All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] aio: Save a few cycles in 'lookup_ioctx()'
@ 2021-11-03 21:31 Christophe JAILLET
  2022-08-12  4:54 ` Christophe JAILLET
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2021-11-03 21:31 UTC (permalink / raw)
  To: bcrl, viro
  Cc: linux-aio, linux-fsdevel, linux-kernel, kernel-janitors,
	Christophe JAILLET

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>
---
 fs/aio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/aio.c b/fs/aio.c
index 9c81cf611d65..d189ea13e10a 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1062,7 +1062,7 @@ static struct kioctx *lookup_ioctx(unsigned long ctx_id)
 	id = array_index_nospec(id, table->nr);
 	ctx = rcu_dereference(table->table[id]);
 	if (ctx && ctx->user_id == ctx_id) {
-		if (percpu_ref_tryget_live(&ctx->users))
+		if (percpu_ref_tryget_live_rcu(&ctx->users))
 			ret = ctx;
 	}
 out:
-- 
2.30.2


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

* Re: [PATCH] aio: Save a few cycles in 'lookup_ioctx()'
  2021-11-03 21:31 [PATCH] aio: Save a few cycles in 'lookup_ioctx()' Christophe JAILLET
@ 2022-08-12  4:54 ` Christophe JAILLET
  2022-08-15 18:10   ` Jeff Moyer
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2022-08-12  4:54 UTC (permalink / raw)
  To: bcrl, viro; +Cc: linux-aio, linux-fsdevel, linux-kernel, kernel-janitors

Le 03/11/2021 à 22:31, 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>
> ---
>   fs/aio.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/aio.c b/fs/aio.c
> index 9c81cf611d65..d189ea13e10a 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -1062,7 +1062,7 @@ static struct kioctx *lookup_ioctx(unsigned long ctx_id)
>   	id = array_index_nospec(id, table->nr);
>   	ctx = rcu_dereference(table->table[id]);
>   	if (ctx && ctx->user_id == ctx_id) {
> -		if (percpu_ref_tryget_live(&ctx->users))
> +		if (percpu_ref_tryget_live_rcu(&ctx->users))
>   			ret = ctx;
>   	}
>   out:


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.

Saving a few cycles in a function with "lookup" in its name looks always 
good to me.

CJ

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

* Re: [PATCH] aio: Save a few cycles in 'lookup_ioctx()'
  2022-08-12  4:54 ` Christophe JAILLET
@ 2022-08-15 18:10   ` Jeff Moyer
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Moyer @ 2022-08-15 18:10 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: bcrl, viro, linux-aio, linux-fsdevel, linux-kernel, kernel-janitors

Christophe JAILLET <christophe.jaillet@wanadoo.fr> writes:

> Le 03/11/2021 à 22:31, 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>
>> ---
>>   fs/aio.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/aio.c b/fs/aio.c
>> index 9c81cf611d65..d189ea13e10a 100644
>> --- a/fs/aio.c
>> +++ b/fs/aio.c
>> @@ -1062,7 +1062,7 @@ static struct kioctx *lookup_ioctx(unsigned long ctx_id)
>>   	id = array_index_nospec(id, table->nr);
>>   	ctx = rcu_dereference(table->table[id]);
>>   	if (ctx && ctx->user_id == ctx_id) {
>> -		if (percpu_ref_tryget_live(&ctx->users))
>> +		if (percpu_ref_tryget_live_rcu(&ctx->users))
>>   			ret = ctx;
>>   	}
>>   out:
>
>
> 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.
>
> Saving a few cycles in a function with "lookup" in its name looks
> always good to me.

The patch looks fine to me.

Reviewed-by: Jeff Moyer <jmoyer@redhat.com>


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

end of thread, other threads:[~2022-08-15 18:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03 21:31 [PATCH] aio: Save a few cycles in 'lookup_ioctx()' Christophe JAILLET
2022-08-12  4:54 ` Christophe JAILLET
2022-08-15 18:10   ` Jeff Moyer

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.