All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rcu/kvfree: Make fill page cache start from krcp->nr_bkv_objs
@ 2023-04-12 14:31 Zqiang
  2023-04-13  9:07 ` Uladzislau Rezki
  0 siblings, 1 reply; 3+ messages in thread
From: Zqiang @ 2023-04-12 14:31 UTC (permalink / raw)
  To: urezki, paulmck, frederic, joel, qiang1.zhang
  Cc: qiang.zhang1211, rcu, linux-kernel

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rcu/kvfree: Make fill page cache start from krcp->nr_bkv_objs
  2023-04-12 14:31 [PATCH] rcu/kvfree: Make fill page cache start from krcp->nr_bkv_objs Zqiang
@ 2023-04-13  9:07 ` Uladzislau Rezki
  2023-04-13 18:50   ` Paul E. McKenney
  0 siblings, 1 reply; 3+ messages in thread
From: Uladzislau Rezki @ 2023-04-13  9:07 UTC (permalink / raw)
  To: Zqiang
  Cc: urezki, paulmck, frederic, joel, qiang.zhang1211, rcu, linux-kernel

On Wed, Apr 12, 2023 at 10:31:27PM +0800, Zqiang wrote:
> 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
> 
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rcu/kvfree: Make fill page cache start from krcp->nr_bkv_objs
  2023-04-13  9:07 ` Uladzislau Rezki
@ 2023-04-13 18:50   ` Paul E. McKenney
  0 siblings, 0 replies; 3+ messages in thread
From: Paul E. McKenney @ 2023-04-13 18:50 UTC (permalink / raw)
  To: Uladzislau Rezki
  Cc: Zqiang, frederic, joel, qiang.zhang1211, rcu, linux-kernel

On Thu, Apr 13, 2023 at 11:07:09AM +0200, Uladzislau Rezki wrote:
> On Wed, Apr 12, 2023 at 10:31:27PM +0800, Zqiang wrote:
> > 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
> > 
> Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

Queued and pushed, thank you both!

							Thanx, Paul

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-13 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-12 14:31 [PATCH] rcu/kvfree: Make fill page cache start from krcp->nr_bkv_objs Zqiang
2023-04-13  9:07 ` Uladzislau Rezki
2023-04-13 18:50   ` Paul E. McKenney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.