Re: [PATCH] sched_clock: Provide local_clock() and improve documentation

From: Chad Talbott
Date: Fri May 28 2010 - 14:11:34 EST


On Fri, May 28, 2010 at 6:13 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> + * local_clock()      -- is cpu_clock() on the current cpu.

Pretty sure this should read, "is cpu_clock() on *some* cpu," since
there is no guarantee in a preemptible kernel that local_clock()
returns on the same CPU that it was called from. The caller has to do
the preempt protection itself.

The function could be written as follows (thanks Salman Qazi):

u64 local_clock(unsigned int *where)
{
u64 clock;
unsigned long flags;

local_irq_save(flags);
*where = smp_processor_id();
clock = sched_clock_cpu(*where);
local_irq_restore(flags);

return clock;
}

but I don't see the utility of the resulting routine.

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