linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Moyer <jmoyer@redhat.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: bcrl@kvack.org, viro@zeniv.linux.org.uk, linux-aio@kvack.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] aio: Save a few cycles in 'lookup_ioctx()'
Date: Mon, 15 Aug 2022 14:10:49 -0400	[thread overview]
Message-ID: <x49czd1xtqu.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <a8666743-4dc5-79b8-56c7-23c05fc88d66@wanadoo.fr> (Christophe JAILLET's message of "Fri, 12 Aug 2022 06:54:09 +0200")

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>


      reply	other threads:[~2022-08-15 18:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=x49czd1xtqu.fsf@segfault.boston.devel.redhat.com \
    --to=jmoyer@redhat.com \
    --cc=bcrl@kvack.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-aio@kvack.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).