Re: [PATCH] I3 sched tweaks...

From: Ingo Molnar (mingo@elte.hu)
Date: Wed Jan 16 2002 - 18:31:56 EST


On 16 Jan 2002, Robert Love wrote:

> current is stored in a register (esp) in x86, too. [...]

it's stored in a register, but then it also needs to do some more work to
get at the true pointer. The typical way to load 'current' on x86 into
%eax:

        b8 00 e0 ff ff mov $0xffffe000,%eax
        21 e0 and %esp,%eax

7 bytes icache footprint.

while the cost of moving an already calculated 'current' pointer to the
stack is:

        50 push %eax

1 byte instruction.

and in addition, consider that for larger functions, the 'current' value
will be moved to a gcc spill register anyway, it will end up looking like
this:

        b8 00 e0 ff ff mov $0xffffe000,%edi
        21 e0 and %esp,%edi
        89 7c 24 14 mov %edi,0x14(%esp,1)

while in the function-call variant the pointer is on the stack already, so
accessing it is easy:

        89 7c 24 14 mov 0x10(%esp,1), %eax

so on x86, considering the sched_tick() case, it's slightly faster to pass
the argument. But there isnt any big difference.

but add an instruction or two to the 'current' calculation method, and the
icache footprint and actual overhead will be more clearly in favor of
function calls.

i agree that on architectures where 'current' is stored in a register it's
better to use 'current' explicitly.

        Ingo

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Jan 23 2002 - 21:00:17 EST