mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Karan Tilak Kumar <kartilak@cisco.com>
Cc: sebaddel@cisco.com, arulponn@cisco.com, djhawar@cisco.com,
	gcboffa@cisco.com, mkai2@cisco.com, satishkh@cisco.com,
	aeasi@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] scsi: fnic: Remove unnecessary spinlock locking and unlocking
Date: Wed, 26 Feb 2025 10:32:04 +0300	[thread overview]
Message-ID: <80809232-9490-4a0d-8159-af53228b612b@stanley.mountain> (raw)
In-Reply-To: <20250225215146.4937-2-kartilak@cisco.com>

On Tue, Feb 25, 2025 at 01:51:46PM -0800, Karan Tilak Kumar wrote:
> diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c
> index 8843d9486dbb..6530298733f0 100644
> --- a/drivers/scsi/fnic/fdls_disc.c
> +++ b/drivers/scsi/fnic/fdls_disc.c
> @@ -311,36 +311,30 @@ void fdls_schedule_oxid_free_retry_work(struct work_struct *work)
>  	unsigned long flags;
>  	int idx;
>  
> -	spin_lock_irqsave(&fnic->fnic_lock, flags);
> -
>  	for_each_set_bit(idx, oxid_pool->pending_schedule_free, FNIC_OXID_POOL_SZ) {
>  
>  		FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
>  			"Schedule oxid free. oxid idx: %d\n", idx);
>  
> -		spin_unlock_irqrestore(&fnic->fnic_lock, flags);
>  		reclaim_entry = kzalloc(sizeof(*reclaim_entry), GFP_KERNEL);
> -		spin_lock_irqsave(&fnic->fnic_lock, flags);
> -
>  		if (!reclaim_entry) {
>  			schedule_delayed_work(&oxid_pool->schedule_oxid_free_retry,
>  				msecs_to_jiffies(SCHEDULE_OXID_FREE_RETRY_TIME));
> -			spin_unlock_irqrestore(&fnic->fnic_lock, flags);
>  			return;
>  		}
>  
>  		if (test_and_clear_bit(idx, oxid_pool->pending_schedule_free)) {

We discussed this earlier and I really should have brought it up then,
but what is this check about?  We "know" (scare quotes) that it is true
because we're inside a for_each_set_bit() loop.  I had assumed it was to
test for race conditions so that's why I put it under the lock.  If the
locking doesn't matter then we could just do a clear_bit() without doing
a second test.

regards,
dan carpenter

>  			reclaim_entry->oxid_idx = idx;
>  			reclaim_entry->expires = round_jiffies(jiffies + delay_j);
> +			spin_lock_irqsave(&fnic->fnic_lock, flags);
>  			list_add_tail(&reclaim_entry->links, &oxid_pool->oxid_reclaim_list);
> +			spin_unlock_irqrestore(&fnic->fnic_lock, flags);
>  			schedule_delayed_work(&oxid_pool->oxid_reclaim_work, delay_j);
>  		} else {
>  			/* unlikely scenario, free the allocated memory and continue */
>  			kfree(reclaim_entry);
>  		}
>  	}

> -
> -	spin_unlock_irqrestore(&fnic->fnic_lock, flags);
>  }
>  
>  static bool fdls_is_oxid_fabric_req(uint16_t oxid)
> -- 
> 2.47.1

  reply	other threads:[~2025-02-26  7:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 21:51 [PATCH 1/2] scsi: fnic: Replace fnic->lock_flags with local flags Karan Tilak Kumar
2025-02-25 21:51 ` [PATCH 2/2] scsi: fnic: Remove unnecessary spinlock locking and unlocking Karan Tilak Kumar
2025-02-26  7:32   ` Dan Carpenter [this message]
2025-02-27  1:16     ` Karan Tilak Kumar (kartilak)

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=80809232-9490-4a0d-8159-af53228b612b@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=aeasi@cisco.com \
    --cc=arulponn@cisco.com \
    --cc=djhawar@cisco.com \
    --cc=gcboffa@cisco.com \
    --cc=jejb@linux.ibm.com \
    --cc=kartilak@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mkai2@cisco.com \
    --cc=satishkh@cisco.com \
    --cc=sebaddel@cisco.com \
    /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

all inboxes | Powered by JetHome®