From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754493AbcGFOP2 (ORCPT ); Wed, 6 Jul 2016 10:15:28 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33436 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752055AbcGFOP0 (ORCPT ); Wed, 6 Jul 2016 10:15:26 -0400 Date: Wed, 6 Jul 2016 16:15:22 +0200 From: Frederic Weisbecker To: Rik van Riel Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@kernel.org, pbonzini@redhat.com, fweisbec@redhat.com, wanpeng.li@hotmail.com, efault@gmx.de, tglx@linutronix.de, rkrcmar@redhat.com, kernel@kyup.com Subject: Re: [PATCH v3 1/4] sched,time: count actually elapsed irq & softirq time Message-ID: <20160706141518.GA12876@lerouge> References: <1467315350-3152-1-git-send-email-riel@redhat.com> <1467315350-3152-2-git-send-email-riel@redhat.com> <20160705124033.GA5332@lerouge> <20160705124707.199ba315@annuminas.surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160705124707.199ba315@annuminas.surriel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 05, 2016 at 12:47:07PM -0400, Rik van Riel wrote: > On Tue, 5 Jul 2016 14:40:34 +0200 > Frederic Weisbecker wrote: > > > ... > > Thanks for the review Frederic. Here is a fixed version of patch 1, > the other three still seem to apply cleanly. > > ---8<--- > > Subject: sched,time: count actually elapsed irq & softirq time > > Currently, if there was any irq or softirq time during 'ticks' > jiffies, the entire period will be accounted as irq or softirq > time. > > This is inaccurate if only a subset of the time was actually spent > handling irqs, and could conceivably mis-count all of the ticks during > a period as irq time, when there was some irq and some softirq time. > > This can actually happen when irqtime_account_process_tick is called > from account_idle_ticks, which can pass a larger number of ticks down > all at once. > > Fix this by changing irqtime_account_hi_update, irqtime_account_si_update, > and steal_account_process_ticks to work with cputime_t time units, and > return the amount of time spent in each mode. > > Rename steal_account_process_ticks to steal_account_process_time, to > reflect that time is now accounted in cputime_t, instead of ticks. > > Additionally, have irqtime_account_process_tick take into account how > much time was spent in each of steal, irq, and softirq time. > > The latter could help improve the accuracy of cputime > accounting when returning from idle on a NO_HZ_IDLE CPU. > > Properly accounting how much time was spent in hardirq and > softirq time will also allow the NO_HZ_FULL code to re-use > these same functions for hardirq and softirq accounting. > > Signed-off-by: Rik van Riel > --- > include/asm-generic/cputime_nsecs.h | 2 + > kernel/sched/cputime.c | 124 ++++++++++++++++++++++-------------- > 2 files changed, 79 insertions(+), 47 deletions(-) > > diff --git a/include/asm-generic/cputime_nsecs.h b/include/asm-generic/cputime_nsecs.h > index 0f1c6f315cdc..918ebb01486c 100644 > --- a/include/asm-generic/cputime_nsecs.h > +++ b/include/asm-generic/cputime_nsecs.h > @@ -50,6 +50,8 @@ typedef u64 __nocast cputime64_t; > (__force u64)(__ct) > #define nsecs_to_cputime(__nsecs) \ > (__force cputime_t)(__nsecs) > +#define nsecs_to_cputime64(__nsecs) \ > + (__force cputime_t)(__nsecs) (__force cputime64_t) :-) Although functionally that shouldn't matter for cputime_nsecs.h. You probably won't get a warning either. Reviewed-by: Frederic Weisbecker Thanks!