rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zqiang <qiang1.zhang@intel.com>
To: urezki@gmail.com, paulmck@kernel.org, frederic@kernel.org,
	joel@joelfernandes.org, qiang1.zhang@intel.com
Cc: qiang.zhang1211@gmail.com, rcu@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] rcu/kvfree: Make fill page cache start from krcp->nr_bkv_objs
Date: Wed, 12 Apr 2023 22:31:27 +0800	[thread overview]
Message-ID: <20230412143127.1062367-1-qiang1.zhang@intel.com> (raw)

The fill_page_cache_func() is invoked and start from zero to
allocate nr_pages of page, if the kfree_rcu_work() executes before
the fill_page_cache_func(), the krcp->nr_bkv_objs is updated before
enter for-loop and equal to nr_pages, since the page is allocated
first, and then check the krcp->nr_bkv_objs in put_cached_bnode(),
this produces a meaningless __get_free_page() call, this commit
therefore make allocate page start from krcp->nr_bkv_objs and
check krcp->nr_bkv_objs before allocate page.

Signed-off-by: Zqiang <qiang1.zhang@intel.com>
---
 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 41daae3239b5..dcb86f9f2dd6 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3223,7 +3223,7 @@ static void fill_page_cache_func(struct work_struct *work)
 	nr_pages = atomic_read(&krcp->backoff_page_cache_fill) ?
 		1 : rcu_min_cached_objs;
 
-	for (i = 0; i < nr_pages; i++) {
+	for (i = READ_ONCE(krcp->nr_bkv_objs); i < nr_pages; i++) {
 		bnode = (struct kvfree_rcu_bulk_data *)
 			__get_free_page(GFP_KERNEL | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN);
 
-- 
2.32.0


             reply	other threads:[~2023-04-12 14:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12 14:31 Zqiang [this message]
2023-04-13  9:07 ` [PATCH] rcu/kvfree: Make fill page cache start from krcp->nr_bkv_objs Uladzislau Rezki
2023-04-13 18:50   ` Paul E. McKenney

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=20230412143127.1062367-1-qiang1.zhang@intel.com \
    --to=qiang1.zhang@intel.com \
    --cc=frederic@kernel.org \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=qiang.zhang1211@gmail.com \
    --cc=rcu@vger.kernel.org \
    --cc=urezki@gmail.com \
    /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).