From patchwork Tue Nov 5 18:49:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 178548 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp1151376ilf; Tue, 5 Nov 2019 10:49:58 -0800 (PST) X-Google-Smtp-Source: APXvYqxKDyyJ0lrXcAmp5ziimMLeIpOAbqevieABQIfF5GTpQDMXA1Kel/EVF1cG0jUtJL6TV3Eq X-Received: by 2002:a17:906:3b06:: with SMTP id g6mr8947446ejf.20.1572979798122; Tue, 05 Nov 2019 10:49:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572979798; cv=none; d=google.com; s=arc-20160816; b=FugELtIlEGUR8HbzVkPY39yhlxrwpojpg3axvbwsJVNJ1jxAciTz1cGwTJEepiIF9b HASpkKuj0UDIsJfw0SWshmIKAHBIB7hcpSBnyGLfxDoMEm4o9/wW2Tceq7wlndq8wAap QjDc29pmGCBE4Ao83d6g+WmMam1BziBumPyNudGKx9vh1SJA3WCXdZ7kSQwTmzaCEArG 84T9IqYbQ+yeY7TptvKl8hDCqKuAzLn5h+sOV1a4loFzYr2WvGhwtbxyNWkd/P8vAJur e4yqUkeCOYgryzweSxrRMNi+7bHS6gqljt8DMx7CzKGIwtpZUKp07aBqRcib72LZAT/+ amVA== 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; bh=//sItIXLl6E4Ye9AiiPOHeektXX9ZAo/gSmUR4HA0Qs=; b=YeKmmMLnqMLtusWR5GsiCiBSKdO4McGRjAf6qaiMJhI/u6hhAmYvZclTe0n5lC9Mf8 ZjV09bIXVaqbXgIVKrrWrwGWCc71DbImZ1FPFx+2JC8uPxqZndCNqjvdem7N8htyFyDQ 6ZQTjDNLEURX3+rQ6SXfSSjdDpafdjf2RQtJgt1K4lWNX7Mxo/s+WvWA+CNCShwIPXef Li4QfrtuL5FsGSm1L/KAKczxnDfHQlj74xvpc2inHpoYOFVL5BdG/eVItxAckO29IQU8 oRjLFeYAf11qHx39hhSJjgvlVpUZYLXfoffC/j4S7oVE6f6TvUfoDCQD608jOVALMyzS SQjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="T1AsK/X2"; 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 nj2si13921473ejb.233.2019.11.05.10.49.57; Tue, 05 Nov 2019 10:49:58 -0800 (PST) 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="T1AsK/X2"; 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 S2390793AbfKEStv (ORCPT + 26 others); Tue, 5 Nov 2019 13:49:51 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:38404 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390777AbfKEStu (ORCPT ); Tue, 5 Nov 2019 13:49:50 -0500 Received: by mail-qk1-f194.google.com with SMTP id e2so22138046qkn.5 for ; Tue, 05 Nov 2019 10:49:50 -0800 (PST) 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=//sItIXLl6E4Ye9AiiPOHeektXX9ZAo/gSmUR4HA0Qs=; b=T1AsK/X293UuDDf3vetvrnF+e4m4Efzz4Y69za3KWN4Xo+EIFMCKYOGIkNE5g6Rgua EVVcKVf7j0f4vptuaNqtczhCFAMrCmlx0R1llPT0pqBksrl1YlwoEVX2n+iGyPl9Ghvf ZkTCVWmV4TUSNoAGfrude0gL41pcMCB4XiwgXTTXF6AGlnfoGxGTeVj7LPaBSGPKF1gY yRdhNtGwgq8pxPuuHE5K0xgYPzb5NcsaQgGaw23ufIRRWsUHq+ip/sVJgeITS2G3SFhr 1YKM5sP2i0UMtt+uuV/ToOR0UnANnyEftFhCP7PbaDp+aqpYa7UdEheSyh8lKS6RUYbh SCeQ== 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=//sItIXLl6E4Ye9AiiPOHeektXX9ZAo/gSmUR4HA0Qs=; b=fy+lz9J20tWS331eQrZn9h2QHU5vwPFxu+u33DnKUS+jmpQXA7BPK9dGxjgVlfx4mc NooQM+XYwXoAXt12q2CkVDR2W/7c4n4wyqqTOKKJLwVrvjS9eLr/v45s03+2G8iCGpKa h61QeyVA3cQ7etRZI+6Q+AHs/1seN4uUx9yzNaCS1MbJyTrnDkNP+W8RjGg4RB2vxxRU l7dG8ufd+FKrl950P4Lp+mIsZlNrq0zhtx47gy1GkCoPwQ6l39y2ZNPnV0ZVRRrAUKCQ XPrbVKwS908PDASMiNHcOaCPo5rKkoQnHUq9r8OhYrDj7OpDwgbv/GFXiflDUW4W+X5J Ia9A== X-Gm-Message-State: APjAAAXZXOwNOigLZ0hrLIyxC4xOMtx6345Pkk83fyq43fd+h2RyEWCf oQvuXUp1g5IFhaXkXdx1ONjHVw== X-Received: by 2002:a37:4dd2:: with SMTP id a201mr8093655qkb.5.1572979789538; Tue, 05 Nov 2019 10:49:49 -0800 (PST) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.googlemail.com with ESMTPSA id j7sm6832565qkd.46.2019.11.05.10.49.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Nov 2019 10:49:48 -0800 (PST) From: Thara Gopinath To: mingo@redhat.com, peterz@infradead.org, ionela.voinescu@arm.com, vincent.guittot@linaro.org, rui.zhang@intel.com, edubezval@gmail.com, qperret@google.com Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, daniel.lezcano@linaro.org Subject: [Patch v5 1/6] sched/pelt.c: Add support to track thermal pressure Date: Tue, 5 Nov 2019 13:49:41 -0500 Message-Id: <1572979786-20361-2-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1572979786-20361-1-git-send-email-thara.gopinath@linaro.org> References: <1572979786-20361-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extrapolating on the exisiting framework to track rt/dl utilization using pelt signals, add a similar mechanism to track thermal pressure. The difference here from rt/dl utilization tracking is that, instead of tracking time spent by a cpu running a rt/dl task through util_avg, the average thermal pressure is tracked through load_avg. This is because thermal pressure signal is weighted "delta" capacity and is not binary(util_avg is binary). "delta capacity" here means delta between the actual capacity of a cpu and the decreased capacity a cpu due to a thermal event. In order to track average thermal pressure, a new sched_avg variable avg_thermal is introduced. Function update_thermal_load_avg can be called to do the periodic bookeeping (accumulate, decay and average) of the thermal pressure. Signed-off-by: Thara Gopinath --- kernel/sched/pelt.c | 13 +++++++++++++ kernel/sched/pelt.h | 7 +++++++ kernel/sched/sched.h | 1 + 3 files changed, 21 insertions(+) -- 2.1.4 Reviewed-by: Vincent Guittot diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c index a96db50..3821069 100644 --- a/kernel/sched/pelt.c +++ b/kernel/sched/pelt.c @@ -353,6 +353,19 @@ int update_dl_rq_load_avg(u64 now, struct rq *rq, int running) return 0; } +int update_thermal_load_avg(u64 now, struct rq *rq, u64 capacity) +{ + if (___update_load_sum(now, &rq->avg_thermal, + capacity, + capacity, + capacity)) { + ___update_load_avg(&rq->avg_thermal, 1, 1); + return 1; + } + + return 0; +} + #ifdef CONFIG_HAVE_SCHED_AVG_IRQ /* * irq: diff --git a/kernel/sched/pelt.h b/kernel/sched/pelt.h index afff644..c74226d 100644 --- a/kernel/sched/pelt.h +++ b/kernel/sched/pelt.h @@ -6,6 +6,7 @@ int __update_load_avg_se(u64 now, struct cfs_rq *cfs_rq, struct sched_entity *se int __update_load_avg_cfs_rq(u64 now, struct cfs_rq *cfs_rq); int update_rt_rq_load_avg(u64 now, struct rq *rq, int running); int update_dl_rq_load_avg(u64 now, struct rq *rq, int running); +int update_thermal_load_avg(u64 now, struct rq *rq, u64 capacity); #ifdef CONFIG_HAVE_SCHED_AVG_IRQ int update_irq_load_avg(struct rq *rq, u64 running); @@ -159,6 +160,12 @@ update_dl_rq_load_avg(u64 now, struct rq *rq, int running) } static inline int +update_thermal_load_avg(u64 now, struct rq *rq, u64 capacity) +{ + return 0; +} + +static inline int update_irq_load_avg(struct rq *rq, u64 running) { return 0; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 0db2c1b..d5d82c8 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -944,6 +944,7 @@ struct rq { #ifdef CONFIG_HAVE_SCHED_AVG_IRQ struct sched_avg avg_irq; #endif + struct sched_avg avg_thermal; u64 idle_stamp; u64 avg_idle;