From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Hannes Reinecke <hare@suse.de>,
John Garry <john.garry@huawei.com>,
jinpu.wang@cloud.ionos.com, jejb@linux.ibm.com,
martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
Ajish.Koshy@microchip.com
Subject: Re: [PATCH 3/4] scsi: pm8001: Use non-atomic bitmap ops for tag alloc + free
Date: Mon, 20 Jun 2022 15:07:06 +0900 [thread overview]
Message-ID: <594ac0c9-a55b-bec7-77e3-a6c7e9525f6b@opensource.wdc.com> (raw)
In-Reply-To: <303bbfad-edde-1197-679e-4a09175fb1f3@suse.de>
On 6/20/22 15:00, Hannes Reinecke wrote:
> On 6/10/22 18:46, John Garry wrote:
>> In pm8001_tag_alloc() we don't require atomic set_bit() as we are already
>> in atomic context. In pm8001_tag_free() we should use the same host
>> spinlock to protect clearing the tag (and then don't require the atomic
>> clear_bit()).
>>
>> Signed-off-by: John Garry <john.garry@huawei.com>
>> ---
>> drivers/scsi/pm8001/pm8001_sas.c | 10 +++++++---
>> 1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
>> index 3a863d776724..8e3f2f9ddaac 100644
>> --- a/drivers/scsi/pm8001/pm8001_sas.c
>> +++ b/drivers/scsi/pm8001/pm8001_sas.c
>> @@ -66,7 +66,11 @@ static int pm8001_find_tag(struct sas_task *task, u32 *tag)
>> void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag)
>> {
>> void *bitmap = pm8001_ha->tags;
>> - clear_bit(tag, bitmap);
>> + unsigned long flags;
>> +
>> + spin_lock_irqsave(&pm8001_ha->bitmap_lock, flags);
>> + __clear_bit(tag, bitmap);
>> + spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags);
>> }
>>
> This spin lock is pretty much pointless; clear_bit() is always atomic.
But __clear_bit() is not atomic. I think it was the point of this patch,
to not use atomics and use the spinlock instead to protect bitmap.
Before the patch, pm8001_tag_alloc() takes the spinlock *and* use the
atomic set_bit(), which is an overkill. pm8001_tag_free() only clears the
bit using the the atomic clear_bit().
After the patch, spinlock guarantees atomicity for both alloc and free.
Not sure there is any gain from this.
>
> Cheers,
>
> Hannes
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2022-06-20 6:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-10 16:46 [PATCH 0/4] pm8001 driver improvements John Garry
2022-06-10 16:46 ` [PATCH 1/4] scsi: pm8001: Rework shost initial values John Garry
2022-06-13 6:39 ` Jinpu Wang
2022-06-10 16:46 ` [PATCH 2/4] scsi: pm8001: Setup tags before using them John Garry
2022-06-10 16:46 ` [PATCH 3/4] scsi: pm8001: Use non-atomic bitmap ops for tag alloc + free John Garry
2022-06-20 6:00 ` Hannes Reinecke
2022-06-20 6:07 ` Damien Le Moal [this message]
2022-06-20 6:53 ` Jinpu Wang
2022-06-20 7:40 ` John Garry
2022-06-10 16:46 ` [PATCH 4/4] scsi: pm8001: Expose HW queues for pm80xx hw John Garry
2022-06-13 7:28 ` [PATCH 0/4] pm8001 driver improvements Damien Le Moal
2022-06-17 1:45 ` Martin K. Petersen
2022-06-22 2:10 ` 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=594ac0c9-a55b-bec7-77e3-a6c7e9525f6b@opensource.wdc.com \
--to=damien.lemoal@opensource.wdc.com \
--cc=Ajish.Koshy@microchip.com \
--cc=hare@suse.de \
--cc=jejb@linux.ibm.com \
--cc=jinpu.wang@cloud.ionos.com \
--cc=john.garry@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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®