Re: current pointer question/suggestion

Alexander Kjeldaas (astor@guardian.no)
Fri, 17 Jul 1998 19:52:01 +0200


On Fri, Jul 17, 1998 at 01:52:37PM +0100, Alan Cox wrote:
>
> The wait queue is a linked list of who is waiting. That list spans the
> kernel stacks of each process. When you walk a wakeup list you walk
> across all those stacks.
>

Ok - I understand. My point was not to put the _stack_ at a constant
address, but to put _current_ on a constant address by having one
"kernel" page mapped differently in each task.

Currently, the task_struct and the stack are allocated together to
make access to current fast. With current at a constant address,
there would be no need to have the stack in the same area and if we
can do with a 4k stack, no need to allocate a 8k region. But the main
point was that it is slightly faster to do "current = const" than
"current = %esp & ~8191" which is slightly faster than "current =
*(%esp & ~4095)" [is 2.0 something like that?].

The task_struct for current would be mapped two places in memory so
the problem would be to make sure that we don't put any pointers to
current into kernel datastructures but always use a pointer (I called
it current->this) which points to the linear address for the
task_struct.

If this is feasible, it can be used for other structures as well, but
at that time things probably get a bit hairy and there must be a set
of macros that are used instead of the '&' operator when the address
should be accessed outside of the current process.

There could also be a problem if other parts of the kernel wanted to
poke into arbitrary parts of the stack of other processes since such a
stack could have a pointer to current which wouldn't have any meaning
to the poking process. [And based on the comments I got, I thought
some part of the kernel did just that and I couldn't understand why!].

astor

-- 
 Alexander Kjeldaas, Guardian Networks AS, Trondheim, Norway
 http://www.guardian.no/

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html