Received: by 10.213.65.68 with SMTP id h4csp3922342imn; Tue, 3 Apr 2018 13:06:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/x83wlqp5/ZUEB+uqBO8/Lm5gbRWwL3aZoxBvhRfBzG/0y0NbvlzQQT9Kr3KgZVkALnYU/ X-Received: by 10.99.95.144 with SMTP id t138mr9801367pgb.94.1522785997177; Tue, 03 Apr 2018 13:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522785997; cv=none; d=google.com; s=arc-20160816; b=ijnERLk+Y8gvquqLJli4x3CK2E3yYtNErKpZut6WN+6nqd/VCjeRUHizTiAKjwLS5N sL8OeQdnnAzodl2ZRBB27kRFlbvJ9z6K/QEYimy54KooIloBkjJWj2OIDwdyMMO8Gki/ S7h706s/Y5YheZj6Ak87kd63YzWImuBj1IfcNEsIBDWBlLy7K8MwwGNELYCYTeGS09KU +Tx9jD1eDZS8q9+sNr2bENHOrbAowDgN47n+bT+EqO5IQsmrUOPE7Kgz+APZyMgZ2yk+ ew8L8d9ez7Vrrt+H2VNZIWklIgyP8NQ1Z3hVYrHvCJYYZzz7cg+jjf/WAyB0T77Zm1gq p5VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date:arc-authentication-results; bh=bnydGLqGAnhwXKjF1kI9Sk+EmT4/GsIIpJztNokW5ko=; b=FI898dT9cv+K0ulV6agJAl9cDSLFPAXgS6DBK0c6027I7feokzpZvJ4FAblVwGf3EV JPLtK1ISr7ftCzMeJkAHTMyGBk57oswHOPTvx7qXO13IWdAfMkcXTUDBTj4hfkV8vlSp 1qDIYuqkTlN5uWbyjuh/Re+WPwkOQCjTE3vJ9Cp302Z1vpPuVOJx1qhCRkxix1pRHGrh dQmEzK3QDy6kwXGmSMZqmiFeS15feLsKARwDsrn16PFxzU2rhsDbeNsdvT7/vFIDu0w6 fxFO3iZ2f5k/smy2mKtgK1YketgEYGoXyMWQzxY9pigdyH1bc9IEKJBXg3RqqCGcnjiW jBcQ== ARC-Authentication-Results: i=1; mx.google.com; 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 c32-v6si1226466plj.381.2018.04.03.13.06.22; Tue, 03 Apr 2018 13:06:37 -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; 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 S1752986AbeDCUEp (ORCPT + 99 others); Tue, 3 Apr 2018 16:04:45 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:32968 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751859AbeDCUEo (ORCPT ); Tue, 3 Apr 2018 16:04:44 -0400 Received: (qmail 6467 invoked by uid 2102); 3 Apr 2018 16:04:43 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 3 Apr 2018 16:04:43 -0400 Date: Tue, 3 Apr 2018 16:04:43 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Andrea Parri cc: David Howells , , Ingo Molnar , Peter Zijlstra , , Andrea Parri , Will Deacon , Boqun Feng , Nicholas Piggin , Jade Alglave , Luc Maranget , Akira Yokosawa Subject: Re: [PATCH v2 1/3] locking: Document the semantics of spin_is_locked() In-Reply-To: <20180403193139.GA6143@andrea> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 3 Apr 2018, Andrea Parri wrote: > On Tue, Apr 03, 2018 at 04:23:07PM +0100, David Howells wrote: > > Andrea Parri wrote: > > > > > Sorry, but I don't understand your objection: are you suggesting to add > > > something like "Always return 0 on !SMP" to the comment? what else? > > > > Something like that, possibly along with a warning that this might not be what > > you want. You might actually want it to return true on !SMP, it depends on > > what you're using it for. > > I ended up with the following revision. I hesitated on whether to refer > to 'include/linux/spinlock_up.h' or not, but in the end I decided to not > include the reference. Please let me know what you think about this. > +/** > + * 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. > + * > + * Remark that this primitve can return a fixed value > + * under certain !SMP configurations. I would change these last two paragraphs as follows: + * Returns: 1 if @lock is locked, 0 otherwise. + * However, on !CONFIG_SMP builds with !CONFIG_DEBUG_SPINLOCK, + * the return value is always 0 (see include/linux/spinlock_up.h). + * Therefore you should not rely heavily on the return value. Alan