Linux block layer
 help / color / mirror / Atom feed
From: Logan Gunthorpe <logang@deltatee.com>
To: Keith Busch <kbusch@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
	linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Sagi Grimberg <sagi@grimberg.me>,
	Keith Busch <keith.busch@wdc.com>, Jens Axboe <axboe@kernel.dk>
Subject: Re: [RESEND PATCH] nvme: Use spin_lock_irqsave() when taking the ctrl->lock
Date: Wed, 12 Aug 2020 15:31:41 -0600	[thread overview]
Message-ID: <b86772c1-17ed-ec44-1b60-7f2ad80bd73c@deltatee.com> (raw)
In-Reply-To: <20200812211959.GA1238450@dhcp-10-100-145-180.wdl.wdc.com>



On 2020-08-12 3:19 p.m., Keith Busch wrote:
> On Wed, Aug 12, 2020 at 03:01:19PM -0600, Logan Gunthorpe wrote:
>> @@ -2971,15 +2971,16 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
>>  static struct nvme_cel *nvme_find_cel(struct nvme_ctrl *ctrl, u8 csi)
>>  {
>>  	struct nvme_cel *cel, *ret = NULL;
>> +	unsigned long flags;
>>
>> -	spin_lock(&ctrl->lock);
>> +	spin_lock_irqsave(&ctrl->lock, flags);
>>  	list_for_each_entry(cel, &ctrl->cels, entry) {
>>  		if (cel->csi == csi) {
>>  			ret = cel;
>>  			break;
>>  		}
>>  	}
>> -	spin_unlock(&ctrl->lock);
>> +	spin_unlock_irqrestore(&ctrl->lock, flags);
>>
>>  	return ret;
>>  }
>> @@ -2988,6 +2989,7 @@ static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi,
>>  				struct nvme_effects_log **log)
>>  {
>>  	struct nvme_cel *cel = nvme_find_cel(ctrl, csi);
>> +	unsigned long flags;
>>  	int ret;
>>
>>  	if (cel)
>> @@ -3006,9 +3008,9 @@ static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi,
>>
>>  	cel->csi = csi;
>>
>> -	spin_lock(&ctrl->lock);
>> +	spin_lock_irqsave(&ctrl->lock, flags);
>>  	list_add_tail(&cel->entry, &ctrl->cels);
>> -	spin_unlock(&ctrl->lock);
>> +	spin_unlock_irqrestore(&ctrl->lock, flags);
>>  out:
>>  	*log = &cel->log;
>>  	return 0;
>>
> 
> Neither of these are ever called from an interrupt disabled context,
> correct? If so, you can just use spin_lock_irq() without saving the
> current irq state.

Yes, I believe that is correct. I'll send a v2 shortly.

Thanks,

Logan

      reply	other threads:[~2020-08-12 21:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-12 21:01 [RESEND PATCH] nvme: Use spin_lock_irqsave() when taking the ctrl->lock Logan Gunthorpe
2020-08-12 21:19 ` Keith Busch
2020-08-12 21:31   ` Logan Gunthorpe [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=b86772c1-17ed-ec44-1b60-7f2ad80bd73c@deltatee.com \
    --to=logang@deltatee.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=keith.busch@wdc.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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