diff mbox series

[v2] rcu/kvfree: Make drain_page_cache() call return directly if cache is disabled

Message ID 20230418122702.1378299-1-qiang1.zhang@intel.com (mailing list archive)
State Accepted
Commit 0d9e733231cb70a6c20fb1198abad75c67b08956
Headers show
Series [v2] rcu/kvfree: Make drain_page_cache() call return directly if cache is disabled | expand

Commit Message

Zqiang April 18, 2023, 12:27 p.m. UTC
If the rcu_min_cached_objs is set to zero at boot params, the
krcp->page_cache_work will not be triggered to fill page cache,
and the put_cached_bnode() also does not fill page cache, this
also means the krcp->bkvcache is always empty, so not need to
acquire unnecessary krcp->lock to get page from krcp->bkvcache,
this commit therefore make drain_page_cache() return directly if
the rcu_min_cached_objs is zero.

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

Comments

Uladzislau Rezki April 20, 2023, 11:06 a.m. UTC | #1
On Tue, Apr 18, 2023 at 08:27:02PM +0800, Zqiang wrote:
> If the rcu_min_cached_objs is set to zero at boot params, the
> krcp->page_cache_work will not be triggered to fill page cache,
> and the put_cached_bnode() also does not fill page cache, this
> also means the krcp->bkvcache is always empty, so not need to
> acquire unnecessary krcp->lock to get page from krcp->bkvcache,
> this commit therefore make drain_page_cache() return directly if
> the rcu_min_cached_objs is zero.
> 
> Signed-off-by: Zqiang <qiang1.zhang@intel.com>
> ---
>  kernel/rcu/tree.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index 93faf9f5c58f..00620a2117de 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -2924,6 +2924,9 @@ drain_page_cache(struct kfree_rcu_cpu *krcp)
>  	struct llist_node *page_list, *pos, *n;
>  	int freed = 0;
>  
> +	if (!rcu_min_cached_objs)
> +		return 0;
> +
>  	raw_spin_lock_irqsave(&krcp->lock, flags);
>  	page_list = llist_del_all(&krcp->bkvcache);
>  	WRITE_ONCE(krcp->nr_bkv_objs, 0);
> -- 
> 2.32.0
> 
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

--
Uladzislau Rezki
Paul E. McKenney April 24, 2023, 5:35 p.m. UTC | #2
On Thu, Apr 20, 2023 at 01:06:27PM +0200, Uladzislau Rezki wrote:
> On Tue, Apr 18, 2023 at 08:27:02PM +0800, Zqiang wrote:
> > If the rcu_min_cached_objs is set to zero at boot params, the
> > krcp->page_cache_work will not be triggered to fill page cache,
> > and the put_cached_bnode() also does not fill page cache, this
> > also means the krcp->bkvcache is always empty, so not need to
> > acquire unnecessary krcp->lock to get page from krcp->bkvcache,
> > this commit therefore make drain_page_cache() return directly if
> > the rcu_min_cached_objs is zero.
> > 
> > Signed-off-by: Zqiang <qiang1.zhang@intel.com>
> > ---
> >  kernel/rcu/tree.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> > index 93faf9f5c58f..00620a2117de 100644
> > --- a/kernel/rcu/tree.c
> > +++ b/kernel/rcu/tree.c
> > @@ -2924,6 +2924,9 @@ drain_page_cache(struct kfree_rcu_cpu *krcp)
> >  	struct llist_node *page_list, *pos, *n;
> >  	int freed = 0;
> >  
> > +	if (!rcu_min_cached_objs)
> > +		return 0;
> > +
> >  	raw_spin_lock_irqsave(&krcp->lock, flags);
> >  	page_list = llist_del_all(&krcp->bkvcache);
> >  	WRITE_ONCE(krcp->nr_bkv_objs, 0);
> > -- 
> > 2.32.0
> > 
> Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

Queued for further testing and review, thank you both!

						Thanx, Paul
diff mbox series

Patch

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 93faf9f5c58f..00620a2117de 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -2924,6 +2924,9 @@  drain_page_cache(struct kfree_rcu_cpu *krcp)
 	struct llist_node *page_list, *pos, *n;
 	int freed = 0;
 
+	if (!rcu_min_cached_objs)
+		return 0;
+
 	raw_spin_lock_irqsave(&krcp->lock, flags);
 	page_list = llist_del_all(&krcp->bkvcache);
 	WRITE_ONCE(krcp->nr_bkv_objs, 0);