On Wed, 27 May 2015, Andrew Morton wrote:

> > +static int try_logbuf_lock_in_nmi(void)
> > +{
> > +   u64 start_time, current_time;
> > +   int this_cpu = smp_processor_id();
> > +
> > +   /* no way if we are already locked on this CPU */
> > +   if (logbuf_cpu == this_cpu)
> > +           return 0;
> > +
> > +   /* try hard to get the lock but do not wait forever */
> > +   start_time = cpu_clock(this_cpu);
> > +   current_time = start_time;
> > +   while (current_time - start_time < TRY_LOCKBUF_LOCK_MAX_DELAY_NS) {
> > +           if (raw_spin_trylock(&logbuf_lock))
> > +                   return 1;
> > +           cpu_relax();
> > +           current_time = cpu_clock(this_cpu);
> > +   }
> 
> (Looks at the read_seqcount_retry() in
> kernel/time/sched_clock.c:sched_clock())
> 
> Running cpu_clock() in NMI context seems a generally bad idea.  

Umm, why? Requirement for it to be NMI-safe is explicitly documented. See 
the corresponding section in Documentation/timers/timekeeping.txt.

-- 
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to