Received: by 10.213.65.68 with SMTP id h4csp1597733imn; Sun, 1 Apr 2018 09:44:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/jEDuHqfmi2IFD0b/coqtbnUjp5cq/RP3hovYZJbM3YlsyYiL9HzBpR1MEGY5+v3xBdYxs X-Received: by 10.101.101.153 with SMTP id u25mr2746812pgv.151.1522601042313; Sun, 01 Apr 2018 09:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522601042; cv=none; d=google.com; s=arc-20160816; b=vIC7c2HwnfbidTEJhqdlI7/L370O8Pxin8OaUbUBQVMtTaix3C3qu3F/Il2nwyMUBE PlUSjJ6xgcQf4fF9o6hoWGHBpZc2V2J0ecvuOfm65tREzQHF+Z1SvZM+1uzNiN1xvRt2 LbP+VTnEMn7IoBalRUHsfVbGlbGVDTLBLNBFWHatSf9YVK9v0duYlAirLjcLrBoo1WJi NRzfgaBsEhdR5yeqlfuKSBFPQPCuSBfUtLfTqgQAlASftXkqKKLbyKZQebU/VUCaVbjg s+tosMhq6dBINCZS/WmV41RbOJGWnCE6dAV0FnQHhJUR2hcLGbRzHjtdDGJNL6nVKJWM Tdng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=1jPe7J95ppT+O6lWo0lAZcs1u1zw0hFu8sq+aO5beE4=; b=iTuCrnE3gUVlNgtSUpuvRpAVSNmUf1RE6HMpzBaJaYYqEspzUlc/aJzFA/G1OIcQ/U BImm9+EiNDIPmheGUlKtEe8HdfDUTOaxSR6RER65kkhwgRBe+02T+Jtn6q14i73cKn/v EeavJPpmgmbmipXjWTN55NQTzDtULtlhelyBjKsxrJZ9jcgRaDPG3nx48wRPplmjRDBY ipDxfjxzDlcLrOAuh8LpNkSehbDqVIE9kug74U2RgV6dnTpEcd/VlY9yhT/dWM3FsNdh jRxMjirA8x4bcvkritU9ASMpMe442rsMCIraWW3rOkPRFivT4ulqahFVO4IYsm+aEjOo gt6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Xdf9Gc6w; 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 31-v6si12789638plk.674.2018.04.01.09.43.48; Sun, 01 Apr 2018 09:44:02 -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=pass header.i=@amarulasolutions.com header.s=google header.b=Xdf9Gc6w; 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 S1753785AbeDAQmj (ORCPT + 99 others); Sun, 1 Apr 2018 12:42:39 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:55048 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753730AbeDAQmg (ORCPT ); Sun, 1 Apr 2018 12:42:36 -0400 Received: by mail-wm0-f66.google.com with SMTP id h76so21993706wme.4 for ; Sun, 01 Apr 2018 09:42:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1jPe7J95ppT+O6lWo0lAZcs1u1zw0hFu8sq+aO5beE4=; b=Xdf9Gc6wQJvoEHjVk+hf/a2T1NHKK/V3iYgtlLex95lJpzQ0hB6PsElCet00rVL8Fw fsw8T0D0fteN6ZDVZfnBbZ0TpHTfD0SEofkOMSLjDe/EuGAiDzAxTAA1fuZ/jmiPmz/A Tz0CgMJDS7888zUV6qSDIGjGjoFzk40vWf4hk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1jPe7J95ppT+O6lWo0lAZcs1u1zw0hFu8sq+aO5beE4=; b=kvW8x13SXGSmK09InKK9+5pI6WLPvGcjDdx6RBIQwITD9SOJ8tcieQJ6qtl2v6YNmc 71uWkZqZWClEqQZKL26BgmNASsz8JjFlSJFwfRxshMZCYYqIOOzJZrpcVgCR7+SG91Wd RflUV+tocLZHUsOkOpbeAoMeIfw2ABQQAdbWU5sEN8kI4YtfjiNXMBlhqOlrwthYcM2S UVxImrw8EhXIaaTOfIefGpDXZMHlS+CkWru7nsLZ1s3oqKMccLUpsUXnbOWgteQaZkmx s8hh8gBRZpomkgY8n+MHiEW+/Ol7LCbP3HEmVMSEqD69ouoExQ53lFGIL7G/acc8lqvP Fgfg== X-Gm-Message-State: AElRT7FMhuFQIg2AYXIQvmwuCLxXePT2ovkp7fvTB19F/tETJwjZoQea w37jIskZNknG9Nd5oeuWvlAdcQ== X-Received: by 10.28.46.5 with SMTP id u5mr7563764wmu.139.1522600954856; Sun, 01 Apr 2018 09:42:34 -0700 (PDT) Received: from localhost.localdomain (host187-49-dynamic.250-95-r.retail.telecomitalia.it. [95.250.49.187]) by smtp.gmail.com with ESMTPSA id a205sm2579302wmf.18.2018.04.01.09.42.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 01 Apr 2018 09:42:34 -0700 (PDT) From: Andrea Parri To: paulmck@linux.vnet.ibm.com, Ingo Molnar , Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Andrea Parri , Andrea Parri , Alan Stern , Will Deacon , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , Akira Yokosawa Subject: [PATCH v2 1/3] locking: Document the semantics of spin_is_locked() Date: Sun, 1 Apr 2018 18:41:50 +0200 Message-Id: <1522600912-6208-2-git-send-email-andrea.parri@amarulasolutions.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522600912-6208-1-git-send-email-andrea.parri@amarulasolutions.com> References: <1522600912-6208-1-git-send-email-andrea.parri@amarulasolutions.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). [1] https://marc.info/?l=linux-kernel&m=151981440005264&w=2 Signed-off-by: Andrea Parri Cc: Alan Stern Cc: Will Deacon Cc: Peter Zijlstra Cc: Boqun Feng Cc: Nicholas Piggin Cc: David Howells Cc: Jade Alglave Cc: Luc Maranget Cc: "Paul E. McKenney" Cc: Akira Yokosawa Cc: Ingo Molnar --- include/linux/spinlock.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index 4894d322d2584..2639fdc9a916c 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -380,6 +380,17 @@ 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. + * + * Return: 1, if @lock is (found to be) locked; 0, otherwise. + */ static __always_inline int spin_is_locked(spinlock_t *lock) { return raw_spin_is_locked(&lock->rlock); -- 2.7.4