Messages in this thread | | | Date | Thu, 28 May 2015 09:54:14 +0200 (CEST) | From | Jiri Kosina <> | Subject | Re: [PATCH 02/10] printk: Try harder to get logbuf_lock on NMI |
| |
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
| |