[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44L0.1804031557470.1399-100000@iolanthe.rowland.org>
Date: Tue, 3 Apr 2018 16:04:43 -0400 (EDT)
From: Alan Stern <stern@...land.harvard.edu>
To: Andrea Parri <andrea.parri@...rulasolutions.com>
cc: David Howells <dhowells@...hat.com>, <paulmck@...ux.vnet.ibm.com>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
<linux-kernel@...r.kernel.org>,
Andrea Parri <parri.andrea@...il.com>,
Will Deacon <will.deacon@....com>,
Boqun Feng <boqun.feng@...il.com>,
Nicholas Piggin <npiggin@...il.com>,
Jade Alglave <j.alglave@....ac.uk>,
Luc Maranget <luc.maranget@...ia.fr>,
Akira Yokosawa <akiyks@...il.com>
Subject: Re: [PATCH v2 1/3] locking: Document the semantics of spin_is_locked()
On Tue, 3 Apr 2018, Andrea Parri wrote:
> On Tue, Apr 03, 2018 at 04:23:07PM +0100, David Howells wrote:
> > Andrea Parri <andrea.parri@...rulasolutions.com> 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
Powered by blists - more mailing lists