From: Uladzislau Rezki <urezki@gmail.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Uladzislau Rezki <urezki@gmail.com>,
Vlastimil Babka <vbabka@suse.cz>, RCU <rcu@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Neeraj upadhyay <Neeraj.Upadhyay@amd.com>,
Boqun Feng <boqun.feng@gmail.com>,
Joel Fernandes <joel@joelfernandes.org>,
Frederic Weisbecker <frederic@kernel.org>,
Oleksiy Avramchenko <oleksiy.avramchenko@sony.com>
Subject: Re: [PATCH v2] rcu/kvfree: Add kvfree_rcu_barrier() API
Date: Fri, 13 Sep 2024 14:24:38 +0200 [thread overview]
Message-ID: <ZuQvBjqEtVus7rGO@pc638.lan> (raw)
In-Reply-To: <4c3647a0-a6f9-40d7-b214-7497af104181@paulmck-laptop>
On Thu, Sep 12, 2024 at 11:07:24AM -0700, Paul E. McKenney wrote:
> On Thu, Sep 12, 2024 at 06:16:56PM +0200, Uladzislau Rezki wrote:
> > On Wed, Sep 11, 2024 at 03:39:19AM -0700, Paul E. McKenney wrote:
> > > On Wed, Sep 11, 2024 at 11:43:54AM +0200, Uladzislau Rezki wrote:
> > > > On Tue, Sep 10, 2024 at 08:42:54AM -0700, Paul E. McKenney wrote:
> > > > > On Tue, Aug 20, 2024 at 05:59:35PM +0200, Uladzislau Rezki (Sony) wrote:
> > > > > > Add a kvfree_rcu_barrier() function. It waits until all
> > > > > > in-flight pointers are freed over RCU machinery. It does
> > > > > > not wait any GP completion and it is within its right to
> > > > > > return immediately if there are no outstanding pointers.
> > > > > >
> > > > > > This function is useful when there is a need to guarantee
> > > > > > that a memory is fully freed before destroying memory caches.
> > > > > > For example, during unloading a kernel module.
> > > > > >
> > > > > > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> > > > > > Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> > > > >
> > > > > As a follow-on patch, once kvfree_rcu_barrier() is accepted into
> > > > > mainline, should we add a call to kvfree_rcu_barrier() to the
> > > > > rcu_barrier_throttled() function in kernel/rcu/tree.c?
> > > > >
> > > > > This would allow the do_rcu_barrier module parameter to be used to clear
> > > > > out kfree_rcu() as well as call_rcu() work. This would be useful to
> > > > > people running userspace benchmarks that cause the kernel to do a lot
> > > > > of kfree_rcu() calls. Always good to avoid messing up the results from
> > > > > the current run due to deferred work from the previous run. Even better
> > > > > would be to actually account for the deferred work, but do_rcu_barrier
> > > > > can help with that as well. ;-)
> > > > >
> > > > > Thoughts?
> > > > >
> > > > Makes sense. To be make sure that all objects are flushed. And as you
> > > > mentioned it is good to have it for benchmarking as a return to a baseline
> > > > point.
> > > >
> > > > One issue is probably a "name" which would be common for both:
> > > >
> > > > rcu_barrier()
> > > > kvfree_rcu_barrier()
> > > >
> > > > i mean /sys/module/rcutree/parameters/do_rcu_barrier. From how i
> > > > would see it, it is supposed to trigger just rcu_barrier() API.
> > >
> > > One approach would be to keep the old functionality, but create
> > > a new sysfs variable that does both. Except that to avoid code
> > > duplication, we would likely end up with both actually doing
> > > both.
> > >
> > > Another approach is to rename the sysfs variable. This might
> > > work if there are not too many people using it. Might. ;-)
> > >
> > > Other approaches?
> > >
> > Maybe just rename from/to: do_rcu_barrier -> do_barrier? Probably this
> > would be the best, but as you noted, there might be users :)
> >
> > To be safe, we can add kvfree_rcu_barrier() to the rcu_barrier_throttled() and
> > document that it does both now!
>
> That does sound safest to me. We just might find that our users (if any)
> expected that it already did both. ;-)
>
Good. Then i will send out the patch!
--
Uladzislau Rezki
prev parent reply other threads:[~2024-09-13 12:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 15:59 [PATCH v2] rcu/kvfree: Add kvfree_rcu_barrier() API Uladzislau Rezki (Sony)
2024-08-21 18:06 ` Vlastimil Babka
2024-08-22 12:04 ` Uladzislau Rezki
2024-09-10 15:42 ` Paul E. McKenney
2024-09-11 9:43 ` Uladzislau Rezki
2024-09-11 10:39 ` Paul E. McKenney
2024-09-12 16:16 ` Uladzislau Rezki
2024-09-12 18:07 ` Paul E. McKenney
2024-09-13 12:24 ` Uladzislau Rezki [this message]
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=ZuQvBjqEtVus7rGO@pc638.lan \
--to=urezki@gmail.com \
--cc=Neeraj.Upadhyay@amd.com \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleksiy.avramchenko@sony.com \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=vbabka@suse.cz \
/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