From: Karan Tilak Kumar <kartilak@cisco.com>
To: sebaddel@cisco.com
Cc: 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,
Karan Tilak Kumar <kartilak@cisco.com>,
Dan Carpenter <dan.carpenter@linaro.org>
Subject: [PATCH v2 2/2] scsi: fnic: Remove unnecessary spinlock locking and unlocking
Date: Fri, 28 Feb 2025 17:37:12 -0800 [thread overview]
Message-ID: <20250301013712.3115-2-kartilak@cisco.com> (raw)
In-Reply-To: <20250301013712.3115-1-kartilak@cisco.com>
Remove unnecessary locking and unlocking of spinlock in
fdls_schedule_oxid_free_retry_work.
This will shorten the time in the critical section.
Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: a63e78eb2b0f ("scsi: fnic: Add support for fabric based solicited requests and responses")
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Tested-by: Karan Tilak Kumar <kartilak@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
---
Changes between v1 and v2:
Incorporate review comments by Dan:
Replace test and clear bit with clear bit.
---
drivers/scsi/fnic/fdls_disc.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c
index 8843d9486dbb..a9ffa7b63730 100644
--- a/drivers/scsi/fnic/fdls_disc.c
+++ b/drivers/scsi/fnic/fdls_disc.c
@@ -311,36 +311,26 @@ 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)) {
- reclaim_entry->oxid_idx = idx;
- reclaim_entry->expires = round_jiffies(jiffies + delay_j);
- list_add_tail(&reclaim_entry->links, &oxid_pool->oxid_reclaim_list);
- schedule_delayed_work(&oxid_pool->oxid_reclaim_work, delay_j);
- } else {
- /* unlikely scenario, free the allocated memory and continue */
- kfree(reclaim_entry);
- }
+ clear_bit(idx, oxid_pool->pending_schedule_free);
+ 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);
}
-
- spin_unlock_irqrestore(&fnic->fnic_lock, flags);
}
static bool fdls_is_oxid_fabric_req(uint16_t oxid)
--
2.47.1
next prev parent reply other threads:[~2025-03-01 1:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-01 1:37 [PATCH v2 1/2] scsi: fnic: Replace fnic->lock_flags with local flags Karan Tilak Kumar
2025-03-01 1:37 ` Karan Tilak Kumar [this message]
2025-03-01 11:28 ` [PATCH v2 2/2] scsi: fnic: Remove unnecessary spinlock locking and unlocking Dan Carpenter
2025-03-03 20:29 ` Karan Tilak Kumar (kartilak)
2025-03-04 3:09 ` Martin K. Petersen
2025-03-04 3:08 ` [PATCH v2 1/2] scsi: fnic: Replace fnic->lock_flags with local flags Martin K. Petersen
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=20250301013712.3115-2-kartilak@cisco.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