From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Date: Thu, 28 May 2009 12:59:30 +0000 Subject: Re: [PATCH] sched: Support current clocksource handling in Message-Id: <1243515570.6600.96.camel@laptop> List-Id: References: <1243348681.23657.14.camel@twins> <20090526230855.GA27218@linux-sh.org> <20090527001543.GA8493@linux-sh.org> <1243441525.28705.19.camel@desktop> <20090528091936.GA27545@linux-sh.org> <1243503281.23657.80.camel@twins> <20090528110902.GA27884@linux-sh.org> <20090528124207.GA28830@linux-sh.org> In-Reply-To: <20090528124207.GA28830@linux-sh.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Paul Mundt Cc: Thomas Gleixner , Daniel Walker , Linus Walleij , Ingo Molnar , Andrew Victor , Haavard Skinnemoen , Andrew Morton , linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.arm.linux.org.uk, John Stultz On Thu, 2009-05-28 at 21:42 +0900, Paul Mundt wrote: > unsigned long long __attribute__((weak)) sched_clock(void) > { > - return (unsigned long long)(jiffies - INITIAL_JIFFIES) > - * (NSEC_PER_SEC / HZ); > + struct clocksource *clock = ACCESS_ONCE(sched_clocksource); > + > + return cyc2ns(clock, clocksource_read(clock)); > } > > @@ -440,7 +444,17 @@ void clocksource_unregister(struct clocksource *cs) > list_del(&cs->list); > if (clocksource_override = cs) > clocksource_override = NULL; > + > next_clocksource = select_clocksource(); > + > + /* > + * If select_clocksource() fails to find another suitable > + * clocksource for sched_clocksource and we are unregistering > + * it, switch back to jiffies. > + */ > + if (sched_clocksource = cs) > + sched_clocksource = &clocksource_jiffies; > + > spin_unlock_irqrestore(&clocksource_lock, flags); > } CPU0 CPU1 clock = ACCESS_ONCE(sched_clocksource); unload module clocksource_unregister() sched_clocksource = jiffies unmap data/text cyc2ns(clock, clocksource_read(clock)) <--- fireworks