From patchwork Thu Jul 19 12:00:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 142340 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1646257ljj; Thu, 19 Jul 2018 05:00:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfOzmWYEI5CxChA0YiJo5pHXqeiktWfAwMuE8McdJ9eKMLkOr1Re7gCClm7grbmB/sz/bva X-Received: by 2002:a17:902:d711:: with SMTP id w17-v6mr9631813ply.200.1532001624440; Thu, 19 Jul 2018 05:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532001624; cv=none; d=google.com; s=arc-20160816; b=apO9mI8Y8gsUqhcAOSmWRI7aZNALlnWaL9M+oomiPgSQ9mPM15ld+6R10hZtoWEDVa jUcXBDu5Woy3nCLfthlKI6IZ6tsXcANMi/RXLHMuzl60zPuf2vbHrHjQomscyanQZsqC jxu21b+uupwKctNF/FWBSOq8didy4VLWCObOR/1/GP1ZBl9GBK8MsfHfZhyjpk+XmmA3 W6DnkQMAr/yhAXToiJ+wY5gFYbDUI1jKlZw9mQppCBHs+A8tpC6HYw8qRQQwgSpF0KMn Tdbq2h/1/pBWDWmj8MLloGYs0KVE07uDPlo+VEUg1YmAY6U33R4dUHCkiOT7QQCoD43W QMMA== 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=vbIBHcCP7TWdjRelz80wqC2++ODtotrHkzVxAc96dQg=; b=w1XOkWr3W3CMu2Iiuz+I/LR69s7ehzhhuMd79JyiVlnaK0zvY9U0EiKTHDs/Oa75e0 RBl70er4EqISBUxUgH520aHr5ocQ5b13EnLSDvnaQ59Gpegd9saLtscahyjawFfSZ9hc Tu+gJnaEXEiuaX5ItgqlGibB+HEbkNPxg1zKZWR/wtrwvAvqaavUkdQfGRYPFtHDl09x 6+WfiiZiL5MghIla6VYA4LXzz01NKa8JYn2P3qGymfEd8Up4EUluJu/6GDsGA2/hRx5U d0FEZ36Pcvppmxq3Gl/FINlI6QtTD8U24nLvB8+8M6IhWUJa3m8chMEY3j7FxkjxLGb/ 9ayw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bA3dsgaa; 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 l63-v6si5702272pfg.326.2018.07.19.05.00.24; Thu, 19 Jul 2018 05:00:24 -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=bA3dsgaa; 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 S1730966AbeGSMnK (ORCPT + 31 others); Thu, 19 Jul 2018 08:43:10 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34050 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730451AbeGSMnK (ORCPT ); Thu, 19 Jul 2018 08:43:10 -0400 Received: by mail-wr1-f68.google.com with SMTP id c13-v6so7817253wrt.1 for ; Thu, 19 Jul 2018 05:00:20 -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=vbIBHcCP7TWdjRelz80wqC2++ODtotrHkzVxAc96dQg=; b=bA3dsgaaS3TWRxXDmdYtFzcPD1YVcPV2jW2eT+zsFcvJ+WYfRY+/2ZtOGuV/KzPem9 HlQY5ekQK2sc/FWQNHC3ov9x4RCkfjRcKkpneh4Vn5LlzGZf1nwEzghG31SFvtscXOIu ay0X1dZb1h5IHWmSVRKvCFE6Aq95FfqImiHhg= 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=vbIBHcCP7TWdjRelz80wqC2++ODtotrHkzVxAc96dQg=; b=lUcIa4QjuZ8qdhJp7K3vRylb6VqJKIQiQQvgFQuYCT+2ux2tBuDa+5xz0Aqdp4a0wP E2XfynExuHZnSSYt4Z+Xe48FkliRNVd+gnjPf0cKnnZ1mimJMXw9QUUp/mw0fOJ2oSUt bWcLNC91AbaX/IiC3ErCo6pYAaieFtWcdxmMapEZ5Ph2XX9XM6BNZp9Qr2CGvjep95A/ bLM98dd9Refuku7YKTlei9HXc0xvXDGW46K5xcrgFWWIOKeFIfsHPHEcS4gBiJ/J9oLE o9L/w7Y7McO88WiV/2cIrwfVEwGTipCX0dFnrhj2sXeK5K1SEGXasyZ2PeD+S4pJK8fc gPlA== X-Gm-Message-State: AOUpUlHmxF1UV9Lx37rW0hV0OFlnK9FoM5VP7lgJausc6374TsY3XiQT u/J5DZRc9rnNkzj9KCGF3TztZ2vUq2Q= X-Received: by 2002:a5d:5043:: with SMTP id h3-v6mr6974818wrt.186.1532001619411; Thu, 19 Jul 2018 05:00:19 -0700 (PDT) Received: from vingu-laptop.home ([2a01:cb14:8227:ec00:30f7:19b6:cda6:1ba8]) by smtp.gmail.com with ESMTPSA id f20-v6sm9882203wrh.89.2018.07.19.05.00.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jul 2018 05:00:18 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, viresh.kumar@linaro.org, Vincent Guittot Subject: [PATCH] sched/fair: remove #ifdefs from scale_rt_capacity Date: Thu, 19 Jul 2018 14:00:06 +0200 Message-Id: <1532001606-6689-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 Reuse cpu_util_irq() that has been defined for schedutil and set irq util to 0 when !CONFIG_IRQ_TIME_ACCOUNTING But the compiler is not able to optimize the sequence (at least with aarch64 GCC 7.2.1) free *= (max - irq); free /= max; when irq is fixed to 0 Add a new inline function scale_irq_capacity() that will scale utilization when irq is accounted. Reuse this funciton in schedutil which applies similar formula. Suggested-by: Ingo Molnar Signed-off-by: Vincent Guittot --- kernel/sched/cpufreq_schedutil.c | 3 +-- kernel/sched/fair.c | 13 +++---------- kernel/sched/sched.h | 20 ++++++++++++++++++-- 3 files changed, 22 insertions(+), 14 deletions(-) -- 2.7.4 Acked-by: Viresh Kumar diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 97dcd44..3fffad3 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -247,8 +247,7 @@ static unsigned long sugov_get_util(struct sugov_cpu *sg_cpu) * U' = irq + ------- * U * max */ - util *= (max - irq); - util /= max; + util = scale_irq_capacity(util, irq, max); util += irq; /* diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d5f7d52..14c3fdd 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7551,16 +7551,12 @@ static unsigned long scale_rt_capacity(int cpu) struct rq *rq = cpu_rq(cpu); unsigned long max = arch_scale_cpu_capacity(NULL, cpu); unsigned long used, free; -#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING) unsigned long irq; -#endif -#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING) - irq = READ_ONCE(rq->avg_irq.util_avg); + irq = cpu_util_irq(rq); if (unlikely(irq >= max)) return 1; -#endif used = READ_ONCE(rq->avg_rt.util_avg); used += READ_ONCE(rq->avg_dl.util_avg); @@ -7569,11 +7565,8 @@ static unsigned long scale_rt_capacity(int cpu) return 1; free = max - used; -#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING) - free *= (max - irq); - free /= max; -#endif - return free; + + 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 ebb4b3c..b80c3fd 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2210,17 +2210,33 @@ static inline unsigned long cpu_util_rt(struct rq *rq) { return READ_ONCE(rq->avg_rt.util_avg); } +#endif -#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING) +#if defined(SMP) \ + && (defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)) static inline unsigned long cpu_util_irq(struct rq *rq) { return rq->avg_irq.util_avg; } + +static inline +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) { return 0; } -#endif +static inline +unsigned long scale_irq_capacity(unsigned long util, unsigned long irq, unsigned long max) +{ + return util; +} #endif