lkml.org 
[lkml]   [2016]   [Jul]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/4] irqtime: drop local_irq_save/restore from irqtime_account_irq
On Fri, Jul 08, 2016 at 09:19:47AM -0400, Rik van Riel wrote:
> On Fri, 2016-07-08 at 14:30 +0200, Frederic Weisbecker wrote:
> > > + if (irqtype == HARDIRQ_OFFSET) {
> > > + bool leaving_hardirq = hardirq_count();
> > > + delta = sched_clock_cpu(cpu) -
> > > __this_cpu_read(hardirq_start_time);
> > > + __this_cpu_add(hardirq_start_time, delta);
> > > + if (leaving_hardirq) {
> > > + hardirq_time_write_begin();
> > > + __this_cpu_add(cpu_hardirq_time, delta);
> > > + hardirq_time_write_end();
> > > + }
> >
> > This doesn't seem to work with nesting hardirqs.
> >
> > Thanks.
>
> Where does it break?
>
> enter hardirq A -> hardirq_start_time = now
>
> enter hardirq B -> hardirq_start_time = now,
>                    account already elapsed time
>
> leave hardirq B -> account elapsed time, set
>                    hardirq_start_time = now
>
> leave hardirq A -> account elapsed time
>
> What am I missing, except a softirq-style do-while
> loop to account for hardirq A being interrupted by
> hardirq B while updating the statistics?

How about:

enter hardirq A -> delta = sched_clock_cpu(cpu) - __this_cpu_read(hardirq_start_time);
enter hardirq B -> delta = sched_clock_cpu(cpu) - __this_cpu_read(hardirq_start_time);
__this_cpu_add(hardirq_start_time, delta);
...
exit hardirq B
__this_cpu_add(hardirq_start_time, delta);

Also seqcount writers can't nest.


\
 
 \ /
  Last update: 2016-07-08 16:41    [W:2.433 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site