* 2 futex questions
@ 2002-09-25 0:33 alfred
2002-09-25 8:23 ` Ingo Molnar
0 siblings, 1 reply; 3+ messages in thread
From: alfred @ 2002-09-25 0:33 UTC (permalink / raw)
To: linux-kernel
1) There's a comment in sys_futex(...) that says pos_in_page must not be on a page boundary.
Could someone explain why?
2) How is this ever true:
pos_in_page + sizeof(int) > PAGE_SIZE
when checking if pos_in_page is valid?
Thanks,
Alfred Landrum
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 2 futex questions
2002-09-25 0:33 2 futex questions alfred
@ 2002-09-25 8:23 ` Ingo Molnar
2002-09-25 1:14 ` [patch] " alfred
0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2002-09-25 8:23 UTC (permalink / raw)
To: alfred; +Cc: linux-kernel
On Tue, 24 Sep 2002 alfred@leakybucket.org wrote:
> 1) There's a comment in sys_futex(...) that says pos_in_page must not be
> on a page boundary. Could someone explain why?
what it wants to say: 'the futex word must not overflow into the next
page', ie. the futex word needs to be on a single page.
> 2) How is this ever true:
> pos_in_page + sizeof(int) > PAGE_SIZE
> when checking if pos_in_page is valid?
the full test is this:
pos_in_page = ((unsigned long)uaddr) % PAGE_SIZE;
if ((pos_in_page % __alignof__(int)) != 0
|| pos_in_page + sizeof(int) > PAGE_SIZE)
return -EINVAL;
what it says: 'uaddr must be naturally aligned, and the word must be on a
single page'. In theory it's possible that __alignof__(int) !=
sizeof(int).
Ingo
^ permalink raw reply [flat|nested] 3+ messages in thread
* [patch] Re: 2 futex questions
2002-09-25 8:23 ` Ingo Molnar
@ 2002-09-25 1:14 ` alfred
0 siblings, 0 replies; 3+ messages in thread
From: alfred @ 2002-09-25 1:14 UTC (permalink / raw)
To: linux-kernel
On Wed, Sep 25, 2002 at 10:23:16AM +0200, Ingo Molnar wrote:
>
> what it says: 'uaddr must be naturally aligned, and the word must be on a
> single page'. In theory it's possible that __alignof__(int) !=
> sizeof(int).
>
Ok, would the following actually save some cycles then?
diff -u a/kernel/futex.c b/kernel/futex.c
--- a/kernel/futex.c Tue Sep 24 15:25:01 2002
+++ b/kernel/futex.c Tue Sep 24 18:09:09 2002
@@ -321,9 +321,10 @@
pos_in_page = ((unsigned long)uaddr) % PAGE_SIZE;
- /* Must be "naturally" aligned, and not on page boundary. */
+ /* Must be "naturally" aligned, and must not cross a page boundary. */
if ((pos_in_page % __alignof__(int)) != 0
- || pos_in_page + sizeof(int) > PAGE_SIZE)
+ || ((sizeof(int) != __alignof__(int))
+ && (pos_in_page + sizeof(int) > PAGE_SIZE)))
return -EINVAL;
/* Simpler if it doesn't vanish underneath us. */
Alfred Landrum
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-09-25 8:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-25 0:33 2 futex questions alfred
2002-09-25 8:23 ` Ingo Molnar
2002-09-25 1:14 ` [patch] " alfred
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).