* [PATCH] uas: replace WARN_ON_ONCE() with assert_spin_locked().
@ 2014-08-11 7:59 Sanjeev Sharma
2014-08-11 8:28 ` Greg KH
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Sanjeev Sharma @ 2014-08-11 7:59 UTC (permalink / raw)
To: gregkh
Cc: hdegoede, kraxel, mdharm-usb, linux-usb, linux-kernel, linux-scsi,
Sanjeev Sharma, Sanjeev Sharma
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@mentor.com>
---
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);
WARN_ON_ONCE(cmdinfo->state & COMMAND_ABORTED);
cmdinfo->state |= COMMAND_ABORTED;
cmdinfo->state &= ~IS_IN_WORK_LIST;
@@ -181,7 +181,7 @@ static void uas_add_work(struct uas_cmd_info *cmdinfo)
struct scsi_cmnd *cmnd = container_of(scp, struct scsi_cmnd, SCp);
struct uas_dev_info *devinfo = cmnd->device->hostdata;
- WARN_ON_ONCE(!spin_is_locked(&devinfo->lock));
+ assert_spin_locked(&devinfo->lock);
cmdinfo->state |= IS_IN_WORK_LIST;
schedule_work(&devinfo->work);
}
@@ -283,7 +283,7 @@ static int uas_try_complete(struct scsi_cmnd *cmnd, const char *caller)
struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata;
- WARN_ON_ONCE(!spin_is_locked(&devinfo->lock));
+ assert_spin_locked(&devinfo->lock);
if (cmdinfo->state & (COMMAND_INFLIGHT |
DATA_IN_URB_INFLIGHT |
DATA_OUT_URB_INFLIGHT |
@@ -622,7 +622,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
struct urb *urb;
int err;
- WARN_ON_ONCE(!spin_is_locked(&devinfo->lock));
+ assert_spin_locked(&devinfo->lock);
if (cmdinfo->state & SUBMIT_STATUS_URB) {
urb = uas_submit_sense_urb(cmnd, gfp, cmdinfo->stream);
if (!urb)
--
1.7.11.7
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH] uas: replace WARN_ON_ONCE() with assert_spin_locked().
2014-08-11 7:59 [PATCH] uas: replace WARN_ON_ONCE() with assert_spin_locked() Sanjeev Sharma
@ 2014-08-11 8:28 ` Greg KH
[not found] ` <20140811082811.GC1422-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2014-08-11 18:19 ` Guenter Roeck
2014-08-11 18:56 ` Hans de Goede
2 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2014-08-11 8:28 UTC (permalink / raw)
To: Sanjeev Sharma
Cc: hdegoede, kraxel, mdharm-usb, linux-usb, linux-kernel, linux-scsi
On Mon, Aug 11, 2014 at 01:29:26PM +0530, Sanjeev Sharma wrote:
> spin_is_locked() always return false in uniprocessor configuration
Really? On what processor type? I don't see that being the case on a
few processors, but I didn't check them all, or I might be totally
confused with all of the arch_spin_is_locked() definitions in the tree.
> and therefore it
> would be advise to repalce with assert_spin_locked().
This implies that all uses of this function is wrong and should be
replaced and removed, right?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] uas: replace WARN_ON_ONCE() with assert_spin_locked().
2014-08-11 7:59 [PATCH] uas: replace WARN_ON_ONCE() with assert_spin_locked() Sanjeev Sharma
2014-08-11 8:28 ` Greg KH
@ 2014-08-11 18:19 ` Guenter Roeck
2014-08-11 18:55 ` Hans de Goede
2014-08-11 18:56 ` Hans de Goede
2 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2014-08-11 18:19 UTC (permalink / raw)
To: Sanjeev Sharma
Cc: gregkh, hdegoede, kraxel, mdharm-usb, linux-usb, linux-kernel,
linux-scsi
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@mentor.com>
> ---
> 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.
Guenter
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] uas: replace WARN_ON_ONCE() with assert_spin_locked().
2014-08-11 18:19 ` Guenter Roeck
@ 2014-08-11 18:55 ` Hans de Goede
2014-08-11 19:08 ` Guenter Roeck
0 siblings, 1 reply; 9+ messages in thread
From: Hans de Goede @ 2014-08-11 18:55 UTC (permalink / raw)
To: Guenter Roeck, Sanjeev Sharma
Cc: gregkh, kraxel, mdharm-usb, linux-usb, linux-kernel, linux-scsi
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@mentor.com>
>> ---
>> 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.
Ideally we would have a warn_spin_not_locked or such ...
Regards,
Hans
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] uas: replace WARN_ON_ONCE() with assert_spin_locked().
2014-08-11 18:55 ` Hans de Goede
@ 2014-08-11 19:08 ` Guenter Roeck
2014-08-11 19:53 ` Hans de Goede
0 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2014-08-11 19:08 UTC (permalink / raw)
To: Hans de Goede
Cc: Sanjeev Sharma, gregkh, kraxel, mdharm-usb, linux-usb,
linux-kernel, linux-scsi
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@mentor.com>
> >> ---
> >> 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.
> Ideally we would have a warn_spin_not_locked or such ...
>
There is WARN_ON_SMP, which might have been a better choice if the _ONCE isn't
that important (which one should think if it is ok to crash the kernel if the
problem is seen).
Guenter
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] uas: replace WARN_ON_ONCE() with assert_spin_locked().
2014-08-11 19:08 ` Guenter Roeck
@ 2014-08-11 19:53 ` Hans de Goede
0 siblings, 0 replies; 9+ messages in thread
From: Hans de Goede @ 2014-08-11 19:53 UTC (permalink / raw)
To: Guenter Roeck
Cc: Sanjeev Sharma, gregkh, kraxel, mdharm-usb, linux-usb,
linux-kernel, linux-scsi
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@mentor.com>
>>>> ---
>>>> 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)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] uas: replace WARN_ON_ONCE() with assert_spin_locked().
2014-08-11 7:59 [PATCH] uas: replace WARN_ON_ONCE() with assert_spin_locked() Sanjeev Sharma
2014-08-11 8:28 ` Greg KH
2014-08-11 18:19 ` Guenter Roeck
@ 2014-08-11 18:56 ` Hans de Goede
2 siblings, 0 replies; 9+ messages in thread
From: Hans de Goede @ 2014-08-11 18:56 UTC (permalink / raw)
To: Sanjeev Sharma, gregkh
Cc: kraxel, mdharm-usb, linux-usb, linux-kernel, linux-scsi
Hi,
On 08/11/2014 09:59 AM, 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@mentor.com>
Looks sane / good to me:
Acked-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
> ---
> 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);
> WARN_ON_ONCE(cmdinfo->state & COMMAND_ABORTED);
> cmdinfo->state |= COMMAND_ABORTED;
> cmdinfo->state &= ~IS_IN_WORK_LIST;
> @@ -181,7 +181,7 @@ static void uas_add_work(struct uas_cmd_info *cmdinfo)
> struct scsi_cmnd *cmnd = container_of(scp, struct scsi_cmnd, SCp);
> struct uas_dev_info *devinfo = cmnd->device->hostdata;
>
> - WARN_ON_ONCE(!spin_is_locked(&devinfo->lock));
> + assert_spin_locked(&devinfo->lock);
> cmdinfo->state |= IS_IN_WORK_LIST;
> schedule_work(&devinfo->work);
> }
> @@ -283,7 +283,7 @@ static int uas_try_complete(struct scsi_cmnd *cmnd, const char *caller)
> struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
> struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata;
>
> - WARN_ON_ONCE(!spin_is_locked(&devinfo->lock));
> + assert_spin_locked(&devinfo->lock);
> if (cmdinfo->state & (COMMAND_INFLIGHT |
> DATA_IN_URB_INFLIGHT |
> DATA_OUT_URB_INFLIGHT |
> @@ -622,7 +622,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
> struct urb *urb;
> int err;
>
> - WARN_ON_ONCE(!spin_is_locked(&devinfo->lock));
> + assert_spin_locked(&devinfo->lock);
> if (cmdinfo->state & SUBMIT_STATUS_URB) {
> urb = uas_submit_sense_urb(cmnd, gfp, cmdinfo->stream);
> if (!urb)
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-08-11 22:53 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-11 7:59 [PATCH] uas: replace WARN_ON_ONCE() with assert_spin_locked() Sanjeev Sharma
2014-08-11 8:28 ` Greg KH
[not found] ` <20140811082811.GC1422-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2014-08-11 11:56 ` Sharma, Sanjeev
2014-08-11 22:53 ` Greg KH
2014-08-11 18:19 ` Guenter Roeck
2014-08-11 18:55 ` Hans de Goede
2014-08-11 19:08 ` Guenter Roeck
2014-08-11 19:53 ` Hans de Goede
2014-08-11 18:56 ` Hans de Goede
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).