Received: by 10.213.65.68 with SMTP id h4csp159imn; Fri, 6 Apr 2018 14:12:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+YZOQEwQ8pjtrRe4RS8ug0iKnEDCC3b7EGisZbmlPe8XUQhS/40753N+I/Qpb/aOcBeiGf X-Received: by 10.101.101.206 with SMTP id y14mr3647082pgv.220.1523049123724; Fri, 06 Apr 2018 14:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523049123; cv=none; d=google.com; s=arc-20160816; b=axxuZ99JgGJ/sLuyF4yh4Dmvve/dK0nHP12bY1hnv+DfHzVHxa9DvJemNFhTXYyKj9 lwNc0CNtXIClIQtP2jkWIYAE5Nern8dGj4R83UHkAiIJgH7PoONwA535JHd+oRRV+pBm froROmkSt91TaLbzMcSQHyWzfqDXoGM66EXZHcSxLAYGjKPFc98j72LMjEGBon6Y6x2t rbaAUaC/xZFYizd6smO5RANBDwSBS2nY4Nqy5V6kl5Wvk4Q3ALCRY/IQcGDv2PgN4D2F PZir4dI8cEhF4AbRf0vWGq9hhbMwrcGxlHbgLgbirlLnpg7PK975c+ZW8fkvDXZqtM6A mveQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=9rnlsKxELu4AMIiADun5lxWelwsjbKEfIuzUYls6fvw=; b=jNPG+SZG2pkmFZzZt+dVm1BXgrln8CHFX3gM8gfWei15m36JaKITC0Zsvc08HRqrfb 2D8lYqo3zxeGkZ0BtZHRDOg0vmVJTNADFnet1nMDsq9tLIlSR+mjccB8hxrpsfd7QYfZ 5a/Sxu58sV7iKM6OOykCz5862W+ZfpI16FOWj2uFOzu80RIhgEm3peCFWoTzDjKR7Ci8 nUeJn+bFQHVN6cfO2oM+YJYlshPWYem5W/3qD8M3igyrdxdbSdrfaJUvjNEEsDba3uy/ vjXzzOKkWHwbKHzbaQgUIZRRD1S+nu70GD89Z0SVothJM1WuECqXKIp88O0gNBYB8tdF JqNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oug7w/hD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a63si8576550pfc.131.2018.04.06.14.11.26; Fri, 06 Apr 2018 14:12:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oug7w/hD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751642AbeDFVIZ (ORCPT + 99 others); Fri, 6 Apr 2018 17:08:25 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:43520 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751312AbeDFVIY (ORCPT ); Fri, 6 Apr 2018 17:08:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9rnlsKxELu4AMIiADun5lxWelwsjbKEfIuzUYls6fvw=; b=oug7w/hDFmEKuBBw6gP6p7Ml3 LhSwFCFXVUOcOnPkWc+f8sGbKAMYAHptZBa8BXEzIBkUFq1J/kcvMvvz9jiqLPK6UU3EdMn0b3YTP LPoloXrl+3Xj32h5ZJx8KFnfcr5T/k03aEM9AqJI0J2rjyzFSKCtg6h2w/qcM75jcM8uaGR8gFS+u uOzGyecHMjJZqC2gzLaQaj77SJ2LwmfwfxrsgjI1tZLHxU1/3Q5llLQ/hIGfW9MaU1AxnEwvk/Ajw ytRlzT7V2Ucg4/7hYOZfXuWbNb2h2tL2FC/k7lW/Wo89gD8SybFrjeU37zc3MPSpmPfpXjzpf8OdA V2LuIHjXw==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1f4Yan-0003Kv-Rz; Fri, 06 Apr 2018 21:08:17 +0000 Subject: Re: [PATCH v4 1/3] locking: Document the semantics of spin_is_locked() To: paulmck@linux.vnet.ibm.com Cc: Andrea Parri , linux-kernel@vger.kernel.org, Alan Stern , David Howells , Will Deacon , Peter Zijlstra , Boqun Feng , Nicholas Piggin , Jade Alglave , Luc Maranget , Akira Yokosawa , Ingo Molnar References: <1522600912-6208-2-git-send-email-andrea.parri@amarulasolutions.com> <1523044060-5568-1-git-send-email-andrea.parri@amarulasolutions.com> <20180406210741.GF3948@linux.vnet.ibm.com> From: Randy Dunlap Message-ID: <30d15756-1cb4-7123-b4d9-ce2e66861df3@infradead.org> Date: Fri, 6 Apr 2018 14:08:16 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180406210741.GF3948@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/06/2018 02:07 PM, Paul E. McKenney wrote: > On Fri, Apr 06, 2018 at 02:01:41PM -0700, Randy Dunlap wrote: >> On 04/06/2018 12:47 PM, Andrea Parri wrote: >>> There appeared to be a certain, recurrent uncertainty concerning the >>> semantics of spin_is_locked(), likely a consequence of the fact that >>> this semantics remains undocumented or that it has been historically >>> linked to the (likewise unclear) semantics of spin_unlock_wait(). >>> >>> A recent auditing [1] of the callers of the primitive confirmed that >>> none of them are relying on particular ordering guarantees; document >>> this semantics by adding a docbook header to spin_is_locked(). Also, >>> describe behaviors specific to certain CONFIG_SMP=n builds. >>> >>> [1] https://marc.info/?l=linux-kernel&m=151981440005264&w=2 >>> https://marc.info/?l=linux-kernel&m=152042843808540&w=2 >>> https://marc.info/?l=linux-kernel&m=152043346110262&w=2 >>> >>> Co-Developed-by: Andrea Parri >>> Co-Developed-by: Alan Stern >>> Co-Developed-by: David Howells >>> Signed-off-by: Andrea Parri >>> Signed-off-by: Alan Stern >>> Signed-off-by: David Howells >>> Cc: Will Deacon >>> Cc: Peter Zijlstra >>> Cc: Boqun Feng >>> Cc: Nicholas Piggin >>> Cc: Jade Alglave >>> Cc: Luc Maranget >>> Cc: "Paul E. McKenney" >>> Cc: Akira Yokosawa >>> Cc: Ingo Molnar >>> --- >>> include/linux/spinlock.h | 18 ++++++++++++++++++ >>> 1 file changed, 18 insertions(+) >>> >>> diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h >>> index 4894d322d2584..1e8a464358384 100644 >>> --- a/include/linux/spinlock.h >>> +++ b/include/linux/spinlock.h >>> @@ -380,6 +380,24 @@ static __always_inline int spin_trylock_irq(spinlock_t *lock) >>> raw_spin_trylock_irqsave(spinlock_check(lock), flags); \ >>> }) >>> >>> +/** >>> + * spin_is_locked() - Check whether a spinlock is locked. >>> + * @lock: Pointer to the spinlock. >>> + * >>> + * This function is NOT required to provide any memory ordering >>> + * guarantees; it could be used for debugging purposes or, when >>> + * additional synchronization is needed, accompanied with other >>> + * constructs (memory barriers) enforcing the synchronization. >>> + * >>> + * Returns: 1 if @lock is locked, 0 otherwise. >> >> Sorry, minor nit: >> s/Returns:/Return:/ >> (according to kernel-doc.rst) >> >> although I agree that "Returns:" is better. >> [I should have changed that years ago.] > > Agreed, English grammar and templates often seem to conflict. > > So should we change this comment, or are you instead proposing to add > "Returns:" as valid kernel-doc? Please change this patch to current doc syntax. Any changes to kernel-doc syntax would come later. Thanks. > Thanx, Paul > >>> + * >>> + * Note that the function only tells you that the spinlock is >>> + * seen to be locked, not that it is locked on your CPU. >>> + * >>> + * Further, on CONFIG_SMP=n builds with CONFIG_DEBUG_SPINLOCK=n, >>> + * the return value is always 0 (see include/linux/spinlock_up.h). >>> + * Therefore you should not rely heavily on the return value. >>> + */ >>> static __always_inline int spin_is_locked(spinlock_t *lock) >>> { >>> return raw_spin_is_locked(&lock->rlock); >>> >> >> >> -- >> ~Randy >> > -- ~Randy