From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [RFC 5/8] change kernel accounting to include steal time Date: Mon, 30 Aug 2010 18:46:25 +0200 Message-ID: <1283186785.1820.1174.camel@laptop> References: <1283184391-7785-1-git-send-email-glommer@redhat.com> <1283184391-7785-2-git-send-email-glommer@redhat.com> <1283184391-7785-3-git-send-email-glommer@redhat.com> <1283184391-7785-4-git-send-email-glommer@redhat.com> <1283184391-7785-5-git-send-email-glommer@redhat.com> <1283184391-7785-6-git-send-email-glommer@redhat.com> <1283184391-7785-7-git-send-email-glommer@redhat.com> <1283184391-7785-8-git-send-email-glommer@redhat.com> <1283184391-7785-9-git-send-email-glommer@redhat.com> <1283184391-7785-10-git-send-email-glommer@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Cc: kvm@vger.kernel.org, avi@redhat.com, zamsden@redhat.com, mtosatti@redhat.com, riel@redhat.com, mingo@elte.hu, jeremy@goop.org To: Glauber Costa Return-path: Received: from casper.infradead.org ([85.118.1.10]:51007 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752147Ab0H3Qqh convert rfc822-to-8bit (ORCPT ); Mon, 30 Aug 2010 12:46:37 -0400 In-Reply-To: <1283184391-7785-10-git-send-email-glommer@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, 2010-08-30 at 12:06 -0400, Glauber Costa wrote: > This patch proposes a common steal time implementation. When no > steal time is accounted, we just add a branch to the current > accounting code, that shouldn't add much overhead. But why not use alternative code and avoid that conditional all-together? > * Account user cpu time to a process. > * @p: the process that the cpu time gets accounted to > @@ -3169,6 +3179,12 @@ void account_user_time(struct task_struct *p, cputime_t cputime, > struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; > cputime64_t tmp; > > + tmp = get_steal_time_from_hypervisor(); > + if (tmp) { > + account_steal_time(tmp); > + return; > + } > + > /* Add user time to process. */ > p->utime = cputime_add(p->utime, cputime); > p->utimescaled = cputime_add(p->utimescaled, cputime_scaled); > @@ -3234,6 +3250,12 @@ void account_system_time(struct task_struct *p, int hardirq_offset, > return; > } > > + tmp = get_steal_time_from_hypervisor(); > + if (tmp) { > + account_steal_time(tmp); > + return; > + } > + > /* Add system time to process. */ > p->stime = cputime_add(p->stime, cputime); > p->stimescaled = cputime_add(p->stimescaled, cputime_scaled); Why replicate that code and not restructure account_process_tick()?