From patchwork Wed Aug 29 08:51:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 145404 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp423171ljw; Wed, 29 Aug 2018 01:51:55 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYrmFw3i33ZOxM/1e14iQ4VbJd7uGOLcoeDJX8iFvKkhSXl7WVVSvvK8b8EiECTa+In34PQ X-Received: by 2002:a63:f26:: with SMTP id e38-v6mr4746593pgl.354.1535532715129; Wed, 29 Aug 2018 01:51:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535532715; cv=none; d=google.com; s=arc-20160816; b=c6KXoR33rSmj7I6uZo/LtXtBntC3Ri4YuTE5ya58zOSfyQURn5IEvawc/F5YPG7yBE vknWLP47nE5Ou0in+BpOAZECXXZB+4FsGdPV70JYb0UqIAFzDw0DAtGREdwqpOpgFReN B8b8UY7EQIGSYw3h0ePdYdPLxyitbWWZbUoHJ7Tshs+3OlFF3nuUHyL1sdFROeFaOm+0 DbFLLc96bqQ6GxanOHoVQ2QmuCLBSOYQxHlQeyxoFQh/yM4xdCP7QmNIZLIa7FnP01Om ljQqq/UMgrYjNuuv15vvrpg3Cj9lUU3YfgO7ITcQwb3j1fs1vMur2a5NmLEodtJKLk1k K4xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Pgjijn2wJfRCQSPK4qbB6Q/VD+g2NrG2grPakxth6ik=; b=fifMv5d37wQwpBUAKAcj92+GYReRuIOuNFlkkw0J7Kh74gWVXqdWWpvmCmsZ7kD6kF PO6xynrPkCjmZbEOCJndxgrhf7sZ3oUVrlUUWz1ZBHFYTfSwNPe3PHAFy59F7tYNOtS6 0ylGCnso6MLBhPWjwFqlBVNbuCHo1I4KeCPme6FmsdiSCFTVhhKuucMLj+fzCcXH4trz n3s9LqIUSdfC57QJUbjtuhsD9WNQJTzOCvWXRhbPQAbJldZ7KCCpDM7Ldgoxe/0ZHIV7 RNFvTB0oLfyzJw4G1SqkaK5copbiPc42qqi3+PkTki06p28LmTXQm1rb/pbuBJSDpHRF Ht/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mi9t2oiW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j64-v6si3196174pgd.199.2018.08.29.01.51.54; Wed, 29 Aug 2018 01:51:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mi9t2oiW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727835AbeH2Mro (ORCPT + 32 others); Wed, 29 Aug 2018 08:47:44 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:37862 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727099AbeH2Mrn (ORCPT ); Wed, 29 Aug 2018 08:47:43 -0400 Received: by mail-wm0-f68.google.com with SMTP id n11-v6so4631125wmc.2 for ; Wed, 29 Aug 2018 01:51:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Pgjijn2wJfRCQSPK4qbB6Q/VD+g2NrG2grPakxth6ik=; b=Mi9t2oiWma8sxufwofWXTTEb/ZBDvdwmVBsWCAX4R6J3Nx+B/uUjO2b/8bnhjcTk6e 0BJYXPCl+4wawmyn7h0Zyn5FRgfxTY6Q5jY5AyFrVOeIBouWIDHH6KwhvLspvaxV9xkA qK2cewOm0svkwVBjxekZY3Gwh1/O8/cDgJ0Kk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Pgjijn2wJfRCQSPK4qbB6Q/VD+g2NrG2grPakxth6ik=; b=NaizvotX5tI0vgTSzFBGVYMP7rtMBeRq9YZqTklzhQkLTIolWgEusVtJNxOZo4PTXw kXzJOCE3KRT/fthnt5Rcgm/ae7aZhPMFTIMz/QL/dcV3CAkRCyWTuITnAnLDrlEkbGFI OmTwL/2R4WsBznuw9rDkwokltMn6KlV4v4X1ScXIPKOEDpa9jRqDoUsuMJW2mu1SrVkg s58wriMT9PiznFNem46UmK6dvsH3LEusy2TLzi/Z7WP8BfPiApNsBztFusKMFZOdFnSS ZoatvUNUEdWB6LZEVhwGFNDXlYi21l2Bzy/pafoDoLWgc0z5pmz260m9807cdtuuYWVo HT6w== X-Gm-Message-State: APzg51DSSXr06SWAB8OMzvOdCS2KwuT6ds6k309+yaTeN+ZbM5sTdHnK hLkI7uT1FL+L+g3dEPAdBEhQQA== X-Received: by 2002:a1c:82c8:: with SMTP id e191-v6mr3398848wmd.35.1535532711135; Wed, 29 Aug 2018 01:51:51 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:f:6020:4c23:4749:7ea6:c5af]) by smtp.gmail.com with ESMTPSA id w15-v6sm4297890wrs.8.2018.08.29.01.51.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Aug 2018 01:51:50 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, kernellwp@gmail.com Cc: Vincent Guittot Subject: [PATCH] sched/schedutil : optimize utilization scaling for guest kernel Date: Wed, 29 Aug 2018 10:51:42 +0200 Message-Id: <1535532702-3508-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Scaling the utilization of CPUs with irq util_avg in schedutil doesn't give any benefit and just waste CPU cycles when irq time is not accounted but only steal time. Add an internal _scale_irq_capacity() for scale_rt_capacity but scale cpu utilization in schedutil only if we are accounting irq time. Suggested-by: Wanpeng Li Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 2 +- kernel/sched/sched.h | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) -- 2.7.4 Signed-off-by: Vincent Guittot diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 309c93f..c1334be 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7501,7 +7501,7 @@ static unsigned long scale_rt_capacity(int cpu) free = max - used; - return scale_irq_capacity(free, irq, max); + return _scale_irq_capacity(free, irq, max); } static void update_cpu_capacity(struct sched_domain *sd, int cpu) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 4a2e8ca..1003d69 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2221,14 +2221,14 @@ static inline unsigned long cpu_util_irq(struct rq *rq) } static inline -unsigned long scale_irq_capacity(unsigned long util, unsigned long irq, unsigned long max) +unsigned long _scale_irq_capacity(unsigned long util, unsigned long irq, unsigned long max) { util *= (max - irq); util /= max; return util; - } + #else static inline unsigned long cpu_util_irq(struct rq *rq) { @@ -2236,8 +2236,26 @@ static inline unsigned long cpu_util_irq(struct rq *rq) } static inline +unsigned long _scale_irq_capacity(unsigned long util, unsigned long irq, unsigned long max) +{ + return util; +} +#endif + +/* + * scale_irq_capacity is used by schedutil to scale utilization only when + * irq time is accounted. This scaling is not necessary when only virtual time + * is accounted as guest doesn't have access to frequency scaling. + */ +#ifdef CONFIG_IRQ_TIME_ACCOUNTING + +#define scale_irq_capacity _scale_irq_capacity + +#else +static inline unsigned long scale_irq_capacity(unsigned long util, unsigned long irq, unsigned long max) { return util; } #endif +