[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.2.00.1505280952290.13817@pobox.suse.cz>
Date: Thu, 28 May 2015 09:54:14 +0200 (CEST)
From: Jiri Kosina <jkosina@...e.cz>
To: Andrew Morton <akpm@...ux-foundation.org>
cc: Petr Mladek <pmladek@...e.cz>,
Frederic Weisbecker <fweisbec@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Dave Anderson <anderson@...hat.com>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Kay Sievers <kay@...y.org>, Michal Hocko <mhocko@...e.cz>,
Jan Kara <jack@...e.cz>, linux-kernel@...r.kernel.org,
Wang Long <long.wanglong@...wei.com>, peifeiyue@...wei.com,
dzickus@...hat.com, morgan.wang@...wei.com, sasha.levin@...cle.com
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists