Re: How to use a different sched_clock() for ftrace on omap?

From: Ryan Mallon
Date: Wed May 06 2009 - 20:41:41 EST


Tim Bird wrote:
> Hi all,
>
> I've worked up a replacement sched_clock for ftrace on my omap platform.
> The current sched_clock, based on the 32K timer, has low resolution and
> doesn't provide very useful results.
>
> Unfortunately, I'm not sure the best way to use my special one, in place
> of a common one in arch/arm/plat-omap/common.c
>
> I thought the __attribute__ ((weak)) would be enough to have the
> sched_clock() in common.c get out of the way, and allow my board-specific
> sched_clock() to be used. But that didn't work.

Not sure that will work correctly since sched_clock in kernel/sched.c is
already defined as weak. If you have two weak versions of a function I
think the one which gets used is based on link order (if your board's
sched_clock is not being used).

> What is the recommended
> way to specify a board-specific function at compile time?

You could look at arch/x86/kernel/tsc_32.c, I think it does what you
want by using the function called native_sched_clock for the default
sched_clock implementation and using the alias attribute if no board
specific implementation is given, ie:

#ifdef CONFIG_SOME_BOARD
unsigned long long sched_clock(void)
{
some_board_sched_clock();
}
#else
unsigned long long sched_clock(void)
__attribute__((alias("native_sched_clock")));
#endif

You could make it more generic by have some_board_sched_clock be a
#define (__board_sched_clock or something), so if a board defines it
(will need to be in a platform wide header) then you use that, otherwise
you use native_sched_clock.

~Ryan

--
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon Unit 5, Amuri Park
Phone: +64 3 3779127 404 Barbadoes St
Fax: +64 3 3779135 PO Box 13 889
Email: ryan@xxxxxxxxxxxxxxxx Christchurch, 8013
Web: http://www.bluewatersys.com New Zealand
Freecall Australia 1800 148 751 USA 1800 261 2934
--
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/