From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC6D03D6692 for ; Fri, 26 Jun 2026 06:48:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.95.11.211 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782456500; cv=none; b=KThAvubQ0NPl/pqsYGdaNpByM2WkFE8jHuWHRvLk45tWH/56F+ZEL4plsybxNGRtaNH13aieMo8Q46YzkbO/VcmIUC/RocL3S7E5yGTE3AolrDHokGllFGDax50ATH0OQe1adQlC2wpY5xymQkiDREtxX4dlojO3hhO6kNAK3Rc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782456500; c=relaxed/simple; bh=+2Mo30+AGc4dIqKa7FEzV8Ehn/+fbXu+q9e3lvlOQb8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HtdsrNDKORRYR4md8cCK1Kxhkn/LWp5FoYpPkSSI/jLq77H4ZdzVnx72hvsMjWatD7/mmN0s1YF6o3gEcuRdi0On0wA+fF8s/7NZbOLRz309tKASi3njinvOxWfkEMVBukOTZXjMWXbGXE/66YXQkJnFv+yn3slbl06lPg1m2qg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lst.de; spf=pass smtp.mailfrom=lst.de; arc=none smtp.client-ip=213.95.11.211 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lst.de Received: by verein.lst.de (Postfix, from userid 2407) id C8C5968B05; Fri, 26 Jun 2026 08:48:16 +0200 (CEST) Date: Fri, 26 Jun 2026 08:48:16 +0200 From: Christoph Hellwig To: Nilay Shroff Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, hch@lst.de, kbusch@kernel.org, sagi@grimberg.me, axboe@fb.com, bvanassche@acm.org, elver@google.com, gjoyce@linux.ibm.com Subject: Re: [PATCHv2 12/17] nvme: add Clang context annotations for nvme_queue::cq_poll_lock Message-ID: <20260626064816.GB11106@lst.de> References: <20260614131541.2017845-1-nilay@linux.ibm.com> <20260614131541.2017845-13-nilay@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260614131541.2017845-13-nilay@linux.ibm.com> User-Agent: Mutt/1.5.17 (2007-11-01) On Sun, Jun 14, 2026 at 06:45:27PM +0530, Nilay Shroff wrote: > nvme_queue::cqes, nvme_queue::cq_head, and nvme_queue::cq_phase are > protected by nvme_queue::cq_poll_lock. Annotate these fields with > __guarded_by(&cq_poll_lock) and annotate helpers accessing them with > __must_hold(&cq_poll_lock) so that Clang's context analysis can > validate the locking requirements. > > IRQ-based queues do not use cq_poll_lock and instead rely on interrupt > serialization. Annotate nvme_irq() and nvme_irq_check() with > __context_unsafe() to suppress the corresponding context analysis > warnings. > > nvme_poll() invokes nvme_cqe_pending() as a lockless fast-path check > before acquiring cq_poll_lock. This check is intentionally kept outside > the lock because nvme_poll() may be called repeatedly in a tight polling > loop until completions are found. The result is only advisory, as the > completion queue is subsequently revalidated under cq_poll_lock by > nvme_poll_cq(). Suppress the corresponding context analysis warning by > annotating the lockless invocation of nvme_cqe_pending() with > context_unsafe(). I'm not sure the annotation really buys us anything in this form, as it makes bold claims about a guard and then ignores it for the most common case.