All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: target: Save a few cycles in 'transport_lookup_[cmd|tmr]_lun()'
@ 2021-11-03 21:24 Christophe JAILLET
  2022-08-12  4:52 ` Christophe JAILLET
  2022-08-12 16:12 ` Mike Christie
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2021-11-03 21:24 UTC (permalink / raw)
  To: martin.petersen
  Cc: linux-scsi, 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>
---
 drivers/target/target_core_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 44bb380e7390..bfd5d5606522 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -77,7 +77,7 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd)
 
 		se_lun = rcu_dereference(deve->se_lun);
 
-		if (!percpu_ref_tryget_live(&se_lun->lun_ref)) {
+		if (!percpu_ref_tryget_live_rcu(&se_lun->lun_ref)) {
 			se_lun = NULL;
 			goto out_unlock;
 		}
@@ -154,7 +154,7 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd)
 	if (deve) {
 		se_lun = rcu_dereference(deve->se_lun);
 
-		if (!percpu_ref_tryget_live(&se_lun->lun_ref)) {
+		if (!percpu_ref_tryget_live_rcu(&se_lun->lun_ref)) {
 			se_lun = NULL;
 			goto out_unlock;
 		}
-- 
2.30.2


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

* Re: [PATCH] scsi: target: Save a few cycles in 'transport_lookup_[cmd|tmr]_lun()'
  2021-11-03 21:24 [PATCH] scsi: target: Save a few cycles in 'transport_lookup_[cmd|tmr]_lun()' Christophe JAILLET
@ 2022-08-12  4:52 ` Christophe JAILLET
  2022-08-12 16:12 ` Mike Christie
  1 sibling, 0 replies; 3+ messages in thread
From: Christophe JAILLET @ 2022-08-12  4:52 UTC (permalink / raw)
  To: martin.petersen; +Cc: linux-scsi, linux-kernel, kernel-janitors

Le 03/11/2021 à 22:24, 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>
> ---
>   drivers/target/target_core_device.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
> index 44bb380e7390..bfd5d5606522 100644
> --- a/drivers/target/target_core_device.c
> +++ b/drivers/target/target_core_device.c
> @@ -77,7 +77,7 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd)
>   
>   		se_lun = rcu_dereference(deve->se_lun);
>   
> -		if (!percpu_ref_tryget_live(&se_lun->lun_ref)) {
> +		if (!percpu_ref_tryget_live_rcu(&se_lun->lun_ref)) {
>   			se_lun = NULL;
>   			goto out_unlock;
>   		}
> @@ -154,7 +154,7 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd)
>   	if (deve) {
>   		se_lun = rcu_dereference(deve->se_lun);
>   
> -		if (!percpu_ref_tryget_live(&se_lun->lun_ref)) {
> +		if (!percpu_ref_tryget_live_rcu(&se_lun->lun_ref)) {
>   			se_lun = NULL;
>   			goto out_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.

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] scsi: target: Save a few cycles in 'transport_lookup_[cmd|tmr]_lun()'
  2021-11-03 21:24 [PATCH] scsi: target: Save a few cycles in 'transport_lookup_[cmd|tmr]_lun()' Christophe JAILLET
  2022-08-12  4:52 ` Christophe JAILLET
@ 2022-08-12 16:12 ` Mike Christie
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Christie @ 2022-08-12 16:12 UTC (permalink / raw)
  To: Christophe JAILLET, martin.petersen
  Cc: linux-scsi, linux-kernel, kernel-janitors

On 11/3/21 4:24 PM, Christophe JAILLET wrote:
> 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>
> ---
>  drivers/target/target_core_device.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
> index 44bb380e7390..bfd5d5606522 100644
> --- a/drivers/target/target_core_device.c
> +++ b/drivers/target/target_core_device.c
> @@ -77,7 +77,7 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd)
>  
>  		se_lun = rcu_dereference(deve->se_lun);
>  
> -		if (!percpu_ref_tryget_live(&se_lun->lun_ref)) {
> +		if (!percpu_ref_tryget_live_rcu(&se_lun->lun_ref)) {
>  			se_lun = NULL;
>  			goto out_unlock;
>  		}
> @@ -154,7 +154,7 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd)
>  	if (deve) {
>  		se_lun = rcu_dereference(deve->se_lun);
>  
> -		if (!percpu_ref_tryget_live(&se_lun->lun_ref)) {
> +		if (!percpu_ref_tryget_live_rcu(&se_lun->lun_ref)) {
>  			se_lun = NULL;
>  			goto out_unlock;
>  		}

The patch looks ok.

You just got a little unlucky because the Martin just put some
conflicting patches into his 5.20 staging branch:

https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git/log/?h=5.20/scsi-staging

so I think you want to build your patch against that tree and branch.

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

end of thread, other threads:[~2022-08-12 16:13 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:24 [PATCH] scsi: target: Save a few cycles in 'transport_lookup_[cmd|tmr]_lun()' Christophe JAILLET
2022-08-12  4:52 ` Christophe JAILLET
2022-08-12 16:12 ` Mike Christie

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.