public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Alex Shi <alex.shi@linux.alibaba.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Wanpeng Li <wanpeng.li@hotmail.com>,
	Anna-Maria Gleixner <anna-maria@linutronix.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] sched/cputime: code cleanup in irqtime_account_process_tick
Date: Mon, 6 Jan 2020 16:53:51 +0100	[thread overview]
Message-ID: <20200106155350.GB26097@lenoir> (raw)
In-Reply-To: <1577959674-255537-2-git-send-email-alex.shi@linux.alibaba.com>

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.

Thanks.


>  		account_idle_time(cputime);
> -	} else if (p->flags & PF_VCPU) { /* System time or guest time */
> -		account_guest_time(p, cputime);
> -	} else {
> -		account_system_index_time(p, cputime, CPUTIME_SYSTEM);
> -	}
>  }
>  
>  static void irqtime_account_idle_ticks(int ticks)
> -- 
> 1.8.3.1
> 

  reply	other threads:[~2020-01-06 15:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-02 10:07 [PATCH 1/3] sched/cputime: move rq parameter in irqtime_account_process_tick Alex Shi
2020-01-02 10:07 ` [PATCH 2/3] sched/cputime: code cleanup " Alex Shi
2020-01-06 15:53   ` Frederic Weisbecker [this message]
2020-01-07  9:13     ` Peter Zijlstra
2020-01-09 13:30       ` Alex Shi
2020-01-02 10:07 ` [PATCH 3/3] sched/cputime: cleanup account_process_tick/account_idle_ticks Alex Shi
2020-01-06 14:55 ` [PATCH 1/3] sched/cputime: move rq parameter in irqtime_account_process_tick Peter Zijlstra
2020-01-17 10:08 ` [tip: sched/core] " tip-bot2 for Alex Shi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200106155350.GB26097@lenoir \
    --to=frederic@kernel.org \
    --cc=alex.shi@linux.alibaba.com \
    --cc=anna-maria@linutronix.de \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=wanpeng.li@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox