From: Hauke Mehrtens <hauke@hauke-m.de>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless <linux-wireless@vger.kernel.org>
Subject: Re: compat-wireless: backporting kfree_rcu()?
Date: Mon, 14 Nov 2011 20:10:15 +0100 [thread overview]
Message-ID: <4EC16797.40208@hauke-m.de> (raw)
In-Reply-To: <1318925897.3958.11.camel@jlt3.sipsolutions.net>
Hi Johannes,
now your patch using kfree_rcu went into linux-next. ;-)
On 10/18/2011 10:18 AM, Johannes Berg wrote:
> So I was looking at backporting kfree_rcu(), and came up with this:
>
> #define kfree_rcu(data, rcuhead) do { \
> void __kfree_rcu_fn(struct rcu_head *rcu_head) \
> { \
> void *___ptr; \
> ___ptr = container_of(rcu_head, typeof(*(data)), rcuhead);\
> kfree(___ptr); \
> } \
> call_rcu(&(data)->rcuhead, __kfree_rcu_fn); \
> } while (0)
>
>
> This works, thanks to gcc supporting nested functions, but has one major
> issue: any module using call_rcu() must have an rcu_barrier() in its
> module_exit() because __kfree_rcu_fn() might be called after the module
> is unloaded. For kfree_rcu() this isn't needed since the function called
> lives in the base kernel.
This looks nice to me.
> I played around with injecting a call to rcu_barrier() into module exit
> by modifying module_exit() but I couldn't make the CPP do that. Anyone
> else have any ideas?
I played around with module_exit and modified the define into the
following. Now rcu_barrier() gets called on every module_exit. As
modules are not unloaded so often it should not hurd that this is also
done when unloading a module not using kfree_rcu().
#undef module_exit
#define module_exit(exitfn) \
void __exit __exit_rcu_barrier(void) \
{ \
exitfn(); \
rcu_barrier(); \
} \
static inline exitcall_t __exittest(void) \
{ return exitfn; } \
void cleanup_module(void) __attribute__((alias("__exit_rcu_barrier")));
>
> Another idea I had was to insert the __kfree_rcu_fn() code into the
> compat module instead, but I can't see how to do that short of using
> some source post-processing scripts.
Johannes are you fine with this?
Hauke
next prev parent reply other threads:[~2011-11-14 19:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-18 8:18 compat-wireless: backporting kfree_rcu()? Johannes Berg
2011-10-18 10:07 ` Johannes Berg
2011-10-18 10:22 ` Johannes Berg
2011-11-14 19:10 ` Hauke Mehrtens [this message]
2011-11-14 20:24 ` Johannes Berg
2011-11-14 21:21 ` Luis R. Rodriguez
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=4EC16797.40208@hauke-m.de \
--to=hauke@hauke-m.de \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@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).