lkml.org 
[lkml]   [2020]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] sched/cputime: code cleanup in irqtime_account_process_tick
On Mon, Jan 06, 2020 at 04:53:51PM +0100, Frederic Weisbecker wrote:
> On Thu, Jan 02, 2020 at 06:07:53PM +0800, Alex Shi wrote:
> > In this func, since account_system_time() considers guest time account
> > and other system time. we could fold the account_guest_time into
> > account_system_time() to simply the code.
> >
> > Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Frederic Weisbecker <fweisbec@gmail.com>
> > Cc: Wanpeng Li <wanpeng.li@hotmail.com>
> > Cc: Anna-Maria Gleixner <anna-maria@linutronix.de>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: linux-kernel@vger.kernel.org
> > ---
> > kernel/sched/cputime.c | 9 +++------
> > 1 file changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> > index cff3e656566d..46b837e94fce 100644
> > --- a/kernel/sched/cputime.c
> > +++ b/kernel/sched/cputime.c
> > @@ -381,13 +381,10 @@ static void irqtime_account_process_tick(struct task_struct *p, int user_tick,
> > account_system_index_time(p, cputime, CPUTIME_SOFTIRQ);
> > } else if (user_tick) {
> > account_user_time(p, cputime);
> > - } else if (p == this_rq()->idle) {
> > + } else if ((p != this_rq()->idle) || (irq_count() != HARDIRQ_OFFSET))
> > + account_system_time(p, HARDIRQ_OFFSET, cputime);
> > + else
>
> I fear we can't really play the exact same game as account_process_tick() here.
> Since this is irqtime precise accounting, we have already computed the
> irqtime delta in account_other_time() (or we will at some point in the future)
> and substracted it from the ticks to account. This means that the remaining cputime
> to account has to be either utime/stime/gtime/idle-time but not interrupt time, or
> we may account interrupt time twice. And account_system_time() tries to account
> irq time, for example if we interrupt a softirq.

OK, I've dropped 2 and 3. Thanks Frederic!

\
 
 \ /
  Last update: 2020-01-07 10:13    [W:0.048 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site