lkml.org 
[lkml]   [2022]   [Aug]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] mm/mremap_pages: Save a few cycles in 'get_dev_pagemap()'
From
Le 03/11/2021 à 22:35, Christophe JAILLET a écrit :
> Use 'percpu_ref_tryget_live_rcu()' instead of 'percpu_ref_tryget_live()' to
> save a few cycles when it is known that the rcu lock is already
> taken/released.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> mm/memremap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memremap.c b/mm/memremap.c
> index 84de22c14567..012e8d23d365 100644
> --- a/mm/memremap.c
> +++ b/mm/memremap.c
> @@ -506,7 +506,7 @@ struct dev_pagemap *get_dev_pagemap(unsigned long pfn,
> /* fall back to slow path lookup */
> rcu_read_lock();
> pgmap = xa_load(&pgmap_array, PHYS_PFN(phys));
> - if (pgmap && !percpu_ref_tryget_live(pgmap->ref))
> + if (pgmap && !percpu_ref_tryget_live_rcu(pgmap->ref))
> pgmap = NULL;
> rcu_read_unlock();
>

Hi,
gentle reminder.

Is this patch useful?
When I first posted it, percpu_ref_tryget_live_rcu() was really new.
Now it is part of linux since 5.16.

CJ

\
 
 \ /
  Last update: 2022-08-12 06:59    [W:0.078 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site