From: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
To: "Paul E . McKenney" <paulmck@kernel.org>
Cc: 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>,
Vlastimil Babka <vbabka@suse.cz>,
Uladzislau Rezki <urezki@gmail.com>,
Oleksiy Avramchenko <oleksiy.avramchenko@sony.com>
Subject: [PATCH v2 1/2] rcu/kvfree: Use polled API in a slow path
Date: Wed, 4 Sep 2024 16:39:37 +0200 [thread overview]
Message-ID: <20240904143938.119964-2-urezki@gmail.com> (raw)
In-Reply-To: <20240904143938.119964-1-urezki@gmail.com>
For a single argument use a polled API to see if a GP is
already passed. This allows to bypass an extra GP request
in a slow path.
Allocating a page or dynamic rcu_head might take some and
still fail, in that scenario a GP which is requested on entry
of kvfree_call_rcu() can be elapsed. Benefit from this.
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
kernel/rcu/tree.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index e641cc681901..182772494cb0 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3789,6 +3789,7 @@ add_ptr_to_bulk_krc_lock(struct kfree_rcu_cpu **krcp,
void kvfree_call_rcu(struct rcu_head *head, void *ptr)
{
unsigned long flags;
+ struct rcu_gp_oldstate old_snap;
struct kfree_rcu_cpu *krcp;
bool success;
@@ -3799,8 +3800,10 @@ void kvfree_call_rcu(struct rcu_head *head, void *ptr)
* only. For other places please embed an rcu_head to
* your data.
*/
- if (!head)
+ if (!head) {
might_sleep();
+ start_poll_synchronize_rcu_full(&old_snap);
+ }
// Queue the object but don't yet schedule the batch.
if (debug_rcu_head_queue(ptr)) {
@@ -3853,7 +3856,7 @@ void kvfree_call_rcu(struct rcu_head *head, void *ptr)
*/
if (!success) {
debug_rcu_head_unqueue((struct rcu_head *) ptr);
- synchronize_rcu();
+ cond_synchronize_rcu_full(&old_snap);
kvfree(ptr);
}
}
--
2.39.2
next prev parent reply other threads:[~2024-09-04 14:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 14:39 [PATCH v2 0/2] Some enhancement for kvfree_rcu_mightsleep() Uladzislau Rezki (Sony)
2024-09-04 14:39 ` Uladzislau Rezki (Sony) [this message]
2024-09-04 14:39 ` [PATCH v2 2/2] rcu/kvfree: Switch to expedited version in slow path Uladzislau Rezki (Sony)
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=20240904143938.119964-2-urezki@gmail.com \
--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