Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp823848pxa; Wed, 12 Aug 2020 14:20:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMu0peNcHQG07MGsQy8dD4qw8Jud0/ZvXasOw+RC5C+x4tjMsBwnUzixfCD8eJUvJrEhpN X-Received: by 2002:a17:906:3715:: with SMTP id d21mr1713945ejc.281.1597267254749; Wed, 12 Aug 2020 14:20:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597267254; cv=none; d=google.com; s=arc-20160816; b=nyexJHWaqIK31PT/wplNJ+6siSjBl+RHtBC8OSVvbnoFw+ggDaR4TXy5gTGMqh/f41 OdvLr1uZC95lan3d9dmsm8yHLZPyZI4uoLdCBVwcvKUAW0vQMPqNIya+RpW8VJ49F0+I EoYsRcpV0TWVKBzT/9+QWsI+tF9aPs1fqlIlLV8k3UP+qJl1vPcQ6r5algYYqdxHEZMP JB9+zvDh5KkYf2Q3oRr7TLqrnhUIJzdwdYG+I6iB13JoG1wcVl2ncVPHCQJkbWxCpMXo P1VS4Bt+vsy8q89jA47Mgoeh/c7ZmOh/P6mLNtdqBuPJV+U/5F4CFz5n9T5V37HkK867 h9GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=YP33Rn/EtmU6VXuqGQkdyI7r+75/Bs1ZttkQjleicek=; b=1H0UHxCOoBF5EFMornFhL5w+k4MPy1FVs0j2tbC0rz6bK4DeFajeeCC85fu44qpw0t mrEk8OYQsJitAjKQMVWy+OrGHqJWGXOkqF14+H8VExgzcJxqPYnYHuEB6SKms2gTO9pB Tr+eyC5WQ3lSDZ+sq0HxfB2yHj+9vc+bcg/9U0+0KJsqWDh0GS1qIp57F5Et1YIFrI/m AboqYJ71LHs//n5tF25eghj0MaOqSZDAsx0CPZ6Bmefeayt0MOld4/dMDyYUG+Nt1lLm FqnczQHzfBpoMhUBHlW/7VEVN6pNaR506hyfi1LlTvQqqD0tjFwom9xrUUybC+pC2LVB 0roA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZPkAFIa+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z62si2532484ede.173.2020.08.12.14.20.31; Wed, 12 Aug 2020 14:20:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZPkAFIa+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726546AbgHLVUC (ORCPT + 99 others); Wed, 12 Aug 2020 17:20:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:56928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726030AbgHLVUC (ORCPT ); Wed, 12 Aug 2020 17:20:02 -0400 Received: from dhcp-10-100-145-180.wdl.wdc.com (unknown [199.255.45.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2180A20658; Wed, 12 Aug 2020 21:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597267201; bh=AmjQ5uYR6oxVViDZLWc62fXzkb7VPbyJWVNTNVh5UDk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZPkAFIa+yTSlYrEFmY/Jh8cQ2yc0sgRkTHVvo9m7vi6vkUYbg7PAtOfIXoOaGgvYh Vxdg+cbXLcLCBR/MUujLpReYrtpvw/X+pU+PNDr9ZdldrSsbDt+TrAP7r0Y0rqdEz0 +W2EqGaWz2NGUno3aEG0bGsWpB73jPB/cLB8jsfE= Date: Wed, 12 Aug 2020 14:19:59 -0700 From: Keith Busch To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Christoph Hellwig , Sagi Grimberg , Keith Busch , Jens Axboe Subject: Re: [RESEND PATCH] nvme: Use spin_lock_irqsave() when taking the ctrl->lock Message-ID: <20200812211959.GA1238450@dhcp-10-100-145-180.wdl.wdc.com> References: <20200812210119.7155-1-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200812210119.7155-1-logang@deltatee.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.