netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: Brian Gerst <brgerst@gmail.com>,
	aijazbaig1@gmail.com, netfilter-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: help needed with EXPORT_SYMBOL
Date: Mon, 23 Aug 2010 15:43:03 +0200	[thread overview]
Message-ID: <1282570983.2605.1832.camel@laptop> (raw)
In-Reply-To: <alpine.LNX.2.01.1008231527390.21000@obet.zrqbmnf.qr>

On Mon, 2010-08-23 at 15:32 +0200, Jan Engelhardt wrote:
> On Monday 2010-08-23 15:17, Peter Zijlstra wrote:
> 
> >On Mon, 2010-08-23 at 07:48 -0400, Brian Gerst wrote:
> >> 
> >> Use an exported function pointer in the main kernel as a hook that the
> >> module sets when it is loaded.  Note, you must use module_get and
> >> module_put around the call to the module to prevent it from unloading
> >> while in use. 
> >
> >Please don't do any such thing, its impossible to use correctly.
> >
> >Suppose there are two modular users, A and B.
> 
> Though in case there is just a single user it can work out.
> Just like bridge.c, and the bunch of nf_nat_*.c. :-)
> Though yeah. Bad bad.

We have this problem in several areas in the kernel (pm_idle being the
one I hate most since its in code I touch actually grew tons of users).

If you really need to export hooks, provide a registration mechanism and
an arbiter. A very simple, already existing, implementation of this
would be notification chains (include/linux/notifier.h), these provide a
registration interface, and the arbiter is a combination of static
priority combined with return codes.

A more complex example would be the cpuidle/pm_qos subsystem, where you
can register idle states and provide various attributes (exit latency,
energy break even duration, etc) and have the governor pick an idle
state depending on the predicted idle time and required exit latencies.

Bare function pointers suck.

  reply	other threads:[~2010-08-23 13:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-21  6:57 help needed with EXPORT_SYMBOL Aijaz Baig
2010-08-21  9:23 ` Jan Engelhardt
2010-08-23  5:14 ` Aijaz Baig
2010-08-23 11:48   ` Brian Gerst
2010-08-23 13:17     ` Peter Zijlstra
2010-08-23 13:32       ` Jan Engelhardt
2010-08-23 13:43         ` Peter Zijlstra [this message]
2010-08-23 13:44       ` Brian Gerst
2010-08-23 14:05         ` Peter Zijlstra
     [not found]           ` <AANLkTimQDV74kcM_84QySMKmdf-XxFOhqp48cQdQNN4s@mail.gmail.com>
     [not found]             ` <AANLkTinRyoHcSmmHv9tZ36X4wxVVCKGLDwGiZUTPPn+z@mail.gmail.com>
2010-08-24  4:44               ` Aijaz Baig
     [not found]                 ` <AANLkTi=cj+qCFxeT5hq0-x-XqSUCbcqQRAwmQ9h+cOxy@mail.gmail.com>
     [not found]                   ` <AANLkTim9nvJR0K6xJc2kHGCeoMzFLzSxR8Avx59jsEbf@mail.gmail.com>
2010-08-25  9:27                     ` Fwd: " Aijaz Baig
2010-08-25 10:06                       ` Jan Engelhardt
2010-08-25 10:23                       ` Peter Zijlstra
2010-08-25 15:37                       ` Randy Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1282570983.2605.1832.camel@laptop \
    --to=peterz@infradead.org \
    --cc=aijazbaig1@gmail.com \
    --cc=brgerst@gmail.com \
    --cc=jengelh@medozas.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).