* [PATCH] delay.h: add __must_check to msleep_interruptible
@ 2010-11-04 8:55 Baruch Siach
2010-12-16 6:17 ` Baruch Siach
2010-12-17 23:49 ` Andrew Morton
0 siblings, 2 replies; 5+ messages in thread
From: Baruch Siach @ 2010-11-04 8:55 UTC (permalink / raw)
To: linux-kernel; +Cc: Baruch Siach, Andrew Morton
Code calling msleep_interruptible() must be aware that sleep time might be
shorter than intended as a result of a signal being caught. Code not checking
the return value of msleep_interruptible() is probably buggy, unless it's doing
the signal_pending() check itself, which is redundant.
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
include/linux/delay.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/linux/delay.h b/include/linux/delay.h
index a6ecb34..1be4994 100644
--- a/include/linux/delay.h
+++ b/include/linux/delay.h
@@ -44,7 +44,7 @@ static inline void ndelay(unsigned long x)
extern unsigned long lpj_fine;
void calibrate_delay(void);
void msleep(unsigned int msecs);
-unsigned long msleep_interruptible(unsigned int msecs);
+unsigned long __must_check msleep_interruptible(unsigned int msecs);
void usleep_range(unsigned long min, unsigned long max);
static inline void ssleep(unsigned int seconds)
--
1.7.2.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] delay.h: add __must_check to msleep_interruptible
2010-11-04 8:55 [PATCH] delay.h: add __must_check to msleep_interruptible Baruch Siach
@ 2010-12-16 6:17 ` Baruch Siach
2010-12-16 8:20 ` Andrew Morton
2010-12-17 23:49 ` Andrew Morton
1 sibling, 1 reply; 5+ messages in thread
From: Baruch Siach @ 2010-12-16 6:17 UTC (permalink / raw)
To: linux-kernel; +Cc: Andrew Morton
Hi lkml,
On Thu, Nov 04, 2010 at 10:55:41AM +0200, Baruch Siach wrote:
> Code calling msleep_interruptible() must be aware that sleep time might be
> shorter than intended as a result of a signal being caught. Code not checking
> the return value of msleep_interruptible() is probably buggy, unless it's doing
> the signal_pending() check itself, which is redundant.
Ping?
Any reason not to apply this? This patch could have saved me from an incorrect
handling of signaled userspace processes.
baruch
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
> include/linux/delay.h | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/delay.h b/include/linux/delay.h
> index a6ecb34..1be4994 100644
> --- a/include/linux/delay.h
> +++ b/include/linux/delay.h
> @@ -44,7 +44,7 @@ static inline void ndelay(unsigned long x)
> extern unsigned long lpj_fine;
> void calibrate_delay(void);
> void msleep(unsigned int msecs);
> -unsigned long msleep_interruptible(unsigned int msecs);
> +unsigned long __must_check msleep_interruptible(unsigned int msecs);
> void usleep_range(unsigned long min, unsigned long max);
>
> static inline void ssleep(unsigned int seconds)
> --
> 1.7.2.3
--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] delay.h: add __must_check to msleep_interruptible
2010-12-16 6:17 ` Baruch Siach
@ 2010-12-16 8:20 ` Andrew Morton
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2010-12-16 8:20 UTC (permalink / raw)
To: Baruch Siach; +Cc: linux-kernel
On Thu, 16 Dec 2010 08:17:11 +0200 Baruch Siach <baruch@tkos.co.il> wrote:
> On Thu, Nov 04, 2010 at 10:55:41AM +0200, Baruch Siach wrote:
> > Code calling msleep_interruptible() must be aware that sleep time might be
> > shorter than intended as a result of a signal being caught. Code not checking
> > the return value of msleep_interruptible() is probably buggy, unless it's doing
> > the signal_pending() check itself, which is redundant.
>
> Ping?
Stuck in my backlog. Delayed but not forgotten.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] delay.h: add __must_check to msleep_interruptible
2010-11-04 8:55 [PATCH] delay.h: add __must_check to msleep_interruptible Baruch Siach
2010-12-16 6:17 ` Baruch Siach
@ 2010-12-17 23:49 ` Andrew Morton
2010-12-17 23:55 ` Andrew Morton
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2010-12-17 23:49 UTC (permalink / raw)
To: Baruch Siach; +Cc: linux-kernel
On Thu, 4 Nov 2010 10:55:41 +0200
Baruch Siach <baruch@tkos.co.il> wrote:
> Code calling msleep_interruptible() must be aware that sleep time might be
> shorter than intended as a result of a signal being caught. Code not checking
> the return value of msleep_interruptible() is probably buggy, unless it's doing
> the signal_pending() check itself, which is redundant.
>
True. But there are around 250 callsites which don't check the
msleep_interruptible() return value.
I don't think I want to add 250 new warnings to the kernel build -
it'll take *years* to get them all weeded out and meanwhile it will
cause people to miss other warnings while they're ignoring the
msleep_interruptible() warnings.
So. Some lucky duck needs to get down and start fixing all these
things first, please. Meanwhile, a checkpatch rule which prevents new
occurrences would be good.
Except lots of developers and maintainers can't be assed running
checkpatch, so a volunteer who regularly runs linux-next.patch and
patch-2.6.Y-rcY through checkpatch and then hassles people would also be
good.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] delay.h: add __must_check to msleep_interruptible
2010-12-17 23:49 ` Andrew Morton
@ 2010-12-17 23:55 ` Andrew Morton
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2010-12-17 23:55 UTC (permalink / raw)
To: Baruch Siach, linux-kernel
On Fri, 17 Dec 2010 15:49:47 -0800
Andrew Morton <akpm@linux-foundation.org> wrote:
> On Thu, 4 Nov 2010 10:55:41 +0200
> Baruch Siach <baruch@tkos.co.il> wrote:
>
> > Code calling msleep_interruptible() must be aware that sleep time might be
> > shorter than intended as a result of a signal being caught. Code not checking
> > the return value of msleep_interruptible() is probably buggy, unless it's doing
> > the signal_pending() check itself, which is redundant.
> >
>
> True. But there are around 250 callsites which don't check the
> msleep_interruptible() return value.
One quick way of fixing this would be to add
/*
* Used by callsites which are supposed to be calling msleep_interruptible(),
* but which were failing to properly handle msleep_interruptible()'s return
* value
*/
static inline void msleep_you_suck_fixme_please(unsigned int msecs)
{
msleep(msecs);
}
and then patch all the offending msleep_interruptible() callsites to
use msleep_you_suck_fixme_please(). Then add the __must_check to
msleep_interruptible().
And note that 250 msleep_interruptible() -> msleep() changes will
probably fix lots of bugs.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-12-17 23:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-04 8:55 [PATCH] delay.h: add __must_check to msleep_interruptible Baruch Siach
2010-12-16 6:17 ` Baruch Siach
2010-12-16 8:20 ` Andrew Morton
2010-12-17 23:49 ` Andrew Morton
2010-12-17 23:55 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox