mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH]: Fix regression added by ppoll/pselect code.
@ 2006-01-20  0:40 David S. Miller
  2006-01-20  4:48 ` David Woodhouse
  0 siblings, 1 reply; 4+ messages in thread
From: David S. Miller @ 2006-01-20  0:40 UTC (permalink / raw)
  To: torvalds; +Cc: dwmw2, akpm, linux-kernel


The compat layer timeout handling changes in:

9f72949f679df06021c9e43886c9191494fdb007

are busted.  This is most easily seen with an X application
that uses sub-second select/poll timeout such as emacs.  You
hit a key and it takes a second or so before the app responds.

The two ROUND_UP() calls upon entry are using {tv,ts}_sec where it
should instead be using {tv_usec,ts_nsec}, which perfectly explains
the observed incorrect behavior.

Another bug shot down with git bisect.

Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/fs/compat.c b/fs/compat.c
index 18b21b4..ff0bafc 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1743,7 +1743,7 @@ asmlinkage long compat_sys_select(int n,
 		if ((u64)tv.tv_sec >= (u64)MAX_INT64_SECONDS)
 			timeout = -1;	/* infinite */
 		else {
-			timeout = ROUND_UP(tv.tv_sec, 1000000/HZ);
+			timeout = ROUND_UP(tv.tv_usec, 1000000/HZ);
 			timeout += tv.tv_sec * HZ;
 		}
 	}
@@ -1884,7 +1884,7 @@ asmlinkage long compat_sys_ppoll(struct 
 		/* We assume that ts.tv_sec is always lower than
 		   the number of seconds that can be expressed in
 		   an s64. Otherwise the compiler bitches at us */
-		timeout = ROUND_UP(ts.tv_sec, 1000000000/HZ);
+		timeout = ROUND_UP(ts.tv_nsec, 1000000000/HZ);
 		timeout += ts.tv_sec * HZ;
 	}
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]: Fix regression added by ppoll/pselect code.
  2006-01-20  0:40 [PATCH]: Fix regression added by ppoll/pselect code David S. Miller
@ 2006-01-20  4:48 ` David Woodhouse
  2006-01-20  4:56   ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: David Woodhouse @ 2006-01-20  4:48 UTC (permalink / raw)
  To: David S. Miller; +Cc: torvalds, akpm, linux-kernel

On Thu, 2006-01-19 at 16:40 -0800, David S. Miller wrote:
> The two ROUND_UP() calls upon entry are using {tv,ts}_sec where it
> should instead be using {tv_usec,ts_nsec}, which perfectly explains
> the observed incorrect behavior.

Hm, I thought akpm had already fixed that -- but thanks.

His patch also changed the simple powers of ten to the slightly
confusing 'NSEC_PER_SEC' and 'USEC_PER_SEC' macros, as if those numbers
are subject to change by later decree, and shouldn't be hard-coded. I
suspect we can do without that part, although I don't really care either
way.

-- 
dwmw2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]: Fix regression added by ppoll/pselect code.
  2006-01-20  4:48 ` David Woodhouse
@ 2006-01-20  4:56   ` Andrew Morton
  2006-01-20  5:04     ` David Woodhouse
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2006-01-20  4:56 UTC (permalink / raw)
  To: David Woodhouse; +Cc: davem, torvalds, linux-kernel

David Woodhouse <dwmw2@infradead.org> wrote:
>
> His patch also changed the simple powers of ten to the slightly
>  confusing 'NSEC_PER_SEC' and 'USEC_PER_SEC' macros, as if those numbers
>  are subject to change by later decree, and shouldn't be hard-coded.

a) They tell you what the magic numbers _mean_.

b) Ever tried counting nine contiguous zeros at 4AM, making sure that
   they're all there?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]: Fix regression added by ppoll/pselect code.
  2006-01-20  4:56   ` Andrew Morton
@ 2006-01-20  5:04     ` David Woodhouse
  0 siblings, 0 replies; 4+ messages in thread
From: David Woodhouse @ 2006-01-20  5:04 UTC (permalink / raw)
  To: Andrew Morton; +Cc: davem, torvalds, linux-kernel

On Thu, 2006-01-19 at 20:56 -0800, Andrew Morton wrote:
> a) They tell you what the magic numbers _mean_.

Yeah, but so does the context.

> b) Ever tried counting nine contiguous zeros at 4AM, making sure that
>    they're all there?

I work on the principle that if I can't even count any more, it's time I
stopped looking at code altogether :)

Do it if you really want to, by all means -- I just think it's a little
gratuitous. Doesn't really hurt though.

-- 
dwmw2


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-01-20  5:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-20  0:40 [PATCH]: Fix regression added by ppoll/pselect code David S. Miller
2006-01-20  4:48 ` David Woodhouse
2006-01-20  4:56   ` Andrew Morton
2006-01-20  5:04     ` David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®