Re: [PATCH] uas: replace WARN_ON_ONCE() with assert_spin_locked().

From: Hans de Goede
Date: Mon Aug 11 2014 - 15:53:49 EST


Hi,

On 08/11/2014 09:08 PM, Guenter Roeck wrote:
> On Mon, Aug 11, 2014 at 08:55:07PM +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 08/11/2014 08:19 PM, Guenter Roeck wrote:
>>> On Mon, Aug 11, 2014 at 01:29:26PM +0530, Sanjeev Sharma wrote:
>>>> spin_is_locked() always return false in uniprocessor configuration and therefore it
>>>> would be advise to repalce with assert_spin_locked().
>>>>
>>>> Signed-off-by: Sanjeev Sharma <Sanjeev_Sharma@xxxxxxxxxx>
>>>> ---
>>>> drivers/usb/storage/uas.c | 8 ++++----
>>>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
>>>> index 3f42785..8e5877d 100644
>>>> --- a/drivers/usb/storage/uas.c
>>>> +++ b/drivers/usb/storage/uas.c
>>>> @@ -154,7 +154,7 @@ static void uas_mark_cmd_dead(struct uas_dev_info *devinfo,
>>>> struct scsi_cmnd *cmnd = container_of(scp, struct scsi_cmnd, SCp);
>>>>
>>>> uas_log_cmd_state(cmnd, caller);
>>>> - WARN_ON_ONCE(!spin_is_locked(&devinfo->lock));
>>>> + assert_spin_locked(&devinfo->lock);
>>>
>>> Seems to me that replacing WARN_ON_ONCE (which may be annoying but only
>>> creates a traceback, and only once) with assert_spin_locked (which
>>> crashes the kernel) is a bit drastic.
>>
>> I can see your point, but so far these paranoia checks have never triggered,
>> and having them trigger _always_ one some uni-processor (which is the reason
>> for this patch) to me seems the worse problem of the 2.
>>
> If those are just paranoia checks, it might make sense to use
> lockdep_assert_held() to reduce runtime overhead if lockdep
> debugging is disabled.

Ah yes, that is a good idea.

Sanjeev, can you please send a v2 using lockdep_assert_held() ?

Thanks & Regards,

Hans (the uas driver maintainer)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/