rcu/kvfree: Make fill page cache start from krcp->nr_bkv_objs
authorZqiang <qiang1.zhang@intel.com>
Wed, 12 Apr 2023 14:31:27 +0000 (22:31 +0800)
committerPaul E. McKenney <paulmck@kernel.org>
Wed, 10 May 2023 00:26:21 +0000 (17:26 -0700)
commit60888b77a06ea16665e4df980bb86b418253e268
tree7afe5fc6bdac65bb933b8392689cead882d1664b
parent021a5ff8474379cd6c23e9b0e97aa27e5ff66a8b
rcu/kvfree: Make fill page cache start from krcp->nr_bkv_objs

When the fill_page_cache_func() function is invoked, it assumes that
the cache of pages is completely empty.  However, there can be some time
between triggering execution of this function and its actual invocation.
During this time, kfree_rcu_work() might run, and might fill in part or
all of this cache of pages, thus invalidating the fill_page_cache_func()
function's assumption.

This will not overfill the cache because put_cached_bnode() will reject
the extra page.  However, it will result in a needless allocation and
freeing of one extra page, which might not be helpful under lowish-memory
conditions.

This commit therefore causes the fill_page_cache_func() to explicitly
account for pages that have been placed into the cache shortly before
it starts running.

Signed-off-by: Zqiang <qiang1.zhang@intel.com>
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/rcu/tree.c