From patchwork Mon Oct 14 00:58:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 176103 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3886588ill; Sun, 13 Oct 2019 17:58:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqydj1emAgujyGkaD+fUvl+TvoZGZ9VHNtN3RGFTMsXN+mzKnTIDBKP1yVEw/TRA7aW+3KNN X-Received: by 2002:a50:b5e3:: with SMTP id a90mr25346822ede.201.1571014712505; Sun, 13 Oct 2019 17:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571014712; cv=none; d=google.com; s=arc-20160816; b=uFRQcimr4hkkLvN0rwfK+/E3Tz4VTc7QkUlS51qIem1YVHLI5vgi/9DTkB6CYZFjlU h3DSKHIFPIevUhTE9j4Jhd5V1yxNio0HbRIsAO4tWRl58BHE7PgI+WbW9HeOx5AkNt3u GYNM4igCEX+upKluvKcgpCzv8BTaaN+YEXDqEEaJ4M4hxTuCjzCS/zMCWYxS/paoNRsP wyqntvp+/DR1HfopnOd3HeRwZaPIoNCFU1HMHXkyHhQqM/1yVP8AmnA9SFdrJOKoASkT UamYtxF86pBQDAZ76i5pKlsveMHYbf1bByv5o/ixStrPpdFsoN0frisVUhSQZXiW5LPV WEIw== 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=C71Hj3FAfJPFhO85jZclZxmP3ymeCuJHViUF1xnpygY=; b=NJGACWReXmTFWhHbKNPLCjqylHbsKofau80cWIK79KPzSZUeujlPF+u/2LADuXFUwN tTl9p0RiV6noF9QJYJXeVHrGk16U4XT1iBq0STWVVclRiEfui2MgaHE6LODws6jFZGZh 1XLh8hHo+TwfIysEhlwNLHtun3dj4XGG6McXsh9UG3SI5ZQFuIN4RgkJcX3fRdTYpwit 3ByjzURl11Qxnfs11VHKH17YFlTkpGPVCzKuWFg96LgnTTxhaq5iMUFxInSPgnrySF3M K6c1OX6RdQvQvYSUxSc9TWL6gf2L7XLAQBgZgrHhNSxseBkD1zt1Jpy7Tg1Bwve08Z3d hlPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oaGiw5aR; 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 b56si11746068edb.418.2019.10.13.17.58.32; Sun, 13 Oct 2019 17:58:32 -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=oaGiw5aR; 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 S1729727AbfJNA6b (ORCPT + 10 others); Sun, 13 Oct 2019 20:58:31 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:38170 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729180AbfJNA6a (ORCPT ); Sun, 13 Oct 2019 20:58:30 -0400 Received: by mail-qk1-f193.google.com with SMTP id x4so10535100qkx.5 for ; Sun, 13 Oct 2019 17:58:29 -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=C71Hj3FAfJPFhO85jZclZxmP3ymeCuJHViUF1xnpygY=; b=oaGiw5aRw1A3F2kzXrr8txWWSNefUqvDNAIn8wXNSXOxnO1CCmOe/9tE3yoWerx37U dwdZmO0/ga+WVga9PPZdx/QioTC9cM05Q5BnrrFnnWPRVTcGk6VjvE1ZBX9DnHkDm403 YlJDOo3VvV2PfRQ9IurFnFzIrks1x49Hv7/4HRJVRAYR3fZAJ+rXL1UDlBOZbb5tR62o V5YiNDviL1ZVzJvPxD0RInYdQKjTFQLxSiK3eljUc6HahTasuJ1AtA/GKA6TroSK2jQB zv8vkZ5iS/sDvqDE2CJVGn8ZPpX13vXuV8Nhz81aE8eJKEj6qbagG3xi+c7AOeQLe7C2 fUKQ== 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=C71Hj3FAfJPFhO85jZclZxmP3ymeCuJHViUF1xnpygY=; b=jkkLfr4UFseN2S0fgwLuQ/FIfSeIB5KAd44hkYWa74qp8cVPwh6Luehzvf9JNyVfRE aoPqPFIRewymd8aWoKNWquy26pLJqNtlb4r8ghjwUOcMea0SbXMvYgDK9zfqmpyJ6YgB +PxIMDxb4oPa22hYyF97a3RTdi3ci2LrxEcyjIMlb37hzbgchLsR2oixDi1kAOeQqgeM TSqXmUAihs7nK1+rN5no+W0X8stQXJeqc/4ZoA59XrQL+jI08zlhaCPdHoNR+R7Y+Ybc Fe6B3W8NPsbn5ONO1S+SHvtO+9ee5v+y70O24Ztui7JFohAh3J6o0FOqoHnXV5aPXNrf YrLg== X-Gm-Message-State: APjAAAWmQGKgFZW9l40tX2M/Hwq9b/LmUN+IJtF6zmOnkn/ajK5C1JIt IEB2AZbuhUnoaj7faM551aJWjA== X-Received: by 2002:a37:a8d5:: with SMTP id r204mr27828397qke.464.1571014708568; Sun, 13 Oct 2019 17:58:28 -0700 (PDT) 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 c185sm7663901qkf.122.2019.10.13.17.58.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 Oct 2019 17:58:28 -0700 (PDT) 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 Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, daniel.lezcano@linaro.org Subject: [Patch v3 1/7] sched/pelt.c: Add support to track thermal pressure Date: Sun, 13 Oct 2019 20:58:19 -0400 Message-Id: <1571014705-19646-2-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1571014705-19646-1-git-send-email-thara.gopinath@linaro.org> References: <1571014705-19646-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 exisitng framework to track rt/dl utilization using pelt signals, add a similar mechanism to track thermal pressue. 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. In order to track average thermal pressure, a new sched_avg variable avg_thermal is introduced. Function update_thermal_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 diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c index a96db50..f06aae3 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_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..01c5436 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_avg(u64 now, struct rq *rq, u64 capacity); #ifdef CONFIG_HAVE_SCHED_AVG_IRQ int update_irq_load_avg(struct rq *rq, u64 running); @@ -175,6 +176,12 @@ update_rq_clock_pelt(struct rq *rq, s64 delta) { } static inline void update_idle_rq_clock_pelt(struct rq *rq) { } +static inline int +update_thermal_avg(u64 now, struct rq *rq, u64 capacity) +{ + return 0; +} + #endif 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 Mon Oct 14 00:58:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 176109 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3886866ill; Sun, 13 Oct 2019 17:58:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5vbdNTcJedFlkg+FHHsYF4vtiBKr/Mhak7JPbWhf2wcuiJ3DYg2ZcJ3aAgvb7FGdZv0dU X-Received: by 2002:a17:906:f847:: with SMTP id ks7mr26206144ejb.213.1571014736242; Sun, 13 Oct 2019 17:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571014736; cv=none; d=google.com; s=arc-20160816; b=QljzNz7BfcHwSceQdkqUHS+lULQU7IwUcRXGiPGd0kCtukLdedXwSwPy+tqjQRv08i uDkPvpPZMvYHCEjuYSUKfHbHwMORys9hAP5QIXpXkB0Nuu+ASDOQb1Rk8YYWH+UHioTg 4e8mieHwOzv5yjj/1UrIuixrcmWbAhKnKApgBgTgswOhsVKwGyy2v6zxQkbuK43qGOQp Q09ZT0JFTltYuQZwyk/ZxIC0bCJijBloeOexmARVC4bW+yyZP20Kb5xMKlatdNIv/5Sv GElgzeM6lTD0CTwlun11dd4Taw5LES1DveFeB9ileJHYdsMu9/y0NIC4gVKd969uF47k fivQ== 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=HXCk7WFSvFXYWs/yCn2J75WJ4FkUD1kjnWRu7u1SlbU=; b=uETOeH7K7EUJCjGggEFJLgpROYECG9J1X8GUjq+ZjOSnzOWH3tI1CzsrrLNSuS0nXO DngrYsMV/K0rDmXO4Wo0s3fe7ghsezqqETeOuRliBVkj4Q6wD945fTGeTD9aCnrTloFb VpDoRUg+ZVx0ZEfr74RcG+AqS8Zw+8GQIhANO+DZ190EslnVJBaUM3P0EFDdm2IADBdD N7RU4bsfqk5+iEDwv52ECO5aphD6FWXbCuIuxBo6zhj8xGX8Nd4QBcegAVroSeSNlnkP ry/byOCSw5Ei5YoJ2S7UuFOHhzBsRB5phgvHnQhzmsNsAqNqH7wWRCRB9qVmz9IuvJKP LTjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IfEBTd6p; 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 y10si10043433ejw.76.2019.10.13.17.58.56; Sun, 13 Oct 2019 17:58:56 -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=IfEBTd6p; 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 S1729840AbfJNA6w (ORCPT + 10 others); Sun, 13 Oct 2019 20:58:52 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:35156 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729714AbfJNA6b (ORCPT ); Sun, 13 Oct 2019 20:58:31 -0400 Received: by mail-qk1-f196.google.com with SMTP id w2so14483585qkf.2 for ; Sun, 13 Oct 2019 17:58:30 -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=HXCk7WFSvFXYWs/yCn2J75WJ4FkUD1kjnWRu7u1SlbU=; b=IfEBTd6pxtYseUl5ivLDlRrw2pUdcU14DsbG/j4fNMOQ7tnNYxM6AGyj/63cnSz+P8 3S5iRysN1BOvSLTH+0xS8ZnI0qfeQtGfrvsxnCSuU+nmXtDv+4i9RZxwJ9yVV8sNmqF4 bAsqXta4BvcufRImA76CJwCaN8P24CCjCgftvx3+avEFRPeq86WOhoj+DY0xznixF4aK +C669lUh5fqWkx243UocpT5Tgqx6MUp9+P5oSApv67EnQUQ89NiN6WaEvU0emeyguVof DW9zfIswCPmOogOCbfxZ04O0y0iMfYFkTc224qRJtCq5VmoUY8aheoEDFOiZu+vwyJC+ K1Hw== 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=HXCk7WFSvFXYWs/yCn2J75WJ4FkUD1kjnWRu7u1SlbU=; b=RtSfqHRdcy24uPgT5kMSCRqAkEEgwSfGU0AKfBTzvZqhz6EcTyUGUMS4x60slw8IcH lvg9VxE0bNUtB7NWH63FLFqnKNGIxRMXbioQifNi0n+Bg/RaV6zdInXR383b95UclCsx ARah1ROgdfCYsc+C9Bb5Ub6Bfb1cQEm7NQ/Aef+E0FVAtxT+UWyUCB0Uyk/dd7NgE2Ja +CtEFWL6POaPXKsv1kojWRgumd1OCmkbST8eCWchssVsWK7UXoeQerjCHguAYPypk+x1 0g+7f8dUnSPf/B6TJ0ccaZV19g5KG4nxira/HaN9Sbmduzk7TXdTcxOJDUZO2xssgP7X YIag== X-Gm-Message-State: APjAAAXuZhjajSM01Hh9Mimau3KZr1e+pyroAuG5g+xsmCiHnvAeu+/a SUO9HxMslSQLq1/7P1TJIBWUYw== X-Received: by 2002:a37:4dca:: with SMTP id a193mr27620584qkb.292.1571014710026; Sun, 13 Oct 2019 17:58:30 -0700 (PDT) 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 c185sm7663901qkf.122.2019.10.13.17.58.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 Oct 2019 17:58:29 -0700 (PDT) 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 Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, daniel.lezcano@linaro.org Subject: [Patch v3 2/7] sched: Add infrastructure to store and update instantaneous thermal pressure Date: Sun, 13 Oct 2019 20:58:20 -0400 Message-Id: <1571014705-19646-3-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1571014705-19646-1-git-send-email-thara.gopinath@linaro.org> References: <1571014705-19646-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 thermal.c and thermal.h files that provides interface APIs to initialize, update/average, track, accumulate and decay thermal pressure per cpu basis. A per cpu structure max_capacity_info is introduced to keep track of instantaneous per cpu thermal pressure. Thermal pressure is the delta between max_capacity and cap_capacity. API update_periodic_maxcap is called for periodic accumulate and decay of the thermal pressure. It is to to be called from a periodic tick function. This API calculates the delta between max_capacity and cap_capacity and passes on the delta to update_thermal_avg to do the necessary accumulate, decay and average. API update_maxcap_capacity is for the system to update the thermal pressure by updating cap_capacity. Considering, update_periodic_maxcap reads cap_capacity and update_maxcap_capacity writes into cap_capacity, one can argue for some sort of locking mechanism to avoid a stale value. But considering update_periodic_maxcap 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 value used to calculate average thermal pressure for a cpu can be stale for upto 1 tick period. Signed-off-by: Thara Gopinath --- include/linux/sched.h | 14 +++++++++++ kernel/sched/Makefile | 2 +- kernel/sched/thermal.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ kernel/sched/thermal.h | 13 ++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 kernel/sched/thermal.c create mode 100644 kernel/sched/thermal.h -- 2.1.4 diff --git a/include/linux/sched.h b/include/linux/sched.h index 2c2e56b..875ce2b 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1983,6 +1983,20 @@ static inline void rseq_syscall(struct pt_regs *regs) #endif +#ifdef CONFIG_SMP +void update_maxcap_capacity(int cpu, u64 capacity); + +void populate_max_capacity_info(void); +#else +static inline void update_maxcap_capacity(int cpu, u64 capacity) +{ +} + +static inline void populate_max_capacity_info(void) +{ +} +#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/Makefile b/kernel/sched/Makefile index 21fb5a5..4d3b820 100644 --- a/kernel/sched/Makefile +++ b/kernel/sched/Makefile @@ -20,7 +20,7 @@ obj-y += core.o loadavg.o clock.o cputime.o obj-y += idle.o fair.o rt.o deadline.o obj-y += wait.o wait_bit.o swait.o completion.o -obj-$(CONFIG_SMP) += cpupri.o cpudeadline.o topology.o stop_task.o pelt.o +obj-$(CONFIG_SMP) += cpupri.o cpudeadline.o topology.o stop_task.o pelt.o thermal.o obj-$(CONFIG_SCHED_AUTOGROUP) += autogroup.o obj-$(CONFIG_SCHEDSTATS) += stats.o obj-$(CONFIG_SCHED_DEBUG) += debug.o diff --git a/kernel/sched/thermal.c b/kernel/sched/thermal.c new file mode 100644 index 0000000..5f0b2d4 --- /dev/null +++ b/kernel/sched/thermal.c @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Sceduler Thermal Interactions + * + * Copyright (C) 2018 Linaro, Inc., Thara Gopinath + */ + +#include +#include "sched.h" +#include "pelt.h" +#include "thermal.h" + +struct max_capacity_info { + unsigned long max_capacity; + unsigned long cap_capacity; +}; + +static DEFINE_PER_CPU(struct max_capacity_info, max_cap); + +void update_maxcap_capacity(int cpu, u64 capacity) +{ + struct max_capacity_info *__max_cap; + unsigned long __capacity; + + __max_cap = (&per_cpu(max_cap, cpu)); + if (!__max_cap) { + pr_err("no max_capacity_info structure for cpu %d\n", cpu); + return; + } + + /* Normalize the capacity */ + __capacity = (capacity * arch_scale_cpu_capacity(cpu)) >> + SCHED_CAPACITY_SHIFT; + pr_debug("updating cpu%d capped capacity from %lu to %lu\n", cpu, __max_cap->cap_capacity, __capacity); + + __max_cap->cap_capacity = __capacity; +} + +void populate_max_capacity_info(void) +{ + struct max_capacity_info *__max_cap; + u64 capacity; + int cpu; + + for_each_possible_cpu(cpu) { + __max_cap = (&per_cpu(max_cap, cpu)); + if (!__max_cap) + continue; + capacity = arch_scale_cpu_capacity(cpu); + __max_cap->max_capacity = capacity; + __max_cap->cap_capacity = capacity; + pr_debug("cpu %d max capacity set to %ld\n", cpu, __max_cap->max_capacity); + } +} + +void update_periodic_maxcap(struct rq *rq) +{ + struct max_capacity_info *__max_cap = (&per_cpu(max_cap, cpu_of(rq))); + unsigned long delta; + + if (!__max_cap) + return; + + delta = __max_cap->max_capacity - __max_cap->cap_capacity; + update_thermal_avg(rq_clock_task(rq), rq, delta); +} diff --git a/kernel/sched/thermal.h b/kernel/sched/thermal.h new file mode 100644 index 0000000..5657cb4 --- /dev/null +++ b/kernel/sched/thermal.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Scheduler thermal interaction internal methods. + */ + +#ifdef CONFIG_SMP +void update_periodic_maxcap(struct rq *rq); + +#else +static inline void update_periodic_maxcap(struct rq *rq) +{ +} +#endif From patchwork Mon Oct 14 00:58:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 176104 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3886614ill; Sun, 13 Oct 2019 17:58:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxxrVtP/g9YYRzc/EQ04ZcyyXN7YdCQZKmFhislzcsFtrdsx0rOZKBikLzRxz1C6lotXOt X-Received: by 2002:a50:bac2:: with SMTP id x60mr25724645ede.96.1571014714407; Sun, 13 Oct 2019 17:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571014714; cv=none; d=google.com; s=arc-20160816; b=wyzE8FH+hqXK/WTA4HcEOOzieesOo0UqOFdzM9W7FkIp2FApjNu2CIJ0mSw60X94to qI+CL+qAxV+fUELtYmxy/qTq+eBYU7KTBTT+ULCZF8YB85MVcxz+UMcPfb0Z8gbfiWO5 +7AUoZUfDgNkpiwXv9qG5l7lak7aijeJqvzXDg8wnunOI1jwNhtN1YCcRRNwLNlzEj6b gAMd/M0E85T5UAVkhYv18aWL8EfGGKlj0jkYhHQ4j+2c1bVit/5VNnBsFY/pueoSBrts ohWj6vfN21Dzv7tEQM/R2ZNtfPFxci+KDe86d77sFM28mf3uwtmzCP/KDIK5gWaErnGo SVvg== 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=v7XQBgeFPFA2xqVRlaqSBquWqwtCCnMp9HH9en37v0E=; b=J6FDD18nEuuT327EybW0nLtMZAjCHkBVorFtGMM7UdD1US0S3P/dVbfharCSsjvpVq cq1RwXFKlIodlUAhbrnCjpRxmex0xu8OKVipH+DVTxnsTvtENRb2BIshdr3FDbABtKhb 5xxstA0q/xE+QZKuY83f9meSFaAK2hygnmLsXKVfUBed5Ic5GYKmWZZQ0CQ2tAp9O+oD E6tV+cTCHT+t0KsBtj5tSkLcrdAdausrDJSIAsyrPjCRXZEXFe0Sr1mS96/NAKqsrEC9 m1oSxOKsxL5zWmDV6GMr5LVD4skvmZ1hEutpsT1NPB4mdjw8BxM1Py1vpbafjyb4tNJa X4Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QlmjQZ7H; 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 b56si11746068edb.418.2019.10.13.17.58.34; Sun, 13 Oct 2019 17:58: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; dkim=pass header.i=@linaro.org header.s=google header.b=QlmjQZ7H; 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 S1729746AbfJNA6d (ORCPT + 10 others); Sun, 13 Oct 2019 20:58:33 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:41867 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729180AbfJNA6c (ORCPT ); Sun, 13 Oct 2019 20:58:32 -0400 Received: by mail-qt1-f196.google.com with SMTP id v52so23099312qtb.8 for ; Sun, 13 Oct 2019 17:58:31 -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=v7XQBgeFPFA2xqVRlaqSBquWqwtCCnMp9HH9en37v0E=; b=QlmjQZ7HKxGaLUk/fj8Q3XI/TMgE8Zspiynbr6H7molbqqHaYYCH21ecEeCaCxfygE iQv3D8Ihn2Sq+RlbtVsVSfCBAr+2o3sphD1etCCJifKLgXOczG1SaIp5+70IpI5FMOuT L3IPZvzh2J+qBbBTFLno5LYJ+leaaDJrUyNo8z06ztncQQRE1ps0d9kNAtAtYMvQS6zk hYaodwXye+WFFbR93obrGVMLMahq42tdXNK+TNtku3wDREgEkNVKZTPqrukiqsKn0YBa 0fNwvUocRA292ROuxoGwP68cR0694Nwn6XFwjiVB5fPg8GKCXz86McnHYNH1SMiUqj/H UBNg== 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=v7XQBgeFPFA2xqVRlaqSBquWqwtCCnMp9HH9en37v0E=; b=nS00n9YXcyf8nWzKfUd5VnihKQcRoTCJInOHsbbPKY5tPcISVuSSOHStSFzlLFR8nx ecfjwJU60rXfYvAhAuZc5UpSPv5VOzc3uG34yQSXTuCO2UNa9F36Ieq06vN2pqyYcYzK JpY/i0x1LKu3wvQ5jniDx2oGG+jlvCVpYzEvQLfiA22DZf0IfF1J0KCePXkUgjR1Qeld 2HzD/CVnQjWFaxc+NDCtYSDNJtgfgBowd/Irt/pLfNz9PLVgRfCD4+OcIRuZiA5QS/Cx Xte8/o+/O+0OoFpWo6phuVC8Cc3EjSQyED5aYh+pFYGjyedgruywX0ZV1XAMVQwPQP4u T05A== X-Gm-Message-State: APjAAAVmiurjEZlsc1e/9n59CDXM06EJWRyK7KPN6M93w4D1E2O9ah6O mOK/zhaWnwOzzxQ25S+fn9mF8g== X-Received: by 2002:ac8:7447:: with SMTP id h7mr30179050qtr.11.1571014711319; Sun, 13 Oct 2019 17:58:31 -0700 (PDT) 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 c185sm7663901qkf.122.2019.10.13.17.58.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 Oct 2019 17:58:30 -0700 (PDT) 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 Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, daniel.lezcano@linaro.org Subject: [Patch v3 3/7] sched: Initialize per cpu thermal pressure structure Date: Sun, 13 Oct 2019 20:58:21 -0400 Message-Id: <1571014705-19646-4-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1571014705-19646-1-git-send-email-thara.gopinath@linaro.org> References: <1571014705-19646-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 Initialize per cpu max_capacity_info during scheduler init. Signed-off-by: Thara Gopinath --- drivers/base/arch_topology.c | 1 + kernel/sched/core.c | 2 ++ 2 files changed, 3 insertions(+) -- 2.1.4 diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 1eb81f11..7ac9f2f 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -123,6 +123,7 @@ void topology_normalize_cpu_scale(void) pr_debug("cpu_capacity: CPU%d cpu_capacity=%lu\n", cpu, topology_get_cpu_scale(cpu)); } + populate_max_capacity_info(); } bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 7880f4f..744f026 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6534,6 +6534,8 @@ void __init sched_init_smp(void) init_sched_rt_class(); init_sched_dl_class(); + populate_max_capacity_info(); + sched_smp_initialized = true; } From patchwork Mon Oct 14 00:58:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 176105 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3886641ill; Sun, 13 Oct 2019 17:58:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRiBv4v7wI7AsyLmCLqPU1f6g82LLLyosyBAe6N8W4J76Slw1XZhit/yqNaogqlSH4RMr1 X-Received: by 2002:a17:906:3582:: with SMTP id o2mr3927333ejb.54.1571014716219; Sun, 13 Oct 2019 17:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571014716; cv=none; d=google.com; s=arc-20160816; b=fMfTZv2cjGsyVNQjBUew6Kk9xHBVf8kpXfszJGa5LtLv6iufyD1uSOgMNF1+lxcgU5 ngtL2kVh4CRZHQIW0h3C7uC9VCvYk4FyiJf2v8W8c8zxO3P1CDCM7G9irkvZwZos8YkM G/ex91KKZyoP2w4Sl2HGEuOXmJ8YHIZZZF6aknf0GRWRN76QVdZZnfZGZOcOkHV7avSn uDaqcrByQRR/01nzXfDU7Q0ADSFDAD+HkgGFjs2094KGJ8wkYqiXV15/2Oo8xsqZ836t eEg2baKfoCT4EjvHnCLzt1VMFrGu2Q4v6bQ8QpcW5uY75PccZ5k9swPX3ZpeJxPKLV0A WFZA== 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=wKxSPMl7EPM6ok8Zx7OEY5cb3mUO9ZZjqXNAqG0TCKE=; b=fo+yJkkF0SVr4GLV/JbQ5U5xjogxqg+ojDwNtVAM64RwSJ1TNV/o+qIhfSaDdGfVYj j0rpPg0hSo8ijk8z8T2cHE3IAobAoBqPlzw+ln7PVx/2UPfvoDB6W4UVL1ZOSiUhECGg vlgMWJJ0XplkuR3rFcpe4h2WPTDoJquXWxm4V6jPb1H2h9pYkWDyLhKnWubXfbTUw89b N5Ch93Sa4tmAa3Hp1hIXoWtiojUHOnG1/j4kjiDZjCUqezo8yFbO7OT+B2TjvjOm0xbl tewLRv51yx5l+PCWETm3t+s3W2T/Vw3ngpQJqRHjmRjJP96e0k+SdWxgga95FBxjGDLY 8SBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UZR7YFFW; 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 b56si11746068edb.418.2019.10.13.17.58.36; Sun, 13 Oct 2019 17:58:36 -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=UZR7YFFW; 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 S1729763AbfJNA6f (ORCPT + 10 others); Sun, 13 Oct 2019 20:58:35 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:42757 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729737AbfJNA6d (ORCPT ); Sun, 13 Oct 2019 20:58:33 -0400 Received: by mail-qk1-f196.google.com with SMTP id f16so14444226qkl.9 for ; Sun, 13 Oct 2019 17:58:33 -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=wKxSPMl7EPM6ok8Zx7OEY5cb3mUO9ZZjqXNAqG0TCKE=; b=UZR7YFFWzMKcXxJ9dqs7MxnGNzG8a7Oahd6jRqFl17qBcCT2ZZTsf+ArewfUbYNN+w Ie8AcxY33Y6pyzpr/3teLmy1IwRmU7b0QhxBlBYeo9FkFGYVz8h8y1wOlMNtR3eiV+1n vDDQAAfmtw6It/CQwfDk/a7jXhEmgp3zCroGxG4kG3abDt+C67s+xYPDcAh+895sxAyE L3oG7HBa4PHAEqOvkm9oaysZ4yty+HdaN/tt9fy7iBthAPqEJwqyuuCVotRANKOGRYlv kB8pXhZfN5NWRpQ7hyyiMivjBtviVDArOVvvwojB6OQrJ57+co6nbh9wnGh9OjsD2EUG lCjg== 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=wKxSPMl7EPM6ok8Zx7OEY5cb3mUO9ZZjqXNAqG0TCKE=; b=izSqWoTALjHowtHc15XrWoQ/Ih4ewwzi0VrtaFavG2D2soh9LM4WBuumgrU0QXOtsN bW1JzQ9nJRhmSsG3bcR5WWOMGhupOy24zBivDklICWOcoFuKke3SiuYU+LPC5ef7ZTBm ZuNHPsvoQjhMJJF/wSIXgH0ZNvNOGOkqdFWlVq6naJWESfQnsbnDMutE6BUgPT0g1Hw5 aLtgofSeZ7hZx4EQNA16dC9OxTeJZoGhKiLXgQYhQnGid8kG/m+v8Py3ONkRn4vi/Isg D3KElhji/atRPygOTw7tQscn0NNF4Gvtj5hFvWnaJpISJ6FV8nuOc968tF8txRTVs737 RdXA== X-Gm-Message-State: APjAAAWFVILKG4NxAiNmyVlNA/+qRbUO+RGZ7CHiV2jIL0uqs/aN6+GB 6T+VRhAZ2CEhTrUL4nSJM+tezg== X-Received: by 2002:a05:620a:696:: with SMTP id f22mr27017261qkh.91.1571014712537; Sun, 13 Oct 2019 17:58:32 -0700 (PDT) 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 c185sm7663901qkf.122.2019.10.13.17.58.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 Oct 2019 17:58:31 -0700 (PDT) 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 Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, daniel.lezcano@linaro.org Subject: [Patch v3 4/7] sched/fair: Enable CFS periodic tick to update thermal pressure Date: Sun, 13 Oct 2019 20:58:22 -0400 Message-Id: <1571014705-19646-5-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1571014705-19646-1-git-send-email-thara.gopinath@linaro.org> References: <1571014705-19646-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 to trigger the process of computing average thermal pressure for a cpu. Signed-off-by: Thara Gopinath --- kernel/sched/fair.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.1.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 83ab35e..fe7c165 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -21,6 +21,7 @@ * Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra */ #include "sched.h" +#include "thermal.h" #include @@ -7566,6 +7567,8 @@ static void update_blocked_averages(int cpu) done = false; update_blocked_load_status(rq, !done); + + update_periodic_maxcap(rq); rq_unlock_irqrestore(rq, &rf); } @@ -9925,6 +9928,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)); + + update_periodic_maxcap(rq); } /* From patchwork Mon Oct 14 00:58:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 176106 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3886708ill; Sun, 13 Oct 2019 17:58:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjw+WAUtJ2sO7Cm7q6pMJeJC/TlYW08CAQYZKO6AHkE0KYTBnxAixNl2+ebB9VV9XGNSqZ X-Received: by 2002:a17:906:2584:: with SMTP id m4mr16982860ejb.287.1571014721087; Sun, 13 Oct 2019 17:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571014721; cv=none; d=google.com; s=arc-20160816; b=bVeleRrhatterSkTTRlIO3RtBfgUHU3+sv91to1sxUd68yKjPzgg/lJb+ikY0jgaqa OLGLJDM8/OrPCp/lD25TPmj8Dmpv1qkxHo2RHj7BqaaNjA9EWfGVLXKChiR0UcDSv+BT GgWuuZdgUOvVZhI21t49M2kAU8SbaKH7HG/xB0mDDA9/hiGdUulFk4i0oIq3wAHakWQt Egjxf21XpH21DIpfuFFFUUCkUADh1svXEpqOYeHcWchQxM0BfpxXt7SoYmYd9UkT4k3I B0NZkmvYAaFgWp8Os8+C15yI+INseu+eKuMyFgjIBbI4ivRtwLZnsf6s+94NEz2LCNaa k0Qg== 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=O3q+7yGZl2chLLPUpezQ1APj0BawGHMOVtLNFWKxjdQ=; b=MbNKOsx7niBpoHNjJUTZcKSbHczZBkhB+bQOfdAoLOYMnsYZHvO2Es2F3uK4nZ0oCY RBl8u+xlEwraNEwPs+c+QVyDH/50X9Sa544JtETlFN/9JppkYRzpr0HjJLw5KNfrCx/y rWR6jn0W9bsByWZnM7tRLcylgw3D/MW9ODJg2hq83eyVT9nlkgiYQUyvgpDYwVf4DcIs Qfw9V6GzyTJnlifTTJrl2Tws3NRTXfAk7KVD8sMz2s0gGZkQbdXKWIqNE0QWRaXySRQ9 3dU/Lyj7fLJpa71EbMMp+lgsMYYkCRTfpBH/kD3nvRGO1yK7V32ercCx16Y/UkHGw2CO VjIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="sGu/fE49"; 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 bt13si10192289edb.245.2019.10.13.17.58.40; Sun, 13 Oct 2019 17:58:41 -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="sGu/fE49"; 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 S1729779AbfJNA6g (ORCPT + 10 others); Sun, 13 Oct 2019 20:58:36 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:41868 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729755AbfJNA6e (ORCPT ); Sun, 13 Oct 2019 20:58:34 -0400 Received: by mail-qt1-f194.google.com with SMTP id v52so23099416qtb.8 for ; Sun, 13 Oct 2019 17:58:34 -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=O3q+7yGZl2chLLPUpezQ1APj0BawGHMOVtLNFWKxjdQ=; b=sGu/fE49gKyoicIdmc+SvTZvUPm5tvfqbr3kTEypxNdupK5o9nrTkoCNKbZyyfDYKD 7zCSi1Wncjkk90GTtZRvVJWyV2+hHS/r5WCpRoJNKoZhvrBDQlJ392xhw6+Tt4ihP/t+ i4lILG6nsR9FUK1Pa9QN08bT5xX0ZQJPdWv8MEgNFHqu3W/f4Sky0M6hHjPgtCFqVfOt GjtK1h3myOd09NZJGMABRoqhG+0xs0EbeuEUrbpsQ1HwdoZK5ngky8FPVzu/9smWxKPo vzghjqJW0GQtgr3InovmLxEzj/PKZrRkra84LnlHq5QIT6xtciefugtgcoO373q0QFKh 0k/g== 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=O3q+7yGZl2chLLPUpezQ1APj0BawGHMOVtLNFWKxjdQ=; b=n+xtsdJoAnw39OYiKZE59/wGJmHoxtH9KXdYAwG8b1Iea71dkravcaGfuhH19AIMyJ GlnXw9t0zVJvV7dBjUXfQ+nD0r7sXdf9Lg5D5T37CHPv9qOwMnCj2WVNCaQmxbyv6d2E DpZ1+CMOhFNhyoPgLSgf7eJiKTuUwtxHJ9NT7xXtvsw7+NqgeOFukuXciHFScrK5a+6J ftxVfoFqCy7/4E6g3SSDMLHrTFDZ2sYG3wyfhSsW3sst+UPHLv3prIV4QqasogFpHc1v XxghnBMRdOy/3tBPpnwupRs9EDVYO78qt68oK6mznm9bdIfn/n5AGuT1K5ilvss8RgHH qwqA== X-Gm-Message-State: APjAAAVC/OrDUl4+cqbY7hH8ui+W31ydKKPE4RflCaGVQikqF0IXyyax 4sLiY8+SCjow2BE3NIXx5ireFw== X-Received: by 2002:ac8:740b:: with SMTP id p11mr29727737qtq.71.1571014713876; Sun, 13 Oct 2019 17:58:33 -0700 (PDT) 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 c185sm7663901qkf.122.2019.10.13.17.58.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 Oct 2019 17:58:33 -0700 (PDT) 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 Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, daniel.lezcano@linaro.org Subject: [Patch v3 5/7] sched/fair: update cpu_capcity to reflect thermal pressure Date: Sun, 13 Oct 2019 20:58:23 -0400 Message-Id: <1571014705-19646-6-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1571014705-19646-1-git-send-email-thara.gopinath@linaro.org> References: <1571014705-19646-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. 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 fe7c165..cbc2208 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7719,6 +7719,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 Mon Oct 14 00:58:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 176107 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3886713ill; Sun, 13 Oct 2019 17:58:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxidhoX8TzDL0JDhsdUqyKWU8XOObGgya26LfIGY1HZLoVuLHywlIIUod41W/TTBjbcfY16 X-Received: by 2002:a05:6402:154e:: with SMTP id p14mr5168687edx.274.1571014721760; Sun, 13 Oct 2019 17:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571014721; cv=none; d=google.com; s=arc-20160816; b=C4+VG4FA9lT2V3S+3eJcGkLEvAooJUBvJMcVwEuguKDg9YPW0DalL1BybsZiy2aPCj Hry8phGoLH5wXVMoY7HNU6M9sb4XKQz/lBt+O+jOA6+tqmo6cYToQvK96wPp6oiOihiB lZf6s2WyRXSZ76xOug2KdL1xoOyIJn3IX+q8sT/y3RAIi+9yZAUOSnEHhL4/R+exI2XB CExutpulhAQAMnOYfL4/+bIx+Evo5N1NMBghJvdScFV6c0TMpH2OqHwbJ/O+mTmGLDij BjKygbtNDBlFR3iB/l3nIV0rZh8pgCpZDHKQcFvRet1RxAjqwCCO6/E3MB3HP8Fw33UI Ol9g== 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=3R+KOjFcJxzEj7HZtzek49Os8qr1A4xe9Wtj+wmnLMI=; b=rX0Oe/TWrkgNhlW1HPHDA9BctZFj56ytvcBrisJlLBmmXYP+I8OC1AQQAtAWHy5X5q 1Z3g4H7P8vhlnXt5MZGKCk85/ikwlxrHaz4Zj9RUkJ4RE7uCOCFlseD4B/A1iwTsniJ6 6C/tK9a8TppykvuosuJF4+leZ0KxZCF5LYuwC034x0yoSlbk3GIiqHv524WRDchduIkn NbUswPu4LsoCknE84K+Lk7c7rRZwn0GePhk5U+69ohAzIAlksvEyj2sVIbw389H308GF qNCtwyahEsNk09Ca1msE8/vmdKaxEm4gR92m/goeyTTWiYWL3LnR3WJAu+2HbvinMe4I beWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="sZ/nt3MJ"; 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 bt13si10192289edb.245.2019.10.13.17.58.41; Sun, 13 Oct 2019 17:58:41 -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="sZ/nt3MJ"; 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 S1729815AbfJNA6j (ORCPT + 10 others); Sun, 13 Oct 2019 20:58:39 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:40835 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729782AbfJNA6h (ORCPT ); Sun, 13 Oct 2019 20:58:37 -0400 Received: by mail-qk1-f196.google.com with SMTP id y144so14443317qkb.7 for ; Sun, 13 Oct 2019 17:58:35 -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=3R+KOjFcJxzEj7HZtzek49Os8qr1A4xe9Wtj+wmnLMI=; b=sZ/nt3MJoQit3t2N8Ldotj6GBgs9ydlNsOJbMhc+1LM4Iy2EdNza1RSiSgMwBP5TSO a7wWBSMFdqkhhwKX60P9vw4okYb6zD+TMHRDpFoi6O2RQa+xarKSYNPbwr7RNF2zaEKZ XDCkPoFe2wV8J4a7OUkQQfs0eDv/N+z97P+gSpUeS9vIn6BDGz0ok+0rCmTaw4mLRwZD u7ZpzH96c5wig2YXNr1zWnv7mMSD5tfc31dQkmVHSrGOuJXmFgCQqO42buhp7n/EDI/e pu550MJ/RDVRiZEZrETjkjQRr4kdV2bKn7cQdLz1boMQoIcWmvU8EFx0HWMbmpnGJdTR cvBw== 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=3R+KOjFcJxzEj7HZtzek49Os8qr1A4xe9Wtj+wmnLMI=; b=GHj2VQAOEOnvWPDYmqHQZo/BsfAR2ht7VpaT/sif4DBF6rNrp+60rYIA5PRUe30Pht AbQpO9zJsdXFKmDQxpK5AuQEqUucD02KSfF+83TwCGoCZW4Tt5/jbeJirGaF+UV4ANRq F10j35H34QzQKaPvbwXaM6n+p12v1tC+daQfJTGlzHqGEesNmrD65sWmNpbtkE2bQYfd EtLJVh0mV95hiMT9AktqSVLorbiUfEDROzm8vgR3GyT6hKg3glTtDuCrUpintcwJiAQD +sLApqn6zN6hRLPvUgZVOBhIkqTLOTkid7711+i9skCwVJd0Y2YFNEqoTyJjRLkj7GOg o93A== X-Gm-Message-State: APjAAAXB80ASOPUZ8GIZuO+OVt/kWT5S3mkD55j5ir3knK3q6DWEkFQ6 E7zl6gQ7/LoBcEWQQo5GlGfWzw== X-Received: by 2002:a05:620a:12f1:: with SMTP id f17mr27898774qkl.152.1571014715230; Sun, 13 Oct 2019 17:58:35 -0700 (PDT) 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 c185sm7663901qkf.122.2019.10.13.17.58.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 Oct 2019 17:58:34 -0700 (PDT) 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 Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, daniel.lezcano@linaro.org Subject: [Patch v3 6/7] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping Date: Sun, 13 Oct 2019 20:58:24 -0400 Message-Id: <1571014705-19646-7-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1571014705-19646-1-git-send-email-thara.gopinath@linaro.org> References: <1571014705-19646-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 --- drivers/thermal/cpu_cooling.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 391f397..9e2764a 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -218,6 +218,23 @@ static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_cdev, } /** + * update_sched_max_capacity - update scheduler about change in cpu + * max frequency. + * @policy - cpufreq policy whose max frequency is capped. + */ +static void update_sched_max_capacity(struct cpumask *cpus, + unsigned int cur_max_freq, + unsigned int max_freq) +{ + int cpu; + unsigned long capacity = (cur_max_freq << SCHED_CAPACITY_SHIFT) / + max_freq; + + for_each_cpu(cpu, cpus) + update_maxcap_capacity(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 +337,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 +349,17 @@ 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 Mon Oct 14 00:58:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 176108 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3886756ill; Sun, 13 Oct 2019 17:58:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2Lhpw9Mu6vsI6nTcX8yBWHkFPL5Zz0guLy9bDc+XMS9W6dKD8i2DAgURedVs1271xIy2d X-Received: by 2002:aa7:ce08:: with SMTP id d8mr26488481edv.260.1571014726436; Sun, 13 Oct 2019 17:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571014726; cv=none; d=google.com; s=arc-20160816; b=nztTN9RDM4tNy/OOqC3jojfKxLkrjaLc+xmC6xyWmevv8UfovereXCOYFAL0tue6Tc iYjQxMTItletZ7RU8vOjLd3vtQLRL1qjj9cK3p/s3WAhsiEwh7geLujTOSIUXKAsVMnf SrOguglXahD0kUu6TCQGe0hkIvmmbW0HlWlpM2UPHtj8NA03++OqmuqRH7pLKdmTIDEw oGwpVBCezI2o0A4Eyar8yq4sWPqpSCNoEpZOi6zbnT48GPVDEafRDm7QINndRrV4TO2Q TEFvjHe8aRoa4+NdvMXPpcS/cX2dX5EH3f8w1CGqAriiIJAPpWyK93ZyaVrhk7IRbhTp 6NSw== 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=aPyEagV1DxsvKL/RZo3njz7RJXo5X1hyEh5ILDelpv8=; b=m+DqVo9M2mSAt0mcDFDaul6GKpsOmxCYw6Qd1aZcVrf5138/8WOXW/Li+vYq0O0O0N 8ydrrYNLSaeUBFK2Ks24q3+EmD5W9KuJMMzUy3bk+bKyifD0cy+pKxQ8RirSfXQrUbKu xMQA7TLYPAXv3HXf4vFmjmZybII8WnFS9Ij1q4HKZL8lMtsVhOQLjfPHoGCpm6Z/FQJj CYM2mgmC6L0nHDwgEeODlpxtkwX4UbYEuG724UBjuA5dUVC8q3KOJVcLOcZjkw/S0pGv kUP3TlGDeJDYwiU+LkUOdOrCzMslfKpUzvO7g9w2alOIBBVFL4gefthm6fJ73jk2l/QK J0wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JEUmMaVv; 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 k63si11552891edc.347.2019.10.13.17.58.46; Sun, 13 Oct 2019 17:58:46 -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=JEUmMaVv; 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 S1729796AbfJNA6j (ORCPT + 10 others); Sun, 13 Oct 2019 20:58:39 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:36721 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729755AbfJNA6h (ORCPT ); Sun, 13 Oct 2019 20:58:37 -0400 Received: by mail-qt1-f196.google.com with SMTP id o12so23149369qtf.3 for ; Sun, 13 Oct 2019 17:58:37 -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=aPyEagV1DxsvKL/RZo3njz7RJXo5X1hyEh5ILDelpv8=; b=JEUmMaVvI1LTbq3LGF/EHz2CBzkv+GbwvnLMnASrc+hIV9wAca7MyTEh6eTobXhfHE Q+Ca96u2yVxistrNN4nSIttKWMZAiGhjYxHE77kJtMg0Fq3B7kgItwp0zzgctcRMzCIQ pTxOgNH2GVIWWo/X+ghPkmT6MPxxVvXV+Pa7tFIpr6H+oVMT4+oKmwkodX63ZPfQ9naB bWXkxqp6QL3TBDPXGj5sXeGa0xGNkuN4ZaIQqDLYHK1vx2zyXzfRCheESeEG2c9ANJW3 rDLndBM3+sVJpeXsvRP4XoSU/uhEUqmQ09mzeqwPJZhfuuWnKWQ2vg/YvS2eXhUM/KG1 +IJA== 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=aPyEagV1DxsvKL/RZo3njz7RJXo5X1hyEh5ILDelpv8=; b=rw/mEP63PmdmRUJCUzs/hp3EwV5HfGaE93SwMxKNlwM7UukCiu/Q5KODFzw4o1ZfdJ dYrMsjhV2AU/CI6USuO3gVgQGS78xSw93SDDAbf7YOT80d1b+Y5mAuay9r2Jklf5Oarx AOC7QsZXgmmWibB4nRwNrZU7ptJXUzncEnbfzoRGIQOYnrt124GDOgVPsLbETQ79TV+0 qL3ytuC9yzRxdzmIlIIt+5Jrks1dsL3aOq+glInTTpoJtid1pnZqZk0rxWI3LO15dUr1 cXjmxcPCmRvXt2TUzU/SKIgfP6E1VBC3UXZIIhcjjP7U9Kqx6Lz0w/0FconJMdtE1LyG m4Pg== X-Gm-Message-State: APjAAAWumtn+klowBlkM61lkZSNZPHVMBqiDzSQtl+rSFZT4YSjUTZnD LpDw/OrHEnX38ng3bzt9YIsSkg== X-Received: by 2002:ac8:363c:: with SMTP id m57mr30156349qtb.290.1571014716532; Sun, 13 Oct 2019 17:58:36 -0700 (PDT) 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 c185sm7663901qkf.122.2019.10.13.17.58.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 Oct 2019 17:58:35 -0700 (PDT) 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 Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, daniel.lezcano@linaro.org Subject: [Patch v3 7/7] sched: thermal: Enable tuning of decay period Date: Sun, 13 Oct 2019 20:58:25 -0400 Message-Id: <1571014705-19646-8-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1571014705-19646-1-git-send-email-thara.gopinath@linaro.org> References: <1571014705-19646-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 slow decay is to right shift the now run time. Signed-off-by: Thara Gopinath --- include/linux/sched/sysctl.h | 1 + kernel/sched/thermal.c | 16 +++++++++++++++- kernel/sysctl.c | 7 +++++++ 3 files changed, 23 insertions(+), 1 deletion(-) -- 2.1.4 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h index d4f6215..f4c4afd 100644 --- a/include/linux/sched/sysctl.h +++ b/include/linux/sched/sysctl.h @@ -41,6 +41,7 @@ extern unsigned int sysctl_numa_balancing_scan_size; #ifdef CONFIG_SCHED_DEBUG extern __read_mostly unsigned int sysctl_sched_migration_cost; extern __read_mostly unsigned int sysctl_sched_nr_migrate; +extern __read_mostly unsigned int sysctl_sched_thermal_decay_coeff; int sched_proc_update_handler(struct ctl_table *table, int write, void __user *buffer, size_t *length, diff --git a/kernel/sched/thermal.c b/kernel/sched/thermal.c index 5f0b2d4..2a00488 100644 --- a/kernel/sched/thermal.c +++ b/kernel/sched/thermal.c @@ -10,6 +10,19 @@ #include "pelt.h" #include "thermal.h" +/** + * By default the decay is the default pelt decay period. + * The decay coefficient can change is decay period in + * multiples of 32. + * Decay coefficient Decay period(ms) + * 0 32 + * 1 64 + * 2 128 + * 3 256 + * 4 512 + */ +unsigned int sysctl_sched_thermal_decay_coeff __read_mostly; + struct max_capacity_info { unsigned long max_capacity; unsigned long cap_capacity; @@ -62,5 +75,6 @@ void update_periodic_maxcap(struct rq *rq) return; delta = __max_cap->max_capacity - __max_cap->cap_capacity; - update_thermal_avg(rq_clock_task(rq), rq, delta); + update_thermal_avg((rq_clock_task(rq) >> + sysctl_sched_thermal_decay_coeff), rq, delta); } diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 00fcea2..5056c08 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -376,6 +376,13 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, + { + .procname = "sched_thermal_decay_coeff", + .data = &sysctl_sched_thermal_decay_coeff, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, #ifdef CONFIG_SCHEDSTATS { .procname = "sched_schedstats",