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; From patchwork Tue Nov 5 18:49:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 178549 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp1151385ilf; Tue, 5 Nov 2019 10:49:58 -0800 (PST) X-Google-Smtp-Source: APXvYqxX3ABhwxnT/tPjtbYFb/FJLCXzTbOFJzbbDOdpQvkBGLkVrBvP+2S/EUTQi6v2iDVqwDJW X-Received: by 2002:aa7:d0d4:: with SMTP id u20mr16175195edo.112.1572979798554; 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=UxEin9xWZINkYCpEbzn4VBz+it4TbGaUkL394PuyhRVqCPmAsXiDc+YNFE+eynmi/q h1QBztl0eegUpx70D6GC6z059YMhU3WPwKiVslmG3EXR6Uoa2sIpdu240kJegO4TsE4e WIuG0RkVaRCE7HT6qTDFXc+KhC55voM7UvRcVUBO7g7xUNeykDO9zcoi6aXhYIX5imUy eLW0UpMKpBYx1np0eTXO40oZtBu4nlbSLGF3WaXIVE+U2OnJC5guL04fdvw8AFU6RDz6 gCAIoq7bN7SKdIx0DCRcOCqZYjHGb76SEe9dZofTZTzl7m8z1thtXzLVzOzQ+lmQaE2s BWkg== 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=MuKIljDj+9SX43fxK+S80WZiAzsSjNwIox+BZEd7J9Y=; b=BRDN+gDEXmR5nqyqXKj4l01QrjPIxw9wd/Bys7tp4kRNez2oUPOLEFrtAVdt4zgDId 0ob3f+QA/mz2TFXUQ87rJLDeboJdWVPRXdeYq4cvRFK9EnrxjhQN8Tafnn6ghTYTj4Hr ASB+mB4hjIIu5DKFHpfEIsCDUci66Q44XB701AaIMdq0ZeTOWMDtHlGwAU7hQrAfXJue IcDUcad/xICopxqcIrbM8Shbep8nudvxdU+buJW2dkRVv7H6i6wsF+A+QGfxN8CUwfTp HBONAhOgLeM+BExbPePXGRqaFhikhS/28RLLMDRH43fiUxk3A2uA6/tO3EFwpbmMPkyp nUJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QdXBSTW3; 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.58; 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=QdXBSTW3; 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 S2390807AbfKEStx (ORCPT + 26 others); Tue, 5 Nov 2019 13:49:53 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:34774 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390777AbfKEStw (ORCPT ); Tue, 5 Nov 2019 13:49:52 -0500 Received: by mail-qk1-f196.google.com with SMTP id 205so20804092qkk.1 for ; Tue, 05 Nov 2019 10:49:51 -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=MuKIljDj+9SX43fxK+S80WZiAzsSjNwIox+BZEd7J9Y=; b=QdXBSTW3Kw+04AzcbpElRt6qPXZK2jBWi9b0TUpFBvqZ0jmUJOZZHqzE+mRkRFKjAB LIgnHG3qWbcnUjh3S4Fh3Lrek+Gg/zooK+jHZpo8dThwVz2dIyrHzNA3V+aIoar16Mh7 pGBz8VLs516af0LQJLcX0y2e7OqEldy7wlSMhox6c94zO8ORMNjmlSm5Yg63kmN2m/ZC WOfuCz8LtqhCnicyW7RZf3CId1Mey1UkdOOiYLXbk/TDL0ry/+X71a1a34S+g7L10xaL Hl3dVbgvaJf19263O+gF06VVYMUvmKzK/Rr2I5IFnU0AVkSdrZerFRHPaB3AHsaI36Ed nnHA== 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=MuKIljDj+9SX43fxK+S80WZiAzsSjNwIox+BZEd7J9Y=; b=MqJ9L4K/l/EvAaFajwhxaLFPv40EKxfBrm4xzvsQaFnKTcJ4Kq1t8u24PEKnBDIT4E BwsEAbImxwHC6zs/h72lY9q9CtGfXX05vf3qD4bMZ/rlPaBKdK6cF800byON3Ok7AbY6 UnuMJ6jMpBLuxzTS/bxt3J3uABIIc+XkNUOniBjj1SFeMkzon/eaCTnkfqJ2C9ZyuD0n Y2Sltt1JDyH6SsAk+caXnX3FRmVSCr6hqBDx8UkPxw1UyVf2wctc9g8Gp2MV1ESWjgy2 u81T+Srg/Ww9ADyMpmU9LFkavCh6//xa0ziQr5i6+3ctRDzcAiCxpWAPJLDU4WW5jJnH YOkw== X-Gm-Message-State: APjAAAUhFrg3k/FsV+dYrocJ8WZCNBHDWZUQtWl6sbSJz06eUEHBixjk HV2b10RuGFO7UtFoa+YZOqmshQ== X-Received: by 2002:a37:6c47:: with SMTP id h68mr12942464qkc.30.1572979790881; Tue, 05 Nov 2019 10:49:50 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Nov 2019 10:49:50 -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 2/6] sched/fair: Add infrastructure to store and update instantaneous thermal pressure Date: Tue, 5 Nov 2019 13:49:42 -0500 Message-Id: <1572979786-20361-3-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 Add interface APIs to initialize, update/average, track, accumulate and decay thermal pressure per cpu basis. A per cpu variable thermal_pressure is introduced to keep track of instantaneous per cpu thermal pressure. Thermal pressure is the delta between maximum capacity and capped capacity due to a thermal event. API trigger_thermal_pressure_average is called for periodic accumulate and decay of the thermal pressure.This API passes on the instantaneous thermal pressure of a cpu to update_thermal_load_avg to do the necessary accumulate, decay and average. API update_thermal_pressure is for the system to update the thermal pressure by providing a capped maximum capacity. Considering, trigger_thermal_pressure_average reads thermal_pressure and update_thermal_pressure writes into thermal_pressure, one can argue for some sort of locking mechanism to avoid a stale value. But considering trigger_thermal_pressure_average can be called from a system critical path like scheduler tick function, a locking mechanism is not ideal. This means that it is possible the thermal_pressure value used to calculate average thermal pressure for a cpu can be stale for upto 1 tick period. Signed-off-by: Thara Gopinath --- v3->v4: - Dropped per cpu max_capacity_info struct and instead added a per delta_capacity variable to store the delta between maximum capacity and capped capacity. The delta is now calculated when thermal pressure is updated and not every tick. - Dropped populate_max_capacity_info api as only per cpu delta capacity is stored. - Renamed update_periodic_maxcap to trigger_thermal_pressure_average and update_maxcap_capacity to update_thermal_pressure. v4->v5: - As per Peter's review comments folded thermal.c into fair.c. - As per Ionela's review comments revamped update_thermal_pressure to take maximum available capacity as input instead of maximum capped frequency ration. --- include/linux/sched.h | 9 +++++++++ kernel/sched/fair.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) -- 2.1.4 diff --git a/include/linux/sched.h b/include/linux/sched.h index 263cf08..3c31084 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1993,6 +1993,15 @@ static inline void rseq_syscall(struct pt_regs *regs) #endif +#ifdef CONFIG_SMP +void update_thermal_pressure(int cpu, unsigned long capped_capacity); +#else +static inline void +update_thermal_pressure(int cpu, unsigned long capped_capacity) +{ +} +#endif + const struct sched_avg *sched_trace_cfs_rq_avg(struct cfs_rq *cfs_rq); char *sched_trace_cfs_rq_path(struct cfs_rq *cfs_rq, char *str, int len); int sched_trace_cfs_rq_cpu(struct cfs_rq *cfs_rq); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 682a754..2e907cc 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -86,6 +86,12 @@ static unsigned int normalized_sysctl_sched_wakeup_granularity = 1000000UL; const_debug unsigned int sysctl_sched_migration_cost = 500000UL; +/* + * Per-cpu instantaneous delta between maximum capacity + * and maximum available capacity due to thermal events. + */ +static DEFINE_PER_CPU(unsigned long, thermal_pressure); + #ifdef CONFIG_SMP /* * For asym packing, by default the lower numbered CPU has higher priority. @@ -10401,6 +10407,37 @@ static unsigned int get_rr_interval_fair(struct rq *rq, struct task_struct *task return rr_interval; } +#ifdef CONFIG_SMP +/** + * update_thermal_pressure: Update thermal pressure + * @cpu: the cpu for which thermal pressure is to be updated for + * @capped_capacity: maximum capacity of the cpu after the capping + * due to thermal event. + * + * Delta between the arch_scale_cpu_capacity and capped max capacity is + * stored in per cpu thermal_pressure variable. + */ +void update_thermal_pressure(int cpu, unsigned long capped_capacity) +{ + unsigned long delta; + + delta = arch_scale_cpu_capacity(cpu) - capped_capacity; + per_cpu(thermal_pressure, cpu) = delta; +} +#endif + +/** + * trigger_thermal_pressure_average: Trigger the thermal pressure accumulate + * and average algorithm + */ +static void trigger_thermal_pressure_average(struct rq *rq) +{ +#ifdef CONFIG_SMP + update_thermal_load_avg(rq_clock_task(rq), rq, + per_cpu(thermal_pressure, cpu_of(rq))); +#endif +} + /* * All the scheduling class methods: */ From patchwork Tue Nov 5 18:49:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 178550 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp1151398ilf; Tue, 5 Nov 2019 10:49:59 -0800 (PST) X-Google-Smtp-Source: APXvYqwk55aygcQMESXqAD9r9wQrEh5L6euIdK/i5hHIwy8fRp2hNBPLsr2XBY3ev6wHW8DL3ULt X-Received: by 2002:a17:906:a40e:: with SMTP id l14mr10024684ejz.168.1572979799183; Tue, 05 Nov 2019 10:49:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572979799; cv=none; d=google.com; s=arc-20160816; b=M7VFEzKiWgJFCwPZz9M5iS8R+zby+bX3Qk64UNDwlbAEhQDIQjMQZgg+WqD8+wdJPm FUAS5ABv7DB8HzsYaSc6IgHroDJZAGlJcXPGO335j+Kumtqd6LVR6rxiqeM8a3tvplxM E8sEM9EK4zuA+z9GB5KxndDRlVH3BfD0UlkW6Gz/rbb2Q8+0ilJ0X/GrLj9EEvLAXl2h zDxpyDFCgOabtWz1DZg4MmZ2QBJxESoKUGwwwJPWCea4wHG1wYM/OA85N6RDhe+DGiw9 ND40hrTVblP2yMHJWx8A+qU6ykmaVbvL6C5+7G9Ns3RuSA/NsctztaLjkZ+e0Bh3dmD/ w+yQ== 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=006+GihIsoSJvx8BvSuuRbmJ7qmM9mq/EsT1uZpB9E8=; b=IQWzUKqn+n3ofLf05zhowCrYtaKZPuafaNXIdRoJ12aSKbwPpLkgwgRAcfmouWVfjw UpARQgt40x2sq42Xo6DhFk0s1jX+SHp2jZhSFZGiHYDdtcBtosuxHxpIP8Esz0bfducJ F/URvjhDhGk6fhyymXvLW0obVlhAzXDY0G2JhW4egQNCU1MvBt4GjhxCS7sIa7wsTKXs Tt1zfLAIqO4NKK57l0ytqZc302ttZTXARNrg2N6DY4gP7qPvtLvGt1fufpFvE3WWY1EU RlKwlY1XsKkiyeKNcuQEry3FOmIP6DpBVfrVUe28Ny7JHHg1gvpDzL07PJ2r6r9MEMie xwXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=umHITE8R; 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.58; Tue, 05 Nov 2019 10:49:59 -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=umHITE8R; 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 S2390817AbfKESty (ORCPT + 26 others); Tue, 5 Nov 2019 13:49:54 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:39611 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390804AbfKEStx (ORCPT ); Tue, 5 Nov 2019 13:49:53 -0500 Received: by mail-qk1-f195.google.com with SMTP id 15so22135530qkh.6 for ; Tue, 05 Nov 2019 10:49:52 -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=006+GihIsoSJvx8BvSuuRbmJ7qmM9mq/EsT1uZpB9E8=; b=umHITE8Rim3P3C0vmPd1bi4DZRx1zdTbqjCJvqS24wBoTsh8ON4lbclj7QoYR/LAXt v81irwxh0cnz10y3uLwQ1f59uei8i1cknodeK+rMgBjswpicXC3nz77LMLSB14C0iObr q7NBo8rxaVDqt3gi9FAeWlL8mZu2A1c19m9C3yDhNftBac5oeJNUf0Skpfg9Y0MO5iP1 f/NkI59MrPdaqfE193YlsGkC9NXaF0e7zO7YGBzhEI1UI3HqErcbcca8k2TjS9WkJRNp Osy4rOGNuTSa8CqqR0cF1OkuCJfbgYtDwS6rdcp24yQjN6W+Lx29FHqqDNJcg4Xe/crU MkhQ== 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=006+GihIsoSJvx8BvSuuRbmJ7qmM9mq/EsT1uZpB9E8=; b=scZ8O3heyI0TvstdZh+b8rLESMaG5m6YJxkZNJJalbmPnQih4XJawKt386PHU/HVNW 4ka9kBCEdOKzj7Vhz3skO4CvTegFegwf8O+oABUXuxvWGn/UmsMq476NziLUqv6n/aIL bZr08/4NuFQrZGN2263BHlIp3ueiUystTI8W+qV3BIhCFi2I8/8sKIP2fh9DTtJnVgXd MSgMR4cUGxeeiOQVsJ93Cq3fS+PWvTATd3Gs2FSqZCs8W1P9RwjFGG0dcPL9/mwjcWEQ 04nvnpLtfkM4WpwfyWnw//rWq6iSRjV3ysr1STUZ6hkEx8n9yB7Yy+DDEBhiym90GXGQ snKQ== X-Gm-Message-State: APjAAAWoWDsCb9PkjYJNSUjTbqfqa6b1W7Nt5I8x3FJT8Eor1IqPUajq I6MmNN8fJmN3ziUvH+549cVZ/g== X-Received: by 2002:ae9:e109:: with SMTP id g9mr6485852qkm.50.1572979792141; Tue, 05 Nov 2019 10:49:52 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Nov 2019 10:49:51 -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 3/6] sched/fair: Enable periodic update of average thermal pressure Date: Tue, 5 Nov 2019 13:49:43 -0500 Message-Id: <1572979786-20361-4-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 Introduce support in CFS periodic tick and other bookkeeping apis to trigger the process of computing average thermal pressure for a cpu. Also consider avg_thermal.load_avg in others_have_blocked which allows for decay of pelt signals. Signed-off-by: Thara Gopinath --- v4->v5: - Updated both versions of update_blocked_averages to trigger the process of computing average thermal pressure. - Updated others_have_blocked to considerd avg_thermal.load_avg. kernel/sched/fair.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.1.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2e907cc..9fb0494 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -92,6 +92,8 @@ const_debug unsigned int sysctl_sched_migration_cost = 500000UL; */ static DEFINE_PER_CPU(unsigned long, thermal_pressure); +static void trigger_thermal_pressure_average(struct rq *rq); + #ifdef CONFIG_SMP /* * For asym packing, by default the lower numbered CPU has higher priority. @@ -7493,6 +7495,9 @@ static inline bool others_have_blocked(struct rq *rq) if (READ_ONCE(rq->avg_dl.util_avg)) return true; + if (READ_ONCE(rq->avg_thermal.load_avg)) + return true; + #ifdef CONFIG_HAVE_SCHED_AVG_IRQ if (READ_ONCE(rq->avg_irq.util_avg)) return true; @@ -7580,6 +7585,8 @@ static void update_blocked_averages(int cpu) done = false; update_blocked_load_status(rq, !done); + + trigger_thermal_pressure_average(rq); rq_unlock_irqrestore(rq, &rf); } @@ -7646,6 +7653,7 @@ static inline void update_blocked_averages(int cpu) update_dl_rq_load_avg(rq_clock_pelt(rq), rq, curr_class == &dl_sched_class); update_irq_load_avg(rq, 0); update_blocked_load_status(rq, cfs_rq_has_blocked(cfs_rq) || others_have_blocked(rq)); + trigger_thermal_pressure_average(rq); rq_unlock_irqrestore(rq, &rf); } @@ -9939,6 +9947,8 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued) update_misfit_status(curr, rq); update_overutilized_status(task_rq(curr)); + + trigger_thermal_pressure_average(rq); } /* From patchwork Tue Nov 5 18:49:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 178551 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp1151920ilf; Tue, 5 Nov 2019 10:50:29 -0800 (PST) X-Google-Smtp-Source: APXvYqxHs/3pbYdK1N0qH8MPl6bSsgYwsUQcywzQU8xgpe0zAuUkmUwvFy0byWgeD0qSMuGMQ5tT X-Received: by 2002:a17:906:378d:: with SMTP id n13mr25294882ejc.260.1572979799629; Tue, 05 Nov 2019 10:49:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572979799; cv=none; d=google.com; s=arc-20160816; b=Ks9fe29F8rqDAg4WCg6pEwQ9eEHUQVJD4fpJ71DNYT4DFras10x1qtCK3cTIkMDCe1 0EjDe1ekhuCVDPAIkBbadP7G1QQEtISCcpkePtZ7bQNvz0FPs7YZFu/4ooGvX47btoNR wmQORpnjPwUnG3Wy6zOa/M3+qUqHoxmrkF+Q/GX9a69knjeYievGkmvCDJ/jNJE84AtQ EGeF6xgkGHSKtpuOkYXR9ulz9juxKyqRgXY6VoHO13RCtDaei0QqpJXYAL7vFgod9+JC qFDq9XA/ZbU1QYZsj2cr3e4dYtSzKPw8NdIzKDqrg9QUe/1xzQQrc+6FsExA0gTTuEXA p3Xg== 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=CdRdyYtCwsA++AMEix7betRB8SrDMfU5EHHNK7KWNOQ=; b=RyQ8XootQx8MhuQuLEdoM+zOuv+l5wjlkIot9Aqe+QKs07JMyhpddc8vAWnhmidOh4 z239v/M0gGRf1m9WwjynUGwiFfopchGVQoPGz12Q2xiDK+dwbEc9uiE79xk+77bcp8PL 6tGTf2gxcGZ/hF5aOgd2HyAHojoZLc+XKzqdv4E14scsb6y6//yvUNoKDpj3PasCQ3vm uEprvh9VEuYPonwXwZBjnct/5gEK1L8tisX3YMhwtVzFLaNJpk7F5zyKA0k+4oPvHMjv 4OlszyDiBX+Q0kfQm6MlJPwqMmwjOW60FV+3uVz8jOkv2ke2v3jBeBGMGUQZAD8byoUd wk1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fy5bE7t9; 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.59; Tue, 05 Nov 2019 10:49:59 -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=fy5bE7t9; 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 S2390829AbfKESt4 (ORCPT + 26 others); Tue, 5 Nov 2019 13:49:56 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:38411 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390813AbfKESty (ORCPT ); Tue, 5 Nov 2019 13:49:54 -0500 Received: by mail-qk1-f194.google.com with SMTP id e2so22138244qkn.5 for ; Tue, 05 Nov 2019 10:49:53 -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=CdRdyYtCwsA++AMEix7betRB8SrDMfU5EHHNK7KWNOQ=; b=fy5bE7t9ATgU8+i9GK9xokBHTF6uuDjJlM/lV6EfNTFyMxa3Uq2ybhKNeWFBvr+Wah 7FDsjBEMqE2RhsL08x7wrmIeAVYlhp9MBctEW93FbdU2hPIvL27CMWE6Q5tjq1uwUPF+ REzgCZ1kmRLRxjB/z2Bn9HHYThkP5adqWMYfnakhGXSnzfl40swpthivf3y3cp+X6jIq ffbMdRSUzIsLm0IYqCAr9aoa36mBtr9p+/lWWiLX6DjMCw6eRHcj+5dpnuDSONP2Lyhy g6aICWCCkW1otiiQ4H4DyhnCaaHsDNOwND3HfFj/gLfymWcSBrt+BYfIwmSDdzkabY8H AoNw== 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=CdRdyYtCwsA++AMEix7betRB8SrDMfU5EHHNK7KWNOQ=; b=DBBJCY78qYhUEDzd+4iTt9QMZc9re4Q42r/CJW5ppKnwKv1eEiIknI1Hl5gJAtP7lF jxHgAcJfLqg1PwFtWqsKb0Mp1+3xOnlcHl4gHlVA2ec/avqpsDF9vTQJIfi5yqrBO0sF 296U+iRL9CfhKy3D+fM36Cv1zLgpEx3vK5pPZ0qdh7AglKheZWX6dW1+absg1tdU0YgQ UJTMP6Kxi1vybxQVJb/bRo5WNCTQZPtZlsxMqKBxk8VCdTIGA9q+EH7v+YsDcnkMV2cV vBUZIG21SwxCAaTXbsz2JhxnA8jFa3qXn2vJK/x6toW7XwawKbIl95S+NZuH4V0uKonM eutw== X-Gm-Message-State: APjAAAU7SeRPmfowV2U94OQYeJ/RqhpFf52SFBdOdo0IFZgxzm5sOQxY xI+O8RD00DV4cAt5iw1TcD3tPQ== X-Received: by 2002:a37:6704:: with SMTP id b4mr22831264qkc.23.1572979793405; Tue, 05 Nov 2019 10:49:53 -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.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Nov 2019 10:49:52 -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 4/6] sched/fair: update cpu_capcity to reflect thermal pressure Date: Tue, 5 Nov 2019 13:49:44 -0500 Message-Id: <1572979786-20361-5-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 cpu_capacity relflects the maximum available capacity of a cpu. Thermal pressure on a cpu means this maximum available capacity is reduced. This patch reduces the average thermal pressure for a cpu from its maximum available capacity so that cpu_capacity reflects the actual available capacity. Other signals that are deducted from cpu_capacity to reflect the actual capacity available are rt and dl util_avg. util_avg tracks a binary signal and uses the weights 1024 and 0. Whereas thermal pressure is tracked using load_avg. load_avg uses the actual "delta" capacity as the weight. Signed-off-by: Thara Gopinath --- kernel/sched/fair.c | 1 + 1 file changed, 1 insertion(+) -- 2.1.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 9fb0494..5f6c371 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7738,6 +7738,7 @@ static unsigned long scale_rt_capacity(struct sched_domain *sd, int cpu) used = READ_ONCE(rq->avg_rt.util_avg); used += READ_ONCE(rq->avg_dl.util_avg); + used += READ_ONCE(rq->avg_thermal.load_avg); if (unlikely(used >= max)) return 1; From patchwork Tue Nov 5 18:49:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 178553 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp1151927ilf; Tue, 5 Nov 2019 10:50:30 -0800 (PST) X-Google-Smtp-Source: APXvYqxaMpgayYUs+AGW9dCYGQVqbH9ncoO/gkQH6mzOOw4NIoJYkTB+m1ykYJNuQqr6ZDbFqneq X-Received: by 2002:a17:906:c801:: with SMTP id cx1mr31481899ejb.266.1572979830202; Tue, 05 Nov 2019 10:50:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572979830; cv=none; d=google.com; s=arc-20160816; b=ujTjd65Dt3VmHGEdAEb2jxW7zaq1LFK5/VrJEG/k/5idoma0HmBWhg56kEXJxFRGhT Tk4dLXF1ziE5OhKmXp90mH7xaQDJeUjImtva5VsZ56FAy8K/F51cnvK1f3OmdfNfzRd0 ndu9vmKDCsV+VDjpcPaczZyZlpzCoFYoEALOXCr6Lip3utWAtUcBGjNZFyv6S3lxbMjj PSji64reYsFj/ChqArtHLiEFGx21Tlui5XE8aWv7XaLP9NFsU2J4Hb+Yi0md4mf4i9wj KkuJUfqIJWHpXK578wCnneo2KfC1tVXUZsy8aySpePvSXoUi4+tACxyX4UPaHuSUFL2n 2E6g== 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=CG7OyLBYjzLCAG4H5jKpLvvKWoPx2TvWNE2pLKqlhn0=; b=ue7IxdUrA8VovjYXEqDM2W4KMyPGiTPylMFBWn+LgQuVWZPrwozYC5k7BUqa/QW8ss 0MgHvi58zMCPTCdZEkynkAf+lFcSBUYw1+YIL+t5KR6gulgme8uomXzA/ikNC4lHCBhB FQX96DfRvhXimP3BbdblA7Q4TC8HG8Qh4mQHQ1RgJ6GVyxUUOd1aVtJMsw6TrZvc4zb1 FAV38vsTsq2hcYTJa9UOcax2/Uz6M0af6yPzVvSi+0W60dYpwcIxqRT0FeDvb8AB4OHt Ez1N6faJVdeg3X/VSDVZAPNK50ZijjFgodR9WSVVcvK/NnUPckVBv9FnbQxtwip0w8Cz V0lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hgKe8F71; 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.50.29; Tue, 05 Nov 2019 10:50:30 -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=hgKe8F71; 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 S2390848AbfKESuC (ORCPT + 26 others); Tue, 5 Nov 2019 13:50:02 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:44881 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390827AbfKESt4 (ORCPT ); Tue, 5 Nov 2019 13:49:56 -0500 Received: by mail-qk1-f195.google.com with SMTP id m16so21790562qki.11 for ; Tue, 05 Nov 2019 10:49:55 -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=CG7OyLBYjzLCAG4H5jKpLvvKWoPx2TvWNE2pLKqlhn0=; b=hgKe8F71HOeu6/wF3M0ARl/hvxLi5HrtK8or4YBExUXSTvdLLvtOAh05PUb8C1dedy eeuIG9u2ICb//KPinErDIy/g4ZueCX6OiIJE9VQfLO+tiZXXV7sGiu0mb96wRO/4Q1Sj +3V91qEqItS3wkCi8gVNXz5CUTK9t+yWcrUbKQ5O4/pGgVrM9gduZpaQDOThrDixS0BN CDm6npYX2Cr03ox8aqEOzpQQgt3sXiI/vdHLiC35dq2kfbR0VAP5h2kTBFPe2pr/v5CQ 9pq6Lg5B6IUu/mTfqWEsPFHY0cOWvEwDowTMrcHnmwxv3XO4frTHhJ+aIDlj0nAS6CDp hRsQ== 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=CG7OyLBYjzLCAG4H5jKpLvvKWoPx2TvWNE2pLKqlhn0=; b=nlqjBx5p7aE87LWDgLdp1NPa0ml9SoZWn7X5KnPONI6NYA+7Kk2A8Y4xhXzhraAyfu q4sCdq4b6j++FgYpGW5XZ21irvu7WR3j/3CfvxN0FZXXYwNQEYbInuhNwXNt4MSWrcLj KsbowpMCwtTe3GgJaByrS4lcWVdZtfwLsPrB43eY3McNEPs70qNLOXVxIOOkdI8+pkUA SKMsV/+mK0NGh6rpIHbC9JQ0e52Q1dUHHL7q7wr7zvylY88nVUDo9jWW8NziwSffZFWp QqOXkJajtpxyBhypWwUyCL2wn575sU59fBJjLzqqeW3AYOp5RPxwLQO1VZWakTBgX5hG bgsw== X-Gm-Message-State: APjAAAXNslJSilynUALFzwDrPBgDDkq7MvUoF3pppIFeCeJ2tBW1c8cX cXgfa+r24MS76Y48bCiKxAhxBA== X-Received: by 2002:a37:4f4e:: with SMTP id d75mr8315091qkb.490.1572979794552; Tue, 05 Nov 2019 10:49:54 -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.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Nov 2019 10:49:53 -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 5/6] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping Date: Tue, 5 Nov 2019 13:49:45 -0500 Message-Id: <1572979786-20361-6-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 Thermal governors can request for a cpu's maximum supported frequency to be capped in case of an overheat event. This in turn means that the maximum capacity available for tasks to run on the particular cpu is reduced. Delta between the original maximum capacity and capped maximum capacity is known as thermal pressure. Enable cpufreq cooling device to update the thermal pressure in event of a capped maximum frequency. Signed-off-by: Thara Gopinath --- v4->v5: - fixed issues in update_sched_max_capacity comment header. - Updated update_sched_max_capacity to calculate maximum available capacity. drivers/thermal/cpu_cooling.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 391f397..c65b7c4 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -218,6 +218,27 @@ static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_cdev, } /** + * update_sched_max_capacity - update scheduler about change in cpu + * max frequency. + * @cpus: list of cpus whose max capacity needs udating in scheduler. + * @cur_max_freq: current maximum frequency. + * @max_freq: highest possible frequency. + */ +static void update_sched_max_capacity(struct cpumask *cpus, + unsigned int cur_max_freq, + unsigned int max_freq) +{ + int cpu; + unsigned long capacity; + + for_each_cpu(cpu, cpus) { + capacity = cur_max_freq * arch_scale_cpu_capacity(cpu); + capacity /= max_freq; + update_thermal_pressure(cpu, capacity); + } +} + +/** * get_load() - get load for a cpu since last updated * @cpufreq_cdev: &struct cpufreq_cooling_device for this cpu * @cpu: cpu number @@ -320,6 +341,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; + int ret; /* Request state should be less than max_level */ if (WARN_ON(state > cpufreq_cdev->max_level)) @@ -331,8 +353,18 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, cpufreq_cdev->cpufreq_state = state; - return dev_pm_qos_update_request(&cpufreq_cdev->qos_req, - cpufreq_cdev->freq_table[state].frequency); + ret = dev_pm_qos_update_request + (&cpufreq_cdev->qos_req, + cpufreq_cdev->freq_table[state].frequency); + + if (ret > 0) { + update_sched_max_capacity + (cpufreq_cdev->policy->cpus, + cpufreq_cdev->freq_table[state].frequency, + cpufreq_cdev->policy->cpuinfo.max_freq); + } + + return ret; } /** From patchwork Tue Nov 5 18:49:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 178552 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp1151938ilf; Tue, 5 Nov 2019 10:50:31 -0800 (PST) X-Google-Smtp-Source: APXvYqxZSzkJmzpznK4665z6y1J0hkFjip4VQMpant7LeEGC7RAFzj1swn5EUwqrNgvfAJgOc1mR X-Received: by 2002:a05:6402:1850:: with SMTP id v16mr20350299edy.301.1572979830906; Tue, 05 Nov 2019 10:50:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572979830; cv=none; d=google.com; s=arc-20160816; b=UDSs0IOrdQEmE8HjRsGezbffjz5o22oJYcV7JbSDJ15hzKzOsYpQQ+ayNQONp5NJ69 D6lF1rGRf4b35upD9TiWZRaaTzGXJBLenD64sEbW2rOT/3lb/7mytr+cV3yBiwH+826u Z0U6+mKeVw2JfoTsAxG2QeBHwXCLIxcvOnbIuVd2pH+hyKnvo9Mlkd9UABUy1Z8zMAEJ FDvzkTqk7rCqYCQGfR9Xe6AoTRB8iFL/7kfUWXmqDu7Cyn95mpCDvyAEr5VydkymYOtj sagEJUje3kS29ZwY220kv9xLOH4JBhezijvaq0v2A70gF45SJni0dtd57K89OWBlB0+L N66g== 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=/uSdHlKPf1tWhKDunGI/tN+mu3wuDSTuhFonKqIHstk=; b=b9lFi5GI7cTgK1E1OPXtLhe5i3r1jDZJ7rZc1Yyu77MWVQsF4FEIDS0jClrUA4/Htb z6Ye+0i+QFSxqVEGrGRjN3siJsiV+HyYS8b8aLWAyTr9aqrfuNDdMH0OnzUV7pXwypsS 9aEx4A405+BjDHkdcgDulHmm7d2vY6KaDQPz4SnzLdGPpiYNuK4HFfH5Qp2kUp/LcvJA gfU0bRl5mj5Sh+af7hkZW0WLhBjTQiXJIggKfdj1aSdXX46nQFXsrjuEES1mjBl6slGF Dzw6pc18Esf6bwRq86W7JNbkDKaRHuld1y1t7ujaBgevrsS86wiHveVGjMrJsxeSWTPI zZ4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="zhz9Ie/3"; 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.50.30; Tue, 05 Nov 2019 10:50:30 -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="zhz9Ie/3"; 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 S2390838AbfKESuB (ORCPT + 26 others); Tue, 5 Nov 2019 13:50:01 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:34785 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390828AbfKESt5 (ORCPT ); Tue, 5 Nov 2019 13:49:57 -0500 Received: by mail-qk1-f194.google.com with SMTP id 205so20804376qkk.1 for ; Tue, 05 Nov 2019 10:49:56 -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=/uSdHlKPf1tWhKDunGI/tN+mu3wuDSTuhFonKqIHstk=; b=zhz9Ie/3qhCwSnRfeGZleXYj7TE0mY6013JOezcJuJbqNIZ0Yyz3f6AFxuKSwpCg5t ejai0aD/uweZBbIr1pAoz12BDN7NSvsiP/7Jp/JNQlaWjz08O+oxhg51H3duZT3fgTDy wXpo2ELGzDQ79mGVuX9D/S3r2q5vLiT8y8xlC1MSeZOYZr8w0E2z8701/sT15w+xjGvL 5+JNahhHmE6PI3DGPA4iqBdRZFXJHMMj1DhNkMvAI8MuUI7Pa7VkMjiJZ5T3CKxpiu06 wpJ0nz5ZG+taEnRd/Gwllc2Q4Y1R/tLmdoZBbEdYqfRP8p3fVjNHL84a8QqeD9NMTtFs uQFQ== 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=/uSdHlKPf1tWhKDunGI/tN+mu3wuDSTuhFonKqIHstk=; b=XR6jkxSkNR8Gu+DnEB+ufyqTxfVdJILcxDEL+IYV8ZQE0Vbfmk/20IAPSrPKkFC5IL 7lm2oH61YeSfAwlrEuvCAQcy7XXIFnBzNNbqUsLVQRpSl5Z2SdZ/VjGDvFOBmfCcRN8j Yg6RE8MJkW4ZZY2/4TTYgVHn0guG064H1WVYSJxqNfT51reivzWzEBjX0ihYERg0bhun VEsKsV+4gYlX3y4k2VoUawrXo1V7HGsnDLdcMv0MlO7iCkEihh4YywA5MCNhh/SU14Oh UxFZhG2t/pIskTqXad8pkPL/odYyhiJD4I+KuBKUGMYyBmkIMtVYkJoEgceluxyEGuqo SDTA== X-Gm-Message-State: APjAAAWSz0hlMI3mkovp3sNBolPHc7uRoGuTCSeuaBf5TfyohSm/L1F2 Y58TfhpqJ21TDGT+YS/aS5F/VQOuHeo= X-Received: by 2002:a05:620a:1437:: with SMTP id k23mr7967359qkj.15.1572979795875; Tue, 05 Nov 2019 10:49:55 -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.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Nov 2019 10:49:55 -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 6/6] sched/fair: Enable tuning of decay period Date: Tue, 5 Nov 2019 13:49:46 -0500 Message-Id: <1572979786-20361-7-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 Thermal pressure follows pelt signas which means the decay period for thermal pressure is the default pelt decay period. Depending on soc charecteristics and thermal activity, it might be beneficial to decay thermal pressure slower, but still in-tune with the pelt signals. One way to achieve this is to provide a command line parameter to set a decay shift parameter to an integer between 0 and 10. Signed-off-by: Thara Gopinath --- v4->v5: - Changed _coeff to _shift as per review comments on the list. Documentation/admin-guide/kernel-parameters.txt | 5 +++++ kernel/sched/fair.c | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index c82f87c..0b8f55e 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4281,6 +4281,11 @@ incurs a small amount of overhead in the scheduler but is useful for debugging and performance tuning. + sched_thermal_decay_shift= + [KNL, SMP] Set decay shift for thermal pressure signal. + Format: integer betweer 0 and 10 + Default is 0. + skew_tick= [KNL] Offset the periodic timer tick per cpu to mitigate xtime_lock contention on larger systems, and/or RCU lock contention on all systems with CONFIG_MAXSMP set. diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 5f6c371..61a020b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -91,6 +91,18 @@ const_debug unsigned int sysctl_sched_migration_cost = 500000UL; * and maximum available capacity due to thermal events. */ static DEFINE_PER_CPU(unsigned long, thermal_pressure); +/** + * By default the decay is the default pelt decay period. + * The decay shift can change the decay period in + * multiples of 32. + * Decay shift Decay period(ms) + * 0 32 + * 1 64 + * 2 128 + * 3 256 + * 4 512 + */ +static int sched_thermal_decay_shift; static void trigger_thermal_pressure_average(struct rq *rq); @@ -10435,6 +10447,15 @@ void update_thermal_pressure(int cpu, unsigned long capped_capacity) delta = arch_scale_cpu_capacity(cpu) - capped_capacity; per_cpu(thermal_pressure, cpu) = delta; } + +static int __init setup_sched_thermal_decay_shift(char *str) +{ + if (kstrtoint(str, 0, &sched_thermal_decay_shift)) + pr_warn("Unable to set scheduler thermal pressure decay shift parameter\n"); + + return 1; +} +__setup("sched_thermal_decay_shift=", setup_sched_thermal_decay_shift); #endif /** @@ -10444,8 +10465,8 @@ void update_thermal_pressure(int cpu, unsigned long capped_capacity) static void trigger_thermal_pressure_average(struct rq *rq) { #ifdef CONFIG_SMP - update_thermal_load_avg(rq_clock_task(rq), rq, - per_cpu(thermal_pressure, cpu_of(rq))); + update_thermal_load_avg(rq_clock_task(rq) >> sched_thermal_decay_shift, + rq, per_cpu(thermal_pressure, cpu_of(rq))); #endif }