From patchwork Wed Jan 26 16:46:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 509161 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0QGk5Qa012459 for ; Wed, 26 Jan 2011 16:46:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753499Ab1AZQpm (ORCPT ); Wed, 26 Jan 2011 11:45:42 -0500 Received: from bombadil.infradead.org ([18.85.46.34]:33285 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753235Ab1AZQpm convert rfc822-to-8bit (ORCPT ); Wed, 26 Jan 2011 11:45:42 -0500 Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1Pi8Uz-00062F-Tb; Wed, 26 Jan 2011 16:45:38 +0000 Received: from j77219.upc-j.chello.nl ([24.132.77.219] helo=laptop) by canuck.infradead.org with esmtpsa (Exim 4.72 #1 (Red Hat Linux)) id 1Pi8Uy-0002kr-Jx; Wed, 26 Jan 2011 16:45:37 +0000 Received: by laptop (Postfix, from userid 1000) id 0FD5310C43363; Wed, 26 Jan 2011 17:46:27 +0100 (CET) Subject: Re: [PATCH 16/16] KVM-GST: adjust scheduler cpu power From: Peter Zijlstra To: Glauber Costa Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, aliguori@us.ibm.com, Rik van Riel , Jeremy Fitzhardinge , Avi Kivity In-Reply-To: <1296056617.3591.26.camel@mothafucka.localdomain> References: <1295892397-11354-1-git-send-email-glommer@redhat.com> <1295892397-11354-17-git-send-email-glommer@redhat.com> <1295893920.28776.468.camel@laptop> <1295895083.15920.9.camel@mothafucka.localdomain> <1295898690.28776.472.camel@laptop> <1295985756.15920.33.camel@mothafucka.localdomain> <1295986386.28776.1101.camel@laptop> <1295988455.15920.35.camel@mothafucka.localdomain> <1295989664.28776.1124.camel@laptop> <1295990853.15920.37.camel@mothafucka.localdomain> <1296035871.28776.1132.camel@laptop> <1296056617.3591.26.camel@mothafucka.localdomain> Date: Wed, 26 Jan 2011 17:46:26 +0100 Message-ID: <1296060386.28776.1312.camel@laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 26 Jan 2011 16:46:06 +0000 (UTC) diff --git a/kernel/sched.c b/kernel/sched.c index 18d38e4..c71384c 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -523,6 +523,9 @@ struct rq { #ifdef CONFIG_IRQ_TIME_ACCOUNTING u64 prev_irq_time; #endif +#ifdef CONFIG_SCHED_PARAVIRT + u64 prev_steal_time; +#endif /* calc_load related fields */ unsigned long calc_load_update; @@ -1888,11 +1891,15 @@ void account_system_vtime(struct task_struct *curr) } EXPORT_SYMBOL_GPL(account_system_vtime); +#endif /* CONFIG_IRQ_TIME_ACCOUNTING */ + static void update_rq_clock_task(struct rq *rq, s64 delta) { - s64 irq_delta; + s64 lost_delta __maybe_unused; + s64 lost = 0; - irq_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time; +#ifdef CONFIG_IRQ_TIME_ACCOUNTING + lost_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time; /* * Since irq_time is only updated on {soft,}irq_exit, we might run into @@ -1909,26 +1916,31 @@ static void update_rq_clock_task(struct rq *rq, s64 delta) * the current rq->clock timestamp, except that would require using * atomic ops. */ - if (irq_delta > delta) - irq_delta = delta; + if (lost_delta > delta) + lost_delta = delta; - rq->prev_irq_time += irq_delta; - delta -= irq_delta; - rq->clock_task += delta; + rq->prev_irq_time += lost_delta; + lost += lost_delta; +#endif +#ifdef CONFIG_SCHED_PARAVIRT + lost_delta = virt_steal_time(cpu_of(rq)) - rq->prev_steal_time; + + /* + * unlikely, unless steal_time accounting is iffy + */ + if (lost + lost_delta > delta) + lost_delta = delta - lost; - if (irq_delta && sched_feat(NONIRQ_POWER)) - sched_rt_avg_update(rq, irq_delta); -} + rq->prev_steal_time += lost_delta; + lost += lost_delta +#endif -#else /* CONFIG_IRQ_TIME_ACCOUNTING */ + rq->clock_task += delta - lost; -static void update_rq_clock_task(struct rq *rq, s64 delta) -{ - rq->clock_task += delta; + if (lost && sched_feat(NONTASK_POWER)) + sched_rt_avg_update(rq, lost); } -#endif /* CONFIG_IRQ_TIME_ACCOUNTING */ - #include "sched_idletask.c" #include "sched_fair.c" #include "sched_rt.c" diff --git a/kernel/sched_features.h b/kernel/sched_features.h index 68e69ac..b334a2d 100644 --- a/kernel/sched_features.h +++ b/kernel/sched_features.h @@ -63,4 +63,4 @@ SCHED_FEAT(OWNER_SPIN, 1) /* * Decrement CPU power based on irq activity */ -SCHED_FEAT(NONIRQ_POWER, 1) +SCHED_FEAT(NONTASK_POWER, 1)