Re: [PATCH v2 1/4] drivers: hwspinlock: add generic framework

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ohad Ben-Cohen
Date: Monday, November 29, 2010 - 2:31 pm

Hi Olof,

On Sat, Nov 27, 2010 at 12:51 AM, Olof Johansson <olof@lixom.net> wrote:
...

Np, but let's wait a bit to see if something like the
BUG_ON_MAPPABLE_NULL macro materializes or not. That should satisfy
everyone in a generic way.


That's up to the users of hwspinlock to take care of, we shouldn't
worry about it here.

...

But that's what mb/wmb/rmb are for - we use mb because we care of both
read and write reordering - and then it's up to platform-specific code
to implement it correctly. We shouldn't worry about the
platform-specific implementation of mb/wmb/rmb in drivers.


Sure.


It's not entirely about checking other subsystems: in a way, one can
also look at it as sanity checks to the hwspinlock framework itself.

For example, when we fetch an hwlock object, and then make sure the id
of the hwlock really match the id we looked for, we get a sanity-level
confidence that our data isn't messed up, and that the radix tree was
pretty much used correctly so far.

If, for some reason, that check would fail, that doesn't necessarily
mean the radix code is faulty: it just means something went really
bad, and for some reason the incorrect object is stored with the id we
looked for. It can also be hwspinlock's fault.

It's important to detect such an anomaly as early as possible,
otherwise the wrong lock is going to be used, user data might be
corrupted, and in general, it's going to be veeeery hard to debug
this.

So I consider this a low-cost check with very high value, and if it
would be triggered even once in the lifetime of hwspinlock, it's well
worth it.


Do you consider radix_tree_delete() inappropriate then ?


Such a function is redundant - as this functionality is already
provided in radix_tree_delete, and it'd be a pity not to use it. One
doesn't have to use this return value though, but it really helps
simplifying the users with no additional cost.



It feels to me like encouraging sloppy coding, especially since we're
talking about hardware resources here, but maybe I'm overlooking a
real use case here...


Sure.

Thanks,
Ohad.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH v2 1/4] drivers: hwspinlock: add generic framework, Ohad Ben-Cohen, (Tue Nov 23, 8:38 am)
[PATCH v2 3/4] OMAP4: hwmod data: Add hwspinlock, Ohad Ben-Cohen, (Tue Nov 23, 8:38 am)
[PATCH v2 4/4] omap: add hwspinlock device, Ohad Ben-Cohen, (Tue Nov 23, 8:39 am)
RE: [PATCH v2 1/4] drivers: hwspinlock: add generic framework, Kamoolkar, Mugdha, (Wed Nov 24, 12:44 am)
RE: [PATCH v2 1/4] drivers: hwspinlock: add generic framework, Kamoolkar, Mugdha, (Wed Nov 24, 11:05 pm)
Re: [PATCH v2 1/4] drivers: hwspinlock: add generic framework, Russell King - ARM Linux, (Fri Nov 26, 2:18 am)
Re: [PATCH v2 1/4] drivers: hwspinlock: add generic framework, Russell King - ARM Linux, (Fri Nov 26, 3:45 am)
Re: [PATCH v2 1/4] drivers: hwspinlock: add generic framework, Russell King - ARM Linux, (Fri Nov 26, 3:53 pm)
Re: [PATCH v2 1/4] drivers: hwspinlock: add generic framework, Ohad Ben-Cohen, (Mon Nov 29, 2:31 pm)