Re: [patch/revised] wake_up_info() ...

From: Linus Torvalds
Date: Mon Jan 05 2004 - 15:48:41 EST




On Mon, 5 Jan 2004, John Gardiner Myers wrote:
>
> It would seem better if info were a void *, to permit sending more than
> a single unsigned long.

The argument against that is that since there is basically no
synchronization here, you can't pass a pointer to some random object. So
by default, you should think of the cookie as "pass-by-value", ie not a
pointer. That way there are no liveness issues: there is no issue about
what happens to the data when the recipient is actually scheduled
(possibly _much_ much after the actual wakeup).

Also, the forseeable actual use of this piece of data is purely integer:
things like the POLLIN | POLLOUT flags. There may never be any other use.

Also, passing in an "unsigned long" does not preclude using a data area
for more complex cases: if the users do their own synchronization around
the waitqueue on a higher level, and a pointer is a valid thing to use,
you can cast that "unsigned long" to a pointer. This is very common kernel
usage: it may not be "portable" in the theoretical sense, but it's deeply
embedded in the kernel that you can pass pointers as just bitpatters that
fit in an "unsigned long".

The basic rule should be: don't build complex infrastructure. Build simple
infrastructure that you can build complexity on top of if you ever need
it. This was my reaction, and apparently Manfred Spraul reacted the same
way.

Linus
-
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/