From patchwork Fri May 25 13:12:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 136862 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3574058lji; Fri, 25 May 2018 06:13:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrc+canNM84tiqqUjL9G0Zb+mSA+YSZ7mItkaOdvOIIfihNfUr4H242h2slv7kRFJMnaurs X-Received: by 2002:a65:4ecc:: with SMTP id w12-v6mr1984678pgq.214.1527254004183; Fri, 25 May 2018 06:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527254004; cv=none; d=google.com; s=arc-20160816; b=OFG/vjzCm7EyHEeEm6tseYfRlhV/FQipmRL1ncpNZBYh5gW4gRZilkOk49SyTG8VQy 7YdOBDackT0xdX9AAKN+t6k7JF0oqAaAB7h5/XLW89AkX8S/W2NM6vulAE1+PbJggfxK OgQg0zJI/HQAqKVdPikbCLMwdQSPEiFOMRvW6PWMwWLaFXHgl4MGFJSZxq9D8YEePQMi FKMa3ApOXly8lWg67o4yPPHSY/NcCtT5yxGsV4GYOCAX+Muh5eVo9qZbB+npMUW/Xs4C wRICFfzEWtaaa21iDgfvW3WUNBE7VrZUtOa/+giQxcuaxvMjJ9S6MS64FsD5VinEKRjp ROWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=8UvYdRA45ghJOD7A8dFE8Ip7cboz8WKLsNwJhabdbVs=; b=paaDHdHdAQqgqXFkQv16wD/Sr49xdrdYWrrkqvIfeWR+yt9zsV8jk2Y3XZcGywOaLv ZqRC/SWB0m840O6LmQEIMZwPfKDUU0mw0LzHvlxPPniJzgoJ7ghtRa/9BCkhfcFyDskZ gadGmpmquxwRyCE1FhgxB7uJ+StA4GmWpCnusb/daoFMCoVD9DcfS3uYQgaCBuywdReZ zS802zzNJDxotsmCo29etWATq2CutiIlfv2S6zsDZqmZIQH1WW2d7jKs9oTOZEmN81lu gYBQHfTRaHcQtrIL3Xr9jc2xFx080lSiNO6YHa9cwnSVDZLtsiDoiGAJVqXnkXtj1UDZ 9S1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M1PJ3fOg; 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 e11-v6si17813905pgf.469.2018.05.25.06.13.20; Fri, 25 May 2018 06:13: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=M1PJ3fOg; 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 S935885AbeEYNMv (ORCPT + 30 others); Fri, 25 May 2018 09:12:51 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:50639 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752848AbeEYNMn (ORCPT ); Fri, 25 May 2018 09:12:43 -0400 Received: by mail-wm0-f68.google.com with SMTP id t11-v6so14335426wmt.0 for ; Fri, 25 May 2018 06:12:43 -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:in-reply-to:references; bh=8UvYdRA45ghJOD7A8dFE8Ip7cboz8WKLsNwJhabdbVs=; b=M1PJ3fOgL7L0gM44po+CWCoyuHSJtrSnJjMECXE94nqrh66UC5zQpL46U53olv5v2w b7njJ71lCvAnYDJjKlB0znGjqI8S7XZ7l34Q1psH7efwsJKLH6RuZjaxwOVE2JYVh+j7 5qSBbYgL+UM1o0nIAZWu+UH0KZgmdnbPik2pk= 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:in-reply-to :references; bh=8UvYdRA45ghJOD7A8dFE8Ip7cboz8WKLsNwJhabdbVs=; b=jTovmkWrs5ENUsrXd2ZHUno0n4bai4ptOl/iQXxdQvUY83WnJK2fq7AjY9rLSESHcG G9oP7R8UUQL0zj9vhOterlH3YXmH6M3oxwnMVrJ0p6qdipfSb88MyPlstUDoCfhfz86K rk85f2pIBn4RaMj0TgjQTFKMAHWO9TLI9l+3mlnzlNybX0UfgAMv3EqLeiLCxSPwMTra OjYP9a9oy45bxdOUabhZxpEnvXvcF5QjYFTKFk7UyQP36rs6N+sExNux/pYqh4Rimg8n ETGbOfEXVi3G43wHU3Ky8yIb6r43isrbW6PVTJiPliHhqnd2AtXXh8nmV1K7ZIgszAHs F/Vw== X-Gm-Message-State: ALKqPwffRvZgTmGP+0iTXxChhprCHS9fX76VE2jD/WEiR4Sc4SF5h6zQ C1EhkCCLFSZnCxL+5iGY1FZck8SjTpM= X-Received: by 2002:a1c:3449:: with SMTP id b70-v6mr1643186wma.42.1527253962692; Fri, 25 May 2018 06:12:42 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:f:6020:a860:64b4:335b:c763]) by smtp.gmail.com with ESMTPSA id 4-v6sm9690948wmg.8.2018.05.25.06.12.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 May 2018 06:12:41 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, rjw@rjwysocki.net Cc: juri.lelli@redhat.com, dietmar.eggemann@arm.com, Morten.Rasmussen@arm.com, viresh.kumar@linaro.org, valentin.schneider@arm.com, quentin.perret@arm.com, Vincent Guittot Subject: [PATCH v5 03/10] cpufreq/schedutil: add rt utilization tracking Date: Fri, 25 May 2018 15:12:24 +0200 Message-Id: <1527253951-22709-4-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527253951-22709-1-git-send-email-vincent.guittot@linaro.org> References: <1527253951-22709-1-git-send-email-vincent.guittot@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add both cfs and rt utilization when selecting an OPP for cfs tasks as rt can preempt and steal cfs's running time. Signed-off-by: Vincent Guittot --- kernel/sched/cpufreq_schedutil.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 28592b6..a84b5a5 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -56,6 +56,7 @@ struct sugov_cpu { /* The fields below are only needed when sharing a policy: */ unsigned long util_cfs; unsigned long util_dl; + unsigned long util_rt; unsigned long max; /* The field below is for single-CPU policies only: */ @@ -178,14 +179,21 @@ static void sugov_get_util(struct sugov_cpu *sg_cpu) sg_cpu->max = arch_scale_cpu_capacity(NULL, sg_cpu->cpu); sg_cpu->util_cfs = cpu_util_cfs(rq); sg_cpu->util_dl = cpu_util_dl(rq); + sg_cpu->util_rt = cpu_util_rt(rq); } static unsigned long sugov_aggregate_util(struct sugov_cpu *sg_cpu) { struct rq *rq = cpu_rq(sg_cpu->cpu); + unsigned long util; - if (rq->rt.rt_nr_running) - return sg_cpu->max; + if (rq->rt.rt_nr_running) { + util = sg_cpu->max; + } else { + util = sg_cpu->util_dl; + util += sg_cpu->util_cfs; + util += sg_cpu->util_rt; + } /* * Utilization required by DEADLINE must always be granted while, for @@ -197,7 +205,7 @@ static unsigned long sugov_aggregate_util(struct sugov_cpu *sg_cpu) * util_cfs + util_dl as requested freq. However, cpufreq is not yet * ready for such an interface. So, we only do the latter for now. */ - return min(sg_cpu->max, (sg_cpu->util_dl + sg_cpu->util_cfs)); + return min(sg_cpu->max, util); } static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, unsigned int flags)