Re: [patch] x86: convert rdtscll() to use __native_read_tsc

From: Ingo Molnar
Date: Tue Dec 16 2008 - 04:15:48 EST



* Ken Chen <kenchen@xxxxxxxxxx> wrote:

> Is there any reason why x86 rdtscll have to use the out of line function
> instead of inline __native_read_tsc()? native_read_tsc and
> __native_read_tsc is essentially the same functions.

Your patch is correct.

The reason for the __native_read_tsc() / native_read_tsc() distinction is
and obscure problem with paravirt function pointers. Such constructs:

./xen/enlighten.c: .read_tsc = native_read_tsc,

do not always work fine with all versions of gcc, if native_read_tsc() is
a simple static inline (as it should be) - the build would fail with
certain gcc flags. (and i remember runtime problems too) The C semantics
of taking the address of an inline function seem pretty clear: the inlined
function should be instantiated in that .o and a pointer should be
generated out of that local instantiation.

Perhaps the real fix is to do this rename as well:

native_read_tsc => native_read_tsc_paravirt
__native_read_tsc => native_read_tsc

as this makes the native_read_tsc_paravirt() a pure technical variant, to
be used in paravirt_ops function pointer assignments. People would thus
just use the obvious native_read_tsc() inline function most of the time
and could forget about native_read_tsc_paravirt().

Jeremy?

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