Received: by 10.213.65.68 with SMTP id h4csp2849165imn; Mon, 9 Apr 2018 10:00:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/MgiwxTWtIiz6JiC/dWlsdIxrsEqP+g5dtp3SbyohBPJ4TrwIGXgi6pOXOqoMQuJ2QUJoq X-Received: by 2002:a17:902:a60d:: with SMTP id u13-v6mr39657372plq.305.1523293234214; Mon, 09 Apr 2018 10:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523293234; cv=none; d=google.com; s=arc-20160816; b=FJd6I6l1nXSSuvMgv1mEDQWMTvzDbYNg6C1oWkXgJm6ktpr+KzLoG8trAdPcA5Ap6H rFpuwA0SOclogi/lq4KhFKDOI9sshkPKLhxNoBgR1/Kfnq1vmUrF1zwX3hIzhYv4aejh MLEjeYZWA/6F8JUgwCVc9SJgPojnNJSDMRwaQhCJSHQudz2Fx5dTEKaHI+VFOtPd2OdW wGrVkCQ6WemkKmOKsyGfBvE2+EYZA2u4taRfIFVLMGVaumxtAjK+r6Vg+rCSe6BKqRQ+ RrdRw7QPt9at3HJzpMntlYmBnqG519xYo6a39iXvq83lSAZZ6yyRtULR3NOdg0NXIQ+G ZZJA== 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:arc-authentication-results; bh=3WHlbdoY1laDx86asEh98W5X1uRxqR4EfrtOiyN4Ytg=; b=Xs4YDLMcR/gng/M0bRAi2vJs3i2BhmYDtwzFW7qz5tI+EXZs1b8eRvnpXHIYWjleKP JkBga9aH6bG6E/a9ybKl3F6XJuIRsVbqfdpIyoy2QSr4Bg87mHqWWQFsGp68c2v0fFFW 4BNnN8T/ZsQ7sV8Bzfe5BRIbR/s963jVt9Z+xImvJsJuzLVP6pkubhJB3/DuJ8TOkujP BsR9sKdGPTBHZjlapa9FVyOb3bnAXAM5Rc+bTd6MbXEjA6m7wuVNyG/Tj2jRMx7PxZ7e ovJL9Pf/d47G23uqlIzCuTG+e7Mh0QuDrcMFSRTSmGOpbeqtfBYdr9B3jEGBAEgoLCdM EZ1A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 195si463514pgd.520.2018.04.09.09.59.57; Mon, 09 Apr 2018 10:00:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753899AbeDIQ4y (ORCPT + 99 others); Mon, 9 Apr 2018 12:56:54 -0400 Received: from foss.arm.com ([217.140.101.70]:58608 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753746AbeDIQ4w (ORCPT ); Mon, 9 Apr 2018 12:56:52 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B27E81529; Mon, 9 Apr 2018 09:56:51 -0700 (PDT) Received: from e110439-lin.cambridge.arm.com (e110439-lin.cambridge.arm.com [10.1.210.68]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 387053F24A; Mon, 9 Apr 2018 09:56:49 -0700 (PDT) From: Patrick Bellasi To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Tejun Heo , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Paul Turner , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Joel Fernandes , Steve Muckle Subject: [PATCH 7/7] sched/cpufreq: uclamp: add utilization clamping for RT tasks Date: Mon, 9 Apr 2018 17:56:15 +0100 Message-Id: <20180409165615.2326-8-patrick.bellasi@arm.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180409165615.2326-1-patrick.bellasi@arm.com> References: <20180409165615.2326-1-patrick.bellasi@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently schedutil enforces a maximum frequency when RT tasks are RUNNABLE. Such a mandatory policy can be made more tunable from userspace thus allowing for example to define a max frequency which is still reasonable for the execution of a specific RT workload. This will contribute to make the RT class more friendly for power/energy sensitive use-cases. This patch extends the usage of util_{min,max} to the RT scheduling class. Whenever a task in this class is RUNNABLE, the util required is defined by the constraints of the CPU control group the task belongs to. The IO wait boost value is thus subject to clamping for RT tasks too. This is to ensure that RT tasks as well as CFS ones are always subject to the set of current utilization clampinig constraints. It's worth to notice that, by default, clamp values are min_util, max_util = (0, SCHED_CAPACITY_SCALE) and thus, RT tasks always run at the maximum OPP if not otherwise constrained by userspace. Signed-off-by: Patrick Bellasi Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Rafael J. Wysocki Cc: Viresh Kumar Cc: Joel Fernandes Cc: Juri Lelli Cc: Dietmar Eggemann Cc: Morten Rasmussen Cc: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org --- kernel/sched/cpufreq_schedutil.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index fe53984d06a0..1c80ad65065a 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -182,16 +182,21 @@ static void sugov_get_util(struct sugov_cpu *sg_cpu) static unsigned long sugov_aggregate_util(struct sugov_cpu *sg_cpu) { + unsigned long util = sg_cpu->util_dl; struct rq *rq = cpu_rq(sg_cpu->cpu); - unsigned long util; - if (rq->rt.rt_nr_running) { - util = sg_cpu->max; - } else { - util = sg_cpu->util_dl; - if (rq->cfs.h_nr_running) - util += uclamp_util(sg_cpu->cpu, sg_cpu->util_cfs); - } + /* + * RT and CFS utilization are clamped, according to the current CPU + * constrains, only when they have RUNNABLE tasks. + * Their utilization are individually clamped to ensure fairness across + * classes, meaning that CFS always get (if possible) the (minimum) + * required bandwidth on top of that required by higher priority + * classes. + */ + if (rq->rt.rt_nr_running) + util += uclamp_util(sg_cpu->cpu, sg_cpu->max); + if (rq->cfs.h_nr_running) + util += uclamp_util(sg_cpu->cpu, sg_cpu->util_cfs); /* * Ideally we would like to set util_dl as min/guaranteed freq and @@ -235,12 +240,10 @@ static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, unsigned int flags) * * Since DL tasks have a much more advanced bandwidth control, it's * safe to assume that IO boost does not apply to those tasks. - * Instead, since for RT tasks we are going to max, we don't want to - * clamp the IO boost max value. + * Instead, for CFS and RT tasks we clamp the IO boost max value + * considering the current constraints for the CPU. */ - max_boost = sg_cpu->iowait_boost_max; - if (!cpu_rq(sg_cpu->cpu)->rt.rt_nr_running) - max_boost = uclamp_util(sg_cpu->cpu, max_boost); + max_boost = uclamp_util(sg_cpu->cpu, sg_cpu->iowait_boost_max); /* Double the IO boost at each frequency increase */ sg_cpu->iowait_boost <<= 1; -- 2.15.1