lkml.org 
[lkml]   [2009]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] sched: Support current clocksource handling in fallback sched_clock().
From
Date
On Thu, 2009-05-28 at 14:22 +0200, Thomas Gleixner wrote:
> On Thu, 28 May 2009, Paul Mundt wrote:
> > @@ -437,10 +441,19 @@ void clocksource_unregister(struct clocksource *cs)
> > unsigned long flags;
> >
> > spin_lock_irqsave(&clocksource_lock, flags);
> > +
> > + if (sched_clocksource == cs) {
> > + printk(KERN_WARNING "Refusing to unregister "
> > + "scheduler clocksource %s", cs->name);
>
> Hmm, isn't that dangerous ? The clocksource might be in a module or
> in kmalloced memory which is going to be freed.

One could play dirty tricks with 'leaking' module ref counts and such so
as to avoid that. The alternative is making sched_clock() look something
like:

u64 __weak sched_clock(void)
{
struct clocksource *clock;
u64 time;

rcu_read_lock();
clock = rcu_dereference(sched_clocksource);
time = cyc2ns(clock, read_clocksource(clock));
rcu_read_unlock;

return time;
}

and make the module unload do a sync_rcu -- but this might be a little
overkill



\
 
 \ /
  Last update: 2009-05-28 14:43    [W:0.087 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site