From: Uladzislau Rezki <urezki@gmail.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Miroslav Benes <mbenes@suse.cz>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Miroslav Benes <mbenes@suse.cz>,
LKML <linux-kernel@vger.kernel.org>, RCU <rcu@vger.kernel.org>,
"Paul E . McKenney" <paulmck@kernel.org>,
Michal Hocko <mhocko@suse.com>,
Andrew Morton <akpm@linux-foundation.org>,
Daniel Axtens <dja@axtens.net>,
Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <neeraju@codeaurora.org>,
Joel Fernandes <joel@joelfernandes.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
"Theodore Y . Ts'o" <tytso@mit.edu>,
Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>,
Luis Chamberlain <mcgrof@kernel.org>,
jeyu@kernel.org
Subject: Re: [PATCH 8/9] module: Switch to kvfree_rcu() API
Date: Wed, 1 Dec 2021 21:34:44 +0100 [thread overview]
Message-ID: <YafcZIKm9UJqs7c4@pc638.lan> (raw)
In-Reply-To: <Yac/PxQ7I70+O0e0@pc638.lan>
On Wed, Dec 01, 2021 at 10:24:15AM +0100, Uladzislau Rezki wrote:
> On Tue, Nov 30, 2021 at 12:04:19PM +0100, Sebastian Andrzej Siewior wrote:
> > On 2021-11-30 11:39:09 [+0100], Miroslav Benes wrote:
> > > > --- a/kernel/module.c
> > > > +++ b/kernel/module.c
> > > > @@ -4150,8 +4150,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
> > > > ddebug_cleanup:
> > > > ftrace_release_mod(mod);
> > > > dynamic_debug_remove(mod, info->debug);
> > > > - synchronize_rcu();
> > > > - kfree(mod->args);
> > > > + kvfree_rcu(mod->args);
> > > > free_arch_cleanup:
> > > > cfi_cleanup(mod);
> > > > module_arch_cleanup(mod);
> > >
> > > hm, if I am not missing something, synchronize_rcu() is not really
> > > connected to kfree(mod->args) there. synchronize_rcu() was added a long
> > > time ago when kernel/module.c removed stop_machine() from the code and
> > > replaced it with RCU to protect (at least?) mod->list. You can find
> > > list_del_rcu(&mod->list) a couple of lines below.
> >
> > so instead synchronize_rcu() + kfree() you could do
> > call_rcu(&mod->args->rcu, kfree()) but since you have no RCU-head around
> > in args you wait for the grace period and then invoke kfree.
> >
> > kvfree_rcu() is somehow like call_rcu() + kfree() but without the needed
> > RCU-head.
> > So you avoid waiting for the grace period but mod->args is freed later,
> > after as expected.
> >
> > > And yes, one could ask how this all works. The error/cleanup sequence in
> > > load_module() is a giant mess... well, load_module() is a mess too, but
> > > the error path is really not nice.
> >
> > Well, spring is coming :)
> >
> Indeed that error path sequence is terrible. I will double check if that
> synchronize_rcu() + kfree() is related to any RCU protection and freeing.
>
> If it is not i will drop this patch.
>
>
OK, that kfree has nothing to do with RCU protection:
<snip>
commit 6526c534b2677ca601b7b92851437feb041d02a1
Author: Rusty Russell <rusty@rustcorp.com.au>
Date: Thu Aug 5 12:59:10 2010 -0600
module: move module args strndup_user to just before use
Instead of copying and allocating the args and storing it in
load_info, we can just allocate them right before we need them.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
<snip>
so, i will drop my patch, since the intention is not to free a ptr
after a grace period.
Thank you for the review!
--
Vlad Rezki
next prev parent reply other threads:[~2021-12-01 20:35 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-24 11:02 [PATCH 0/9] Switch to single argument kvfree_rcu() API Uladzislau Rezki (Sony)
2021-11-24 11:03 ` [PATCH 1/9] ext4: Switch to " Uladzislau Rezki (Sony)
2021-12-08 14:36 ` Uladzislau Rezki
2021-11-24 11:03 ` [PATCH 2/9] ext4: Replace ext4_kvfree_array_rcu() by " Uladzislau Rezki (Sony)
2021-12-08 14:37 ` Uladzislau Rezki
2021-11-24 11:03 ` [PATCH 3/9] fs: nfs: sysfs: Switch to " Uladzislau Rezki (Sony)
2021-11-24 11:03 ` [PATCH 4/9] drivers: " Uladzislau Rezki (Sony)
2021-11-29 12:58 ` Lee Jones
2021-11-29 15:18 ` Uladzislau Rezki
2021-11-29 17:19 ` Marciniszyn, Mike
2021-12-08 15:24 ` Jason Gunthorpe
2021-11-24 11:03 ` [PATCH 5/9] x86/mm: " Uladzislau Rezki (Sony)
2021-11-24 14:58 ` Steven Rostedt
2021-11-24 14:59 ` Steven Rostedt
2021-11-24 18:01 ` Uladzislau Rezki
2021-11-24 11:03 ` [PATCH 6/9] net/tipc: " Uladzislau Rezki (Sony)
2021-11-24 11:03 ` [PATCH 7/9] net/core: " Uladzislau Rezki (Sony)
2021-11-24 11:03 ` [PATCH 8/9] module: " Uladzislau Rezki (Sony)
2021-11-30 10:39 ` Miroslav Benes
2021-11-30 11:04 ` Sebastian Andrzej Siewior
2021-12-01 9:24 ` Uladzislau Rezki
2021-12-01 20:34 ` Uladzislau Rezki [this message]
2021-11-24 11:03 ` [PATCH 9/9] tracing: " Uladzislau Rezki (Sony)
2021-11-24 15:00 ` Steven Rostedt
2021-11-24 18:03 ` Uladzislau Rezki
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=YafcZIKm9UJqs7c4@pc638.lan \
--to=urezki@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=dja@axtens.net \
--cc=frederic@kernel.org \
--cc=jeyu@kernel.org \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=mcgrof@kernel.org \
--cc=mhocko@suse.com \
--cc=neeraju@codeaurora.org \
--cc=oleksiy.avramchenko@sonymobile.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=rcu@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tytso@mit.edu \
/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