From: "Karan Tilak Kumar (kartilak)" <kartilak@cisco.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: "Sesidhar Baddela (sebaddel)" <sebaddel@cisco.com>,
"Arulprabhu Ponnusamy (arulponn)" <arulponn@cisco.com>,
"Dhanraj Jhawar (djhawar)" <djhawar@cisco.com>,
"Gian Carlo Boffa (gcboffa)" <gcboffa@cisco.com>,
"Masa Kai (mkai2)" <mkai2@cisco.com>,
"Satish Kharat (satishkh)" <satishkh@cisco.com>,
"Arun Easi (aeasi)" <aeasi@cisco.com>,
"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 2/2] scsi: fnic: Remove unnecessary spinlock locking and unlocking
Date: Thu, 27 Feb 2025 01:16:00 +0000 [thread overview]
Message-ID: <SJ0PR11MB5896FD24A1AFD61EE36F549EC3CD2@SJ0PR11MB5896.namprd11.prod.outlook.com> (raw)
In-Reply-To: <80809232-9490-4a0d-8159-af53228b612b@stanley.mountain>
On Tuesday, February 25, 2025 11:32 PM, Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> 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
>
Thanks for your review and comments, Dan.
You are right; We reviewed it, and locking is only needed to add to the reclaim list.
We can use clear_bit. I'll send out a revised patch for this.
Regards,
Karan (on behalf of the Cisco team)
prev parent reply other threads:[~2025-02-27 1:17 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
2025-02-27 1:16 ` Karan Tilak Kumar (kartilak) [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=SJ0PR11MB5896FD24A1AFD61EE36F549EC3CD2@SJ0PR11MB5896.namprd11.prod.outlook.com \
--to=kartilak@cisco.com \
--cc=aeasi@cisco.com \
--cc=arulponn@cisco.com \
--cc=dan.carpenter@linaro.org \
--cc=djhawar@cisco.com \
--cc=gcboffa@cisco.com \
--cc=jejb@linux.ibm.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®