LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrew Morton <firstname.lastname@example.org>
To: Ohad Ben-Cohen <email@example.com>
Cc: <firstname.lastname@example.org>, <email@example.com>,
<firstname.lastname@example.org>, Greg KH <email@example.com>,
Tony Lindgren <firstname.lastname@example.org>,
Benoit Cousson <email@example.com>,
Grant Likely <firstname.lastname@example.org>,
Suman Anna <email@example.com>, Kevin Hilman <firstname.lastname@example.org>,
Arnd Bergmann <email@example.com>, Paul Walmsley <firstname.lastname@example.org>,
Hari Kanigeri <email@example.com>,
Simon Que <firstname.lastname@example.org>
Subject: Re: [PATCH v4 1/4] drivers: hwspinlock: add framework
Date: Mon, 31 Jan 2011 15:38:31 -0800 [thread overview]
Message-ID: <email@example.com> (raw)
On Mon, 31 Jan 2011 12:33:41 +0200
Ohad Ben-Cohen <firstname.lastname@example.org> wrote:
> Add a platform-independent hwspinlock framework.
> Hardware spinlock devices are needed, e.g., in order to access data
> that is shared between remote processors, that otherwise have no
> alternative mechanism to accomplish synchronization and mutual exclusion
> Signed-off-by: Ohad Ben-Cohen <email@example.com>
> Cc: Hari Kanigeri <firstname.lastname@example.org>
> Cc: Benoit Cousson <email@example.com>
> Cc: Kevin Hilman <firstname.lastname@example.org>
> Cc: Grant Likely <email@example.com>
> Cc: Arnd Bergmann <firstname.lastname@example.org>
> Cc: Paul Walmsley <email@example.com>
> Acked-by: Tony Lindgren <firstname.lastname@example.org>
> Documentation/hwspinlock.txt | 299 ++++++++++++++++++
> drivers/Kconfig | 2 +
> drivers/Makefile | 2 +
> drivers/hwspinlock/Kconfig | 13 +
> drivers/hwspinlock/Makefile | 5 +
> drivers/hwspinlock/hwspinlock.h | 61 ++++
> drivers/hwspinlock/hwspinlock_core.c | 557 ++++++++++++++++++++++++++++++++++
> include/linux/hwspinlock.h | 298 ++++++++++++++++++
It's a little irritating having two hwspinlock.h's.
hwspinlock_internal.h wold be a conventional approach. But it's not a
> + * A radix tree is used to maintain the available hwspinlock instances.
> + * The tree associates hwspinlock pointers with their integer key id,
> + * and provides easy-to-use API which makes the hwspinlock core code simple
> + * and easy to read.
> + *
> + * Radix trees are quick on lookups, and reasonably efficient in terms of
> + * storage, especially with high density usages such as this framework
> + * requires (a continuous range of integer keys, beginning with zero, is
> + * used as the ID's of the hwspinlock instances).
> + *
> + * The radix tree API supports tagging items in the tree, which this
> + * framework uses to mark unused hwspinlock instances (see the
> + * HWSPINLOCK_UNUSED tag above). As a result, the process of querying the
> + * tree, looking for an unused hwspinlock instance, is now reduced to a
> + * single radix tree API call.
> + */
> +static RADIX_TREE(hwspinlock_tree, GFP_KERNEL);
> + * __hwspin_lock_timeout() - lock an hwspinlock with timeout limit
> + * @hwlock: the hwspinlock to be locked
> + * @timeout: timeout value in jiffies
hm, why in jiffies?
The problem here is that lazy programmers will use
hwspin_lock_timeout(lock, 10, ...)
and their code will work happily with HZ=100 but will explode with HZ=1000.
IOW, this interface *requires* that all callers perform a
seconds-to-jiffies conversion before calling hwspin_lock_timeout(). So
why not reduce their effort and their ability to make mistakes by
defining the API to take seconds?
> + * @mode: mode which controls whether local interrupts are disabled or not
> + * @flags: a pointer to where the caller's interrupt state will be saved at (if
> + * requested)
> + *
> + * This function locks the given @hwlock. If the @hwlock
> + * is already taken, the function will busy loop waiting for it to
> + * be released, but give up when @timeout jiffies have elapsed. If @timeout
> + * is %MAX_SCHEDULE_TIMEOUT, the function will never give up (therefore if a
> + * faulty remote core never releases the @hwlock, it will deadlock).
> + *
> + * Upon a successful return from this function, preemption is disabled
> + * (and possibly local interrupts, too), so the caller must not sleep,
> + * and is advised to release the hwspinlock as soon as possible.
> + * This is required in order to minimize remote cores polling on the
> + * hardware interconnect.
> + *
> + * The user decides whether local interrupts are disabled or not, and if yes,
> + * whether he wants their previous state to be saved. It is up to the user
> + * to choose the appropriate @mode of operation, exactly the same way users
> + * should decide between spin_lock, spin_lock_irq and spin_lock_irqsave.
> + *
> + * Returns 0 when the @hwlock was successfully taken, and an appropriate
> + * error code otherwise (most notably -ETIMEDOUT if the @hwlock is still
> + * busy after @timeout meets jiffies). The function will never sleep.
> + */
next prev parent reply other threads:[~2011-01-31 23:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-31 10:33 [PATCH v4 0/4] Introduce hardware spinlock framework Ohad Ben-Cohen
2011-01-31 10:33 ` [PATCH v4 1/4] drivers: hwspinlock: add framework Ohad Ben-Cohen
2011-01-31 23:38 ` Andrew Morton [this message]
2011-02-01 6:20 ` Ohad Ben-Cohen
2011-02-01 6:38 ` Andrew Morton
2011-02-01 7:36 ` Ohad Ben-Cohen
2011-02-01 7:40 ` Andrew Morton
2011-02-01 8:12 ` Ohad Ben-Cohen
2011-02-02 12:11 ` Russell King - ARM Linux
2011-02-04 1:47 ` Tony Lindgren
2011-02-01 14:17 ` Greg KH
2011-02-01 15:34 ` Arnd Bergmann
2011-01-31 10:33 ` [PATCH v4 2/4] drivers: hwspinlock: add OMAP implementation Ohad Ben-Cohen
2011-01-31 10:33 ` [PATCH v4 3/4] OMAP4: hwmod data: Add hwspinlock Ohad Ben-Cohen
2011-01-31 10:33 ` [PATCH v4 4/4] omap: add hwspinlock device Ohad Ben-Cohen
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--subject='Re: [PATCH v4 1/4] drivers: hwspinlock: add framework' \
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).