From patchwork Thu Dec 12 04:11: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: 181429 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp393728ile; Wed, 11 Dec 2019 20:11:57 -0800 (PST) X-Google-Smtp-Source: APXvYqzPGQyEekuGIU/xj5w1NMKO9RM4jjgNua+aJJqVR1/cZAieGtqE107HEag5Lll0YDR+RHIx X-Received: by 2002:a9d:dc1:: with SMTP id 59mr5915352ots.250.1576123917305; Wed, 11 Dec 2019 20:11:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576123917; cv=none; d=google.com; s=arc-20160816; b=jsCUsAeNLXVBp2/5PP6loNFn1j25SDQLx4r6RTMadNILp8Nok9TsgZthiEP3vUDfYi kdui0PR0TORqqtzF5qeYWvtWaeCSjWxC3V9Wnjx9ij8XRPAsss4FYQ9Yk6M1SOiyqRJ4 X//srHtJZIq2lLri8xVjWh9sOL3xyHhJEBZ6EuylXjCJ/aMfulj69x75FWb4LZulsxUN 64i8FmzAyhwC2vOfR2NeUum8a8eL6jVlDDHeOWnkMbyqY1Qn8PyQ/rkHCLmV9eknhdqv CBN7qp/bzZtSFJAMjG+rcJXQKLBMuNuJ91bjOsiOmpsgiMEAe7JAd+SpNOny57uANmfI XASg== 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=VcDhvGQ0HFCMHix0zaC9dIQROZgnD8ueiSix94LexR8=; b=RKxk9ph27LK20T5mv0Gc0AZiheayL+s1WJj7HyiDroZJC1LZqSt3S0eW1LCjIaLIpg 6a0wliDlTh7HBY7+5lXaO44fcY9+YjoXk9fP+aIuR7wfvG4mmzDVB6+dO3DtzCICaveS QGHPer8KeWQc4XsEzsRO/B1l1UA3tnYjFXCq8tfuz72pHMrhv/QH1A2eNuLKOpR0A4+P kkEwt21wlS74ZXmJE+06I/6mkhn7XFZu0zZihBg62hZcdeUe04/lo0boDjk4e5/W0Y2c oaO2h7sQf3YBtFFi402DbpeC+3LTqy9u4VkPO14F2CyxEgqE76kCBAGpWMTNshUVCfBb 0xhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JAVUepPx; 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 y186si2424408oig.241.2019.12.11.20.11.57; Wed, 11 Dec 2019 20:11:57 -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=JAVUepPx; 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 S1727899AbfLLELy (ORCPT + 27 others); Wed, 11 Dec 2019 23:11:54 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:46079 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727793AbfLLELw (ORCPT ); Wed, 11 Dec 2019 23:11:52 -0500 Received: by mail-qt1-f196.google.com with SMTP id p5so1080808qtq.12 for ; Wed, 11 Dec 2019 20:11: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=VcDhvGQ0HFCMHix0zaC9dIQROZgnD8ueiSix94LexR8=; b=JAVUepPxlepyey7fO/Yk7azK9lSxzBSR7c3u7vSAx2oE3iFywg4J9CM/EPxx/y6e5V oiZCJUsTfNKre3YIFKQzHNRzJYlUffdwWd7ZU8FleF0YJnsUjCgHGhl/4rSkOFSSnC8m xKhBUSehQrbDz+7K7en81JebNyHEDC/yuUfV0eDMztZs/XCi3UtthcajE6NW5McdkDBf SpwOfc6lgJNAslSvr/7wQYIUtoYJQMXvWNXCseWP5LPHs24tPjylCTHoQIylYWlgRWjd 3adETcMR2hNpgOJfIXy6gn2KLALTRZk4/zOtcKMDTkYe04fcvdJ69TZeiwk3alTQdSQe P/Lw== 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=VcDhvGQ0HFCMHix0zaC9dIQROZgnD8ueiSix94LexR8=; b=bFQ34WUlbS/GNqVZYWRZGULg9PsJjVwKje3B21h3+y9oMCrSxMNwB9Iaj5vc2cj/cM oAqvPHzcLa+I6ghwf8f0omqPu+k30h1Vlwb1XCmn4WVegneuhJ8p/MTLecpYFx1NHCqr FtRtKTVxYBokU7LWGf+U6wwQzZf2bSUEd2jfrh9EjMQu/PvZrgQz+037qzgh1BNzbaQ2 Fp0dz5Pa9SvdrBfl2ju6tQosVifT2hJkocqljdE7efzauS4MqshB8BW3tUwhNzxdE8US qRNGqwAKnc8djzQxuFEWemyscJnoRC06ea5x/LWlTfZVLXDagsFv/BIUsSBx+rm18kFv V2Zw== X-Gm-Message-State: APjAAAV7Iz7g0CzsoudT57y+GWk73COpVeEV185r3IO9pTWqK9tdv7fP cYNOII2N2+Krno/xSIhZqkzX7Q== X-Received: by 2002:ac8:508:: with SMTP id u8mr5946084qtg.128.1576123911781; Wed, 11 Dec 2019 20:11:51 -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 s11sm1364126qkg.99.2019.12.11.20.11.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 20:11: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, qperret@google.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, amit.kucheria@verdurent.com Subject: [Patch v6 1/7] sched/pelt.c: Add support to track thermal pressure Date: Wed, 11 Dec 2019 23:11:42 -0500 Message-Id: <1576123908-12105-2-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1576123908-12105-1-git-send-email-thara.gopinath@linaro.org> References: <1576123908-12105-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 existing 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 bookkeeping (accumulate, decay and average) of the thermal pressure. Signed-off-by: Thara Gopinath Reviewed-by: Vincent Guittot --- v5->v6: - added trace support for thermal pressure pelt signal. include/trace/events/sched.h | 4 ++++ kernel/sched/pelt.c | 22 ++++++++++++++++++++++ kernel/sched/pelt.h | 7 +++++++ kernel/sched/sched.h | 1 + 4 files changed, 34 insertions(+) -- 2.1.4 diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index 420e80e..a8fb667 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -613,6 +613,10 @@ DECLARE_TRACE(pelt_dl_tp, TP_PROTO(struct rq *rq), TP_ARGS(rq)); +DECLARE_TRACE(pelt_thermal_tp, + TP_PROTO(struct rq *rq), + TP_ARGS(rq)); + DECLARE_TRACE(pelt_irq_tp, TP_PROTO(struct rq *rq), TP_ARGS(rq)); diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c index a96db50..9aac3b7 100644 --- a/kernel/sched/pelt.c +++ b/kernel/sched/pelt.c @@ -353,6 +353,28 @@ int update_dl_rq_load_avg(u64 now, struct rq *rq, int running) return 0; } +/* + * thermal: + * + * load_sum = \Sum se->avg.load_sum + * + * util_avg and runnable_load_avg are not supported and meaningless. + * + */ +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); + trace_pelt_thermal_tp(rq); + 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 280a3c7..37bd7ef 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 Thu Dec 12 04:11: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: 181428 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp393738ile; Wed, 11 Dec 2019 20:11:57 -0800 (PST) X-Google-Smtp-Source: APXvYqzZZXTd/cwKFd0RLe2aQnB1YoueDnVQAHoM7K9frGl8r6ZhHIRoKLGgcuv9eFVLn84HBKul X-Received: by 2002:a9d:32e:: with SMTP id 43mr5776319otv.301.1576123917716; Wed, 11 Dec 2019 20:11:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576123917; cv=none; d=google.com; s=arc-20160816; b=QOdNRcP6iIivr8R6OpUBIQjbP38siEHFhRBTgEmSggGjyoYgoE0U4mybgmlitzzTu7 jxPbTj1E8LumrxLRP4rgbymKVvxRs5/vre/ylb9KYTPVvSNdh6ZyY+wamERFWrVt4kZO 9MGtH+MGqSVoR8UWBtZO9B7YFoOal3DrWsBQwokxj/ZIjsETNjFpGmsAmb2iaLEc1AdC pmlqGsYf5+o1EHs2D5Z++GjT2VeMrhFCT3vvX+EQX6pn/vQcapbhVd9VcdFBvDLHtDxc fN9E15Pl8IgfcziIZh+ETe/DgtKO85R2DfX21xv+C04xHv3c/4ayPxZdQnapbuWC8xZA X8vg== 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=LZQF+cj5Bhxi0fnKlCZLhWKPYoA+2wvT9NUU/aNTlDY=; b=iZ6VSHTcWWZR4e1YOdktTCtI2C9OW9B5oMt0zOc20CjtPR993LIg57jzB+U8IVul78 Oh8vhPzx1uCZyksa/DM9L9B1HDj743CIdi6YNzrh7RYlabvHnpqdoeQCtpFVFImuY/os Be8XpOCsfMGpHkHp9LzDKQAWlq+RauVLCCNRg02ZFMao2YgZvtuGEshZiPbth2q6Dvzx h+LLUXxjqO4PzJp4WIQHihPQVi2hZMYzjOmkY8hqdpyBMFssPCOfnf4Ghx1WGWx4C1pi CGxSZeL746lYZTnerTBATercd+bli6V3BF0Bl3G5hSAIjJ2k3TBPBNNySzdPVdXDXWYn n3pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cZ5wPiQg; 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 y186si2424408oig.241.2019.12.11.20.11.57; Wed, 11 Dec 2019 20:11:57 -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=cZ5wPiQg; 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 S1727922AbfLLELz (ORCPT + 27 others); Wed, 11 Dec 2019 23:11:55 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:34222 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727894AbfLLELy (ORCPT ); Wed, 11 Dec 2019 23:11:54 -0500 Received: by mail-qk1-f194.google.com with SMTP id d202so549028qkb.1 for ; Wed, 11 Dec 2019 20:11: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=LZQF+cj5Bhxi0fnKlCZLhWKPYoA+2wvT9NUU/aNTlDY=; b=cZ5wPiQg+y190GfRUdHxHfr45yDlULDc+9gI0ExsfvWfblHgptSgKSVJAQTST1WZ9H cvrmmq1s3R58rGA3H/JzHXAQweX4kpdOrOBQbGLyOZlpNtLzTOLUyq/B4jNukqqMlJq8 /+g6BeaVhxGzA6pIiiIvv/kEkPew/Uykzeqq2Wy0L1iPbd4LfXaeSSKTMNpqU+9mKy22 apevOxfODbGBUHCKxSZKv3EXV36mN8sWMYuVodf0gi/RrmHQ/ZFNs4xXvJgt0vI6r8+e WUo0s5ZYOiRnxHlcQRG8tyKkdABID6J2DI1YGhTDOhvMUnJtYAksegkpPpYI5uaVQh89 o70A== 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=LZQF+cj5Bhxi0fnKlCZLhWKPYoA+2wvT9NUU/aNTlDY=; b=osNOuh/StkiteKu205G5X7hZA0S9xKRdTgW42a4cMOsz3bj/3SUtPt1/nYPSDsvmgb B2+H02Q6OoUFX6Fk47LRWrdbwt1eUKJHxfmfK/WoIf4SxYvovI9HNOcCNQ24malZwd17 FkDuzuvUv/0MJFKpEZ18rFarcY/VZm72fdOKlueGbD6dFZb177fGozwEMir77eUgPd/O vu1oarJAW1JGi/laEH9TbtaQFAl6KNzuDEgyFoN5WQuBWDNIEKihaRGcETo7NsGEza1L WAYPbLu3aNs1NgbdFuJV0hmVYa0ci8i0WySF1d8V7vw7585yQqUmCuCquOTBRdUKaykZ wSnQ== X-Gm-Message-State: APjAAAUnYPPCD0xly484SCgkKf2R2XT3FTckh0lUg6O2UjW/OO9GiFW9 FftP3goqjfeTPaGOrUgsyXJf/Q== X-Received: by 2002:a37:4943:: with SMTP id w64mr6275611qka.300.1576123913015; Wed, 11 Dec 2019 20:11: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 s11sm1364126qkg.99.2019.12.11.20.11.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 20:11: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, qperret@google.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, amit.kucheria@verdurent.com Subject: [Patch v6 2/7] sched: Add hook to read per cpu thermal pressure. Date: Wed, 11 Dec 2019 23:11:43 -0500 Message-Id: <1576123908-12105-3-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1576123908-12105-1-git-send-email-thara.gopinath@linaro.org> References: <1576123908-12105-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 arch_scale_thermal_capacity to retrieve per cpu thermal pressure. Signed-off-by: Thara Gopinath --- include/linux/sched/topology.h | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.1.4 diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index f341163..f1e22f9 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -225,6 +225,14 @@ unsigned long arch_scale_cpu_capacity(int cpu) } #endif +#ifndef arch_scale_thermal_capacity +static __always_inline +unsigned long arch_scale_thermal_capacity(int cpu) +{ + return 0; +} +#endif + static inline int task_node(const struct task_struct *p) { return cpu_to_node(task_cpu(p)); From patchwork Thu Dec 12 04:11: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: 181435 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp394129ile; Wed, 11 Dec 2019 20:12:24 -0800 (PST) X-Google-Smtp-Source: APXvYqxlmMbjt2zc1+3QvS0SjWVE5JpxBsaI4h80FG/ajbgnuBmKnqBsVsHWNcOvllp8WtY87obA X-Received: by 2002:a9d:6f82:: with SMTP id h2mr5829405otq.69.1576123943878; Wed, 11 Dec 2019 20:12:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576123943; cv=none; d=google.com; s=arc-20160816; b=IIfdxrd90eu+rReVXpSN2Xt5eI8wLxZgHLxKFJy3TriIqPpwPreMLxmZFl6Qi3rhPD Yi7j4ttXQwlOElwbCbLd6swUfoaTnwMWbMfTo/BfTybkf6rakVqV/Mp1pVn2XipnCnOh GW+M5u+G4TTvDHbqtkATVYp8Cw8ABA76H3coGz1RZF6E+xy/zz9xOMvjdFUf7WZcFGXH zYySorDGdfsiomR8BYZvCoxuZJFQ/Ikx+XhaPkad+QVM8O7GJBqYRONKZyhhZdf2buob CV0lpTcIA+j0YVu9wdYZzNZZF+q5OJRNrgzLcmOarMWEh4lCKyNQ5xNxNgR/oMGLzlgg G+7Q== 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=7l5JKLqHdHgruudTWmIyB43cagXE9G3mjJRNavUYrx4=; b=oj/Px6bBVMY52MAXFjl7wczyjZ+HItgQsGSsH4L8dm0NlRtrSruJdip4Ob7lURtVho giQqInOjlWUPaJmN28Fb+NUY+XkmbhWb5C6o75344que6ifJJqvoLQYs/NL2ivzbqFa+ pfjnwKOYjOer+lm3SR2a6iaf489rlKEfOfq5h7lSiJfsLcqAIW2ZM4UKhdnR6xx8U5ZH 5d0QHwrYtpdTR7WCKw6kpjD6MoJApV1N5E5FvzwMT6KfaJXzr9Uk0NGylvZ2zb9pcR1l PmbWqJtJJX/HqlqBUVYnS8iGffBCQDBJns3fLfkzrplz1VBZpAZVei16hdS576FmVlgq xa2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e3SCyNmm; 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 a128si2463747oib.142.2019.12.11.20.12.23; Wed, 11 Dec 2019 20:12:23 -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=e3SCyNmm; 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 S1728009AbfLLEMW (ORCPT + 27 others); Wed, 11 Dec 2019 23:12:22 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:36372 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727900AbfLLELz (ORCPT ); Wed, 11 Dec 2019 23:11:55 -0500 Received: by mail-qk1-f194.google.com with SMTP id a203so539599qkc.3 for ; Wed, 11 Dec 2019 20:11:54 -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=7l5JKLqHdHgruudTWmIyB43cagXE9G3mjJRNavUYrx4=; b=e3SCyNmm8WdEkCQ7f3y2JoLiUnEkvMrrU/TuSfpi+kkupGJr28+LC5r5TA0lQcSeIR vvBy19qWpacP2+4UZTKfaFcgRe8r7P1Wfcq3xidv9Hf43Mq3Cvt8TvxmiTXfn3N/Xsvh Apr44+/tMBHFY6K27rPCm9SiRomjBs/sNiM3GDLBtohddXnL6BcV0q4+mMU+HkXsnzAC /EdpT3yUbUdm/3Ib5DgDGRuiIV2g1jbbDKPN6TtSstSp4SVzX0aydgoGdgd+INdWmFB9 3dIjeKF+X+Ig3QzTtNaP7/pEhOU80TuR1vsNrqwGQiNR5uaY+iYmySn639nxva/hL8CW RiWg== 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=7l5JKLqHdHgruudTWmIyB43cagXE9G3mjJRNavUYrx4=; b=PNaDAP8eoHgZnk9rFbVNJfUsuC0oNe5KWSIBSpOIdroWWxVdCSBhqo3zwoy2lxwGqr a+podJzhTt4uF5QIgdNK5khbXnkOGPh670iRdvWy+R733fjbj9Y+Fis3oT2OSaMYILpk ZCoFUQpeigE41onca2WcDKyEdR2mRvTylfNXdP08Mb6eTScIPlP6wSHPQjYiQO82R/HH nJ0e3UckOV8QwrlfNgcn/UjiBbiMsE3CyUMONuWAcnlUwRHVNiTAFzgo/Tjp9Vx/KqbA 51xg4CXWMitV6JbjSxs9syb5SSLj4p7BUVaOqKAFV1HVAOxC86qk8DZBOdxWcHe9bkBA Rt/Q== X-Gm-Message-State: APjAAAUYiCgji/1zAN5TcN3SbOEJpdofxchREApRAK+taiZh1FpSK2tL n4MafJEpFIUhYe/hmNlzUzAP/Q== X-Received: by 2002:a37:b601:: with SMTP id g1mr6388350qkf.114.1576123914207; Wed, 11 Dec 2019 20:11: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 s11sm1364126qkg.99.2019.12.11.20.11.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 20:11: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, qperret@google.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, amit.kucheria@verdurent.com Subject: [Patch v6 3/7] Add infrastructure to store and update instantaneous thermal pressure Date: Wed, 11 Dec 2019 23:11:44 -0500 Message-Id: <1576123908-12105-4-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1576123908-12105-1-git-send-email-thara.gopinath@linaro.org> References: <1576123908-12105-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 architecture specific APIs to update and track thermal pressure on a 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. capacity and capped capacity due to a thermal event. topology_get_thermal_pressure can be hooked into the scheduler specified arch_scale_thermal_capacity to retrieve instantaneius thermal pressure of a cpu. arch_set_thermal_presure can be used to update the thermal pressure by providing a capped maximum capacity. Considering topology_get_thermal_pressure reads thermal_pressure and arch_set_thermal_pressure writes into thermal_pressure, one can argue for some sort of locking mechanism to avoid a stale value. But considering topology_get_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. v5->v6: - As per review comments moved all the infrastructure to track and retrieve instantaneous thermal pressure out of scheduler to topology files. arch/arm/include/asm/topology.h | 3 +++ arch/arm64/include/asm/topology.h | 3 +++ drivers/base/arch_topology.c | 13 +++++++++++++ include/linux/arch_topology.h | 11 +++++++++++ 4 files changed, 30 insertions(+) -- 2.1.4 diff --git a/arch/arm/include/asm/topology.h b/arch/arm/include/asm/topology.h index 8a0fae9..90b18c3 100644 --- a/arch/arm/include/asm/topology.h +++ b/arch/arm/include/asm/topology.h @@ -16,6 +16,9 @@ /* Enable topology flag updates */ #define arch_update_cpu_topology topology_update_cpu_topology +/* Replace task scheduler's defalut thermal pressure retrieve API */ +#define arch_scale_thermal_capacity topology_get_thermal_pressure + #else static inline void init_cpu_topology(void) { } diff --git a/arch/arm64/include/asm/topology.h b/arch/arm64/include/asm/topology.h index a4d945d..ccb277b 100644 --- a/arch/arm64/include/asm/topology.h +++ b/arch/arm64/include/asm/topology.h @@ -25,6 +25,9 @@ int pcibus_to_node(struct pci_bus *bus); /* Enable topology flag updates */ #define arch_update_cpu_topology topology_update_cpu_topology +/* Replace task scheduler's defalut thermal pressure retrieve API */ +#define arch_scale_thermal_capacity topology_get_thermal_pressure + #include #endif /* _ASM_ARM_TOPOLOGY_H */ diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 1eb81f11..3a91379 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -42,6 +42,19 @@ void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity) per_cpu(cpu_scale, cpu) = capacity; } +DEFINE_PER_CPU(unsigned long, thermal_pressure); + +void arch_set_thermal_pressure(struct cpumask *cpus, + unsigned long capped_capacity) +{ + int cpu; + unsigned long delta = arch_scale_cpu_capacity(cpumask_first(cpus)) - + capped_capacity; + + for_each_cpu(cpu, cpus) + WRITE_ONCE(per_cpu(thermal_pressure, cpu), delta); +} + static ssize_t cpu_capacity_show(struct device *dev, struct device_attribute *attr, char *buf) diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h index 3015ecb..7a04364 100644 --- a/include/linux/arch_topology.h +++ b/include/linux/arch_topology.h @@ -33,6 +33,17 @@ unsigned long topology_get_freq_scale(int cpu) return per_cpu(freq_scale, cpu); } +DECLARE_PER_CPU(unsigned long, thermal_pressure); + +static inline +unsigned long topology_get_thermal_pressure(int cpu) +{ + return per_cpu(thermal_pressure, cpu); +} + +void arch_set_thermal_pressure(struct cpumask *cpus, + unsigned long capped_capacity); + struct cpu_topology { int thread_id; int core_id; From patchwork Thu Dec 12 04:11: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: 181433 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp393942ile; Wed, 11 Dec 2019 20:12:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxst1+OxX1wT9/vOi+PLtIoWBGddLUZG6C5UPEDzJFUbHxKdFK5JUcq9ycYVCGGoYsoV3XN X-Received: by 2002:a9d:798e:: with SMTP id h14mr5565194otm.257.1576123931438; Wed, 11 Dec 2019 20:12:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576123931; cv=none; d=google.com; s=arc-20160816; b=qhfwYtUijQwhH1mszjLqBfgRpnfPt0OPBwIIyfIiYMECGtJPkW/bi0gM9pjxTARTux AQcgh3ywlZ542Cn+g/7s+b5+nHBW8PMUXdxophdCsJOF+XhclMWLcJwhQ8mcmuyL6J0J IhXRmd84NF0yLc6Kd699Lpu8SUxJyuQnFBlkHl/l6TWc6ubUyXyr/0ER1kxbRZnWQUdz Qj/sCsh2Hzm9gLx3+LuqK7UGOj++GyDQqyRnUeWxAKybI0PIUg4YRNH5t5f2V/8/DXzL jUoaba3N7hTHZJMPLDCuUc4icuUxONX1HwMe+/lVZI0YbM31BrAv3z+CauTDpJe/RVDq WXvw== 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=Gp6DVIMwVoklcyjDkqg4ILNDJLNp+8FQvrp1u97hUfE=; b=Tfi5Tx4MQye6FlscPbcmwE4/hoC0wU1WC6vgW6W8FXcynPsNU3OLTjM4+9inoO4tk+ 78GljFFPWLfd3F0E8/zeqG16WiVjlF3VYt4IT+ZB7Geb340kHy7qr09T25/5/BoR7oLd npwQ4Kj52wIzl0QGe1omyxLD3cXMmWZuVZf0OIWjrv96j1pnbeGYs+oevzDlrgHEvNOJ G6KwfnR3CnKZE/9N6h8PFQYuYB0TVo9LYdqR1WBPHHK1yULA4jG4Lx56Xxn+ZMhihayQ uZ1nWQn0FfgtkEltS1yUDO1TNBt5LSztaLoRpBlfRmO3hE5HzqSsoWNqbr8+Al9xDzix mWsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lEzOn69h; 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 o206si257348oih.143.2019.12.11.20.12.11; Wed, 11 Dec 2019 20:12:11 -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=lEzOn69h; 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 S1726413AbfLLEMB (ORCPT + 27 others); Wed, 11 Dec 2019 23:12:01 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:45321 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727923AbfLLEL4 (ORCPT ); Wed, 11 Dec 2019 23:11:56 -0500 Received: by mail-qk1-f194.google.com with SMTP id x1so500482qkl.12 for ; Wed, 11 Dec 2019 20:11: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=Gp6DVIMwVoklcyjDkqg4ILNDJLNp+8FQvrp1u97hUfE=; b=lEzOn69h/8U6OZo0Ylkp+ZDqv3WQYnl2Rz1FCJbfSsBWYxPEW8OYeIjjl5mKle9K2H +EY9aUHhVK84JduAxF0LdxrQ6aj0dvIxhxHUEjmeLLPOi2uMwnoyjusbqSwUdfCA3Hkl geObQvsPEtfnqcm9dmPFdLgfJdj/peIpg3lpEsjNJHfW9KvxoFdZkpv3udkcbywhzuxK ZtAHbNq1q9Wq72K/QV84rZf+x7hWYw+NFivL+tAz4kc1mfu2jHduamdDhjx+aoSiZf63 NaMt1tbhDmXxbkiofYn90Cke/XRISuN4eyoI7SOtB3jNX+rKUT1MVa8u8urgpYVRE53l x60Q== 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=Gp6DVIMwVoklcyjDkqg4ILNDJLNp+8FQvrp1u97hUfE=; b=HgiKAtE2fOcQ/Mr1PFoSlBLvLcHL5a+mdo8FYp7EIxAu7OYG4fgC1OeNc1ks8SWwO2 YkACvnzwZtLryoIgE8hFFejzOd1DIFR9tMKXM9uWb9UgeG62GDSmc3SlT1n/MpKgyBPZ 17j/F7kZWt6kJgW7YJFxdamaXl48ZFPHoCuZTsFgmZLpnP/6KnimaNMOME2xLIGhMhkk aGEipW1yAuWQyfizJQVXmqJXArwy5MTU/y1zkSZtAo5FoFNoV40fyeCqnnvhLOBdsbEA kLJj0tGY3ymQ1YM/jqq6uIhtNVy3WgWe6DY/APf9NLCRWO1eh/Gu8h/hRe+OQMe/f7Ki DZBg== X-Gm-Message-State: APjAAAWllmL0U6bu7S4f9XDenoTBu6D40g10Xzk7SDolj8auKkY+wsCQ ncXTL5pT/kMRDtImDdObWoS7DQ== X-Received: by 2002:a37:a70b:: with SMTP id q11mr6171161qke.393.1576123915314; Wed, 11 Dec 2019 20:11: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 s11sm1364126qkg.99.2019.12.11.20.11.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 20:11:54 -0800 (PST) From: Thara Gopinath To: mingo@redhat.com, peterz@infradead.org, ionela.voinescu@arm.com, vincent.guittot@linaro.org, rui.zhang@intel.com, qperret@google.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, amit.kucheria@verdurent.com Subject: [Patch v6 4/7] sched/fair: Enable periodic update of average thermal pressure Date: Wed, 11 Dec 2019 23:11:45 -0500 Message-Id: <1576123908-12105-5-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1576123908-12105-1-git-send-email-thara.gopinath@linaro.org> References: <1576123908-12105-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 --- kernel/sched/fair.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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. -- 2.1.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 08a233e..e12a375 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7462,6 +7462,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; @@ -7487,6 +7490,7 @@ static bool __update_blocked_others(struct rq *rq, bool *done) { const struct sched_class *curr_class; u64 now = rq_clock_pelt(rq); + unsigned long thermal_pressure = arch_scale_thermal_capacity(cpu_of(rq)); bool decayed; /* @@ -7497,6 +7501,8 @@ static bool __update_blocked_others(struct rq *rq, bool *done) decayed = update_rt_rq_load_avg(now, rq, curr_class == &rt_sched_class) | update_dl_rq_load_avg(now, rq, curr_class == &dl_sched_class) | + update_thermal_load_avg(rq_clock_task(rq), rq, + thermal_pressure) | update_irq_load_avg(rq, 0); if (others_have_blocked(rq)) @@ -10263,6 +10269,7 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued) { struct cfs_rq *cfs_rq; struct sched_entity *se = &curr->se; + unsigned long thermal_pressure = arch_scale_thermal_capacity(cpu_of(rq)); for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); @@ -10274,6 +10281,7 @@ 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_thermal_load_avg(rq_clock_task(rq), rq, thermal_pressure); } /* From patchwork Thu Dec 12 04:11: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: 181431 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp393845ile; Wed, 11 Dec 2019 20:12:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzRwYK+h6ePr3L3KcLWOYLAsLCTSFnXFMDE0vwEyF+OZhUE407748Ctb6FOIkz4rko6okzs X-Received: by 2002:a05:6830:14d3:: with SMTP id t19mr6080168otq.278.1576123925744; Wed, 11 Dec 2019 20:12:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576123925; cv=none; d=google.com; s=arc-20160816; b=dDxJdCzSMzIfzzMbTUQ5HRynMkgH+bnEvJUXsTIdKbE1hkVS7SbWpLCjzwaPd/gBgD 1ipgyAxXs5MUCchVERfa+ojz8qdNbB7v3y+XOuYUIACM2D2Un0R3m5eCgjSKDDIQ0vhO OQWc6tyr4XqcQyNAHWpU5l638KcncWWZX2dQhvA6mj5yNX4Sra8rAhVqYNbPidCVpy5A ArGUyHBq++7SxR6XQhC4z3EfSF5ps7L8c1b/pFflwhpOPkp2a+RK9BGOlcr36IAHziFe gndQXi6CDLYwrnmidQ8w9fWodvr4xbsR21K7h436kIzudiHraAWc4DuEKoreD4CtdZar 2gWw== 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=tCcvIBy4MWkmlTDlVDEp03XcYYwKUTHVbYQuzgTBX4Q=; b=FNC5A2P+BGFCSzOc8thb4iPZMbUR4Z3lNpZOqD6x9ZTwoy6n3gG0xkZkKXqJshc7Yv bhRh6HS8yCszeDvGrHuImoALpI3Y7nIptUxHK/c5jjSS8PhEju2MGKKlZXGC2qmV7Y+o o1hySjgQAs8ji7InX4ayaYRpkzN++rRwta9Tol4nGKtSa0Sptr+HWDgxTTRwtR3i8b2l Jb+YFkCDKsn4/sZ0u7+UANWtQe+iFSq2JcFIjgCYBiIMyG7QvjPOwdrqrcmeMFb8ozUF p9xn13rTNXVl/AcJXrESZPxj4KDPk9GylX75KUp2dqANrO0qF/LFwtrqKh/rYF6VnJwa hrDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ygf5rZfK; 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 x137si2385764oif.42.2019.12.11.20.12.05; Wed, 11 Dec 2019 20:12:05 -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=Ygf5rZfK; 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 S1727957AbfLLEMD (ORCPT + 27 others); Wed, 11 Dec 2019 23:12:03 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:44410 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727894AbfLLEL6 (ORCPT ); Wed, 11 Dec 2019 23:11:58 -0500 Received: by mail-qk1-f193.google.com with SMTP id w127so505950qkb.11 for ; Wed, 11 Dec 2019 20:11:58 -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=tCcvIBy4MWkmlTDlVDEp03XcYYwKUTHVbYQuzgTBX4Q=; b=Ygf5rZfKVmn/YQ2uNC2loIbKbXNMF6frWitGn6qeyZ917m19A5o1WHD6CnSKJhwXVt 8vJSDHkWzbBLzSUKqGeWG/6Aj2oHGDxefkxkXVkehkoVlB450eAHBTvOpea/2kPVy+GZ DYZ/+YzXpJ9dkZrto/jov76v5xlJmHVFq3V8gL4JEmDItuwGbp6ciUpPbEYmKv5ClIEW VZxIaaIMoGHDL3ggjAp8iBjSDL1voIUDTrRtLWBZltJja++P/tdMancPKhXQuvsrmZNK bVKm6TGcLsB+E0qVJPb6q48wLx3VFmMq3ymvTXwDvSp6Upz7caAfnpiWP/pJgoCsxZG6 MXiQ== 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=tCcvIBy4MWkmlTDlVDEp03XcYYwKUTHVbYQuzgTBX4Q=; b=GtrLTIj26qxOV0duR5HXYtZiKQJu9tqWit6tZoo4guzOxafzmRRW5/Dkg37Oe3gjIF pCzpcPoOfYfk/jWpDbyhOeQkADHmFhS9oMcw8/HcJCoxGp9/hr9VsjmmWVrhqi3zywyr jPMTjIggvN0h+H/R2DRySTKVMJ4ZClqGXwr+dQQyerAi43WmjpTloNhYA2eiWwZboGdM scJEMZ8A10Z4TWL2bNmTS1wEbdwe2N59sQ+ufPUJGRylbWtsm1LETZzvYxnZ7fSGBARO hlvaomVSVi6O/rQ3GlZ/scS9qEZKIkjBM0uIriyBmIJOBAFrUevVJg3JSsdj9zoCwv8A Nyzw== X-Gm-Message-State: APjAAAV+J0btvFecqzLB9Unqk7nT0P+CWbRZrDJ3+vlPO7GOdXakvChl IlUXjcMEFE/IsS7bk519nkalp0hjmnA= X-Received: by 2002:a37:5d0:: with SMTP id 199mr6226995qkf.131.1576123917716; Wed, 11 Dec 2019 20:11:57 -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 s11sm1364126qkg.99.2019.12.11.20.11.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 20:11:56 -0800 (PST) From: Thara Gopinath To: mingo@redhat.com, peterz@infradead.org, ionela.voinescu@arm.com, vincent.guittot@linaro.org, rui.zhang@intel.com, qperret@google.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, amit.kucheria@verdurent.com Subject: [Patch v6 5/7] sched/fair: update cpu_capacity to reflect thermal pressure Date: Wed, 11 Dec 2019 23:11:46 -0500 Message-Id: <1576123908-12105-6-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1576123908-12105-1-git-send-email-thara.gopinath@linaro.org> References: <1576123908-12105-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 | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.1.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e12a375..4840655 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7725,8 +7725,15 @@ static unsigned long scale_rt_capacity(struct sched_domain *sd, int cpu) if (unlikely(irq >= max)) return 1; + /* + * avg_rt.util avg and avg_dl.util track binary signals + * (running and not running) with weights 0 and 1024 respectively. + * avg_thermal.load_avg tracks thermal pressure and the weighted + * average uses the actual delta max capacity. + */ 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 Thu Dec 12 04:11:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 181432 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp393890ile; Wed, 11 Dec 2019 20:12:07 -0800 (PST) X-Google-Smtp-Source: APXvYqx4MfsXqUeNt2GT5bbMzwkQrvaH5THytLH7v/2t9NE9KGP2NOBP8tjY6z83mDskHlfzDifp X-Received: by 2002:a9d:6f82:: with SMTP id h2mr5828272otq.69.1576123927764; Wed, 11 Dec 2019 20:12:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576123927; cv=none; d=google.com; s=arc-20160816; b=iApDHfcTmJ2dOrh9Dgl5Vi0qVh7ihzDvQ7eshyuoY6FirLVjl5+/D2riSuBNIwb+QL V77n7bkbX+xFll4Qybbl6sdu2dHRSVxbDxQr61Kghkb9c1rdIkku4qwx7eVJlWCzsT/H vARS/ToLDE7Az6pxKrULOcjTufQiT4a+rKMZVtCpo/swD+FXShCXmWwLk3dIbfqQDYhM szrXTMe1iTv0c4ck4TYqFmbqVcBVyaJAz7NUKOc/ZNm71Vb4ZWQEjk166MzPOzZbZgqg nPrKBRT0j67uOIpUhdoaIuKRAHqC9Fz9loqYQ6Mk1/ftr6Ynia2cJ/LDI3lkNm7vBlRQ Ro5w== 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=tpyt5iG8GvXOAcMS3lIsuWdgJqz7gi4VYr1fr05aHWQ=; b=FAX9mM2qlN27wN5vTszgxCEoj9euKY7hL1AMUINMOoGs6t0KwIk8lFbCP3ZCw7J8BI a0tpDTaQWLEdZT3jwehkzpJdWp3MYXXr5wDpTPfebfAMY2mibdCLlwB5aRFshgRR78b4 gEw3A53oCS/o3R92cFOCu2jMcH1ozExxu0brOQe978G3cGLqQ7m/nlKQrxjU9D3pV6Lf 0L56V2qAyceUYBwzEQczDSx+QifbPyb+L4Z7XiZsPXnOonX/D5P9OVL8ELOmFObfL6II 7DihdT0/GyLb4RJixoEzQwW+kDLPTnAh0F0KzQ8brNEh0DjVc71/KtH7j7FvLU9I3a5H JVAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=duEljXxt; 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 h138si2266422oib.6.2019.12.11.20.12.07; Wed, 11 Dec 2019 20:12:07 -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=duEljXxt; 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 S1727970AbfLLEMF (ORCPT + 27 others); Wed, 11 Dec 2019 23:12:05 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:40240 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727936AbfLLEL7 (ORCPT ); Wed, 11 Dec 2019 23:11:59 -0500 Received: by mail-qk1-f194.google.com with SMTP id c17so521536qkg.7 for ; Wed, 11 Dec 2019 20:11:59 -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=tpyt5iG8GvXOAcMS3lIsuWdgJqz7gi4VYr1fr05aHWQ=; b=duEljXxtpMvFC8/JZAIVfpc+2JH8fpg4gYIS7wciQah12QzxBYgX+rIgvHbC+UykXs J8HloSy//1JoycNnC91yQ455dOc9s2juG4F8NiqHfD47Ezh5vd/qtAYZlHY1nJlEhZBe 5vde5fp+6ow/szA/F/T0XgFb+cGJkcOEMJdn5vY1KikPGe8/6Az5W1IzETfTU9YgLa7z XzTfEm2s3+8Aw0CA1jpGv7MnO6lDyfrDutxLEMT+1YektINANuhKCcOb3ivUAthfYQld UblqEm+fkmSEnDZABNePuCvzP8A06siJMZnS4drxiAVq6/Y5DUjIEyMsGMoaH8EFY606 YaEg== 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=tpyt5iG8GvXOAcMS3lIsuWdgJqz7gi4VYr1fr05aHWQ=; b=EX3cvIR178P/Hy1r9HfKQjD7jSlwkoSmceJr86AK12mjRUaNUWyaWXbMHgAoInIS/4 bFwoboLGpfJZTKJuseUVF6lfKi+ffR6LeoH85qL9EIrh1eC/huEByWb/ilA2frq81NDU S4I0k2Q9xc3ap4tnMIEQEP0T6yh/+igMyqHVseEn3LilTsODdfbI7HmIBvEhDT0J5HBI 4DOPq48Sk+r6nSzzcHgoDd72vJr4IWu1fjYKtlpqcpzD6DxzCAjCTrWEWmBXqjcpLi05 /YFaxLdc0KZXgB4+8HpuAFtpRFYpV4Cz98afijEKJLGdOng0Ap1rOjoMhY48a+Vsvq5O oMKQ== X-Gm-Message-State: APjAAAVIn+uQeEMGWDVGs0zjYT37yqfZcgKA2mq/hfnBpqaGeGCwYYZ9 natx3W4o7WiDWluZ2L8zFEkQow== X-Received: by 2002:ae9:e702:: with SMTP id m2mr6382951qka.208.1576123918930; Wed, 11 Dec 2019 20:11:58 -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 s11sm1364126qkg.99.2019.12.11.20.11.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 20:11:58 -0800 (PST) From: Thara Gopinath To: mingo@redhat.com, peterz@infradead.org, ionela.voinescu@arm.com, vincent.guittot@linaro.org, rui.zhang@intel.com, qperret@google.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, amit.kucheria@verdurent.com Subject: [Patch v6 6/7] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping Date: Wed, 11 Dec 2019 23:11:47 -0500 Message-Id: <1576123908-12105-7-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1576123908-12105-1-git-send-email-thara.gopinath@linaro.org> References: <1576123908-12105-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. v5->v6: - Removed update_sched_max_capacity. Instead call directly into arch_set_thermal_pressure to update thermal pressure. drivers/thermal/cpu_cooling.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 52569b2..c97c13e 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -430,6 +430,10 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; + struct cpumask *cpus; + unsigned int frequency; + unsigned long capacity; + int ret; /* Request state should be less than max_level */ if (WARN_ON(state > cpufreq_cdev->max_level)) @@ -441,8 +445,19 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, cpufreq_cdev->cpufreq_state = state; - return freq_qos_update_request(&cpufreq_cdev->qos_req, - get_state_freq(cpufreq_cdev, state)); + frequency = get_state_freq(cpufreq_cdev, state); + + ret = freq_qos_update_request(&cpufreq_cdev->qos_req, frequency); + + if (ret > 0) { + cpus = cpufreq_cdev->policy->cpus; + capacity = frequency * + arch_scale_cpu_capacity(cpumask_first(cpus)); + capacity /= cpufreq_cdev->policy->cpuinfo.max_freq; + arch_set_thermal_pressure(cpus, capacity); + } + + return ret; } /* Bind cpufreq callbacks to thermal cooling device ops */ From patchwork Thu Dec 12 04:11:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 181434 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp393990ile; Wed, 11 Dec 2019 20:12:14 -0800 (PST) X-Google-Smtp-Source: APXvYqyZvBqfM0QUz4iIKIulkFUNGUxvKNx68DszjoDgU96VTIv5usC1wEGENPTpg92rODvSWQK8 X-Received: by 2002:a05:6830:128e:: with SMTP id z14mr5642398otp.184.1576123934860; Wed, 11 Dec 2019 20:12:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576123934; cv=none; d=google.com; s=arc-20160816; b=hZtY1K5h1ZRnXvSrDHfweAQJcOxkP/Nm8s8YIlIafhML5l9fMvGDzhnbQ5yTtztPDL PjVwxCGNHd0ZVje4xcPyV54DIwFj7/ZIZME/BnquPKLy82gGOve6avWX+etljW+velKl VIGZ12zSDrTXqb55sqKqNQv1t/noUkIfJYOS/Jpu1U8vX45Mp63u+cy4KCNs9/iTU7Pb UhFjaVVqvGOZimV0EpxPQ2TocFbHYPT5b6OtGUwFSfGjLS6OstxA0F6S9G54X3sXkBt4 SFcvYWHqXZVstu10HI+dOhWywUvmwKOqQ3Upv7+MQ/iXwDVraYvklzjfMrqJ+M+wBrfH D1+A== 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=6+qiJLEvyuiYORpTYpkszMQhGViiRl65Hb8NmS+Suao=; b=qxP81BXiGZMnp9HpXwd6FGS/L43jgJ3bhUWbf++jS1Iih76WdBUy4fa7z06CmaVHdy Im1yIlqHPH1GhTn8T4Qa56wrqiW74HJKrcodQiVNSDBRWmQXW9wI96clCm7/hFlVoiZq aWMldvlIjRn2D4QO/4+AP77bmPXUZto6FKNqwzoMI6SrnqZY0odpZQ0g+Ti2hmXv9dP3 4I/NcqkvsZO5hVnmEQqNjLQIeOUZ4T6CozC5q0VxFuGTbPcSC33yVYJ7KZj48dbMRf+p KGqOB6m+hOC+4KQrZX6uZNghMhgl8oYUGjaQs6Qt0rpnQ0WBFuJQmV2Zf4iXdwcZf6HA j44w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V8Nbw7mU; 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 w9si2340850otl.138.2019.12.11.20.12.14; Wed, 11 Dec 2019 20:12:14 -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=V8Nbw7mU; 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 S1727979AbfLLEMM (ORCPT + 27 others); Wed, 11 Dec 2019 23:12:12 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:37093 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727940AbfLLEMB (ORCPT ); Wed, 11 Dec 2019 23:12:01 -0500 Received: by mail-qk1-f195.google.com with SMTP id m188so538887qkc.4 for ; Wed, 11 Dec 2019 20:12:00 -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=6+qiJLEvyuiYORpTYpkszMQhGViiRl65Hb8NmS+Suao=; b=V8Nbw7mUeIrHldWS5nFNKfJdGB4qHiNdNTYjY1qvbgaYlBmG0UP0hXKMukl7iJK62b fjfc1gJpy19etdQ/JZT3fyGAtsxUbU0XX0mPd/nk9va0kJQYeKKb00xzx97uR1hVIpV9 9bgn7w19rtWoFDB0X31dshrVh4CoKiCAKpv2O36os/lhfzlT/cItx7TooXcr1s2D/LjQ ncDctb1dKp/bbB6hOPS0IWVuu7qzRRuBZTUedwFL9MaeyYSloYHKI/5yZtWjYfPOKDYg UtcTVIAdFUUeXcZqudRTw4C1g0a1y0vzzpmgd+a6Zs8/mOeP0jYgm8o23/8esdUvxxvP jACw== 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=6+qiJLEvyuiYORpTYpkszMQhGViiRl65Hb8NmS+Suao=; b=hsR6XwvS0FuS2EjtY1Wtg+W90AXaaUxgsW/ZdfdoEqD6Drh/bnitNZi/v215ZBD2PY UgjD/BynBhImD8jE8aZLaKFgFgpQaC26zL6g+AI0n9wKHwQjp2dUuNK85lDSO4ZWNRpD vZXDn5P0hZxHVpRmdLurplOSbNfUc1DmImdVvBkwao9HJPtsYR/w87uNL0qwtfO8SU0C yc9BpEKd/2L8ho2QTStyR+M8dZiyxfXZ7OSj+CnkZQkRXIoLxL64mWWNkOvVaeRuOOgK OVcmYRzkUEVdlD7IKWpmOjFUZVq/V7XunJPeP4N0xBcQKSachfynxY4gcZa2qc6k/mEF SJpg== X-Gm-Message-State: APjAAAWNg1CE9oEiPXO0K5zXYQqBPPs9fgviq9qnBdzRcIXMNhGiAnf3 pnugJwaKkZsKOjlhLKMGe2jmeQ== X-Received: by 2002:a37:a5d7:: with SMTP id o206mr6231110qke.227.1576123920124; Wed, 11 Dec 2019 20:12:00 -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 s11sm1364126qkg.99.2019.12.11.20.11.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 20:11:59 -0800 (PST) From: Thara Gopinath To: mingo@redhat.com, peterz@infradead.org, ionela.voinescu@arm.com, vincent.guittot@linaro.org, rui.zhang@intel.com, qperret@google.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, amit.kucheria@verdurent.com Subject: [Patch v6 7/7] sched/fair: Enable tuning of decay period Date: Wed, 11 Dec 2019 23:11:48 -0500 Message-Id: <1576123908-12105-8-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1576123908-12105-1-git-send-email-thara.gopinath@linaro.org> References: <1576123908-12105-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. v5->v6: - as per review comments introduced rq_clock_thermal to return clock shifted by the decay_shift. Documentation/admin-guide/kernel-parameters.txt | 5 ++++ kernel/sched/fair.c | 34 +++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index ade4e6e..ffe456d 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4330,6 +4330,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 between 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 4840655..9154cf8 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -86,6 +86,36 @@ static unsigned int normalized_sysctl_sched_wakeup_granularity = 1000000UL; const_debug unsigned int sysctl_sched_migration_cost = 500000UL; +/** + * 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 inline u64 rq_clock_thermal(struct rq *rq) +{ + return rq_clock_task(rq) >> sched_thermal_decay_shift; +} + +static int __init setup_sched_thermal_decay_shift(char *str) +{ + int _shift; + + if (kstrtoint(str, 0, &_shift)) + pr_warn("Unable to set scheduler thermal pressure decay shift parameter\n"); + + sched_thermal_decay_shift = clamp(_shift, 0, 10); + return 1; +} +__setup("sched_thermal_decay_shift=", setup_sched_thermal_decay_shift); + #ifdef CONFIG_SMP /* * For asym packing, by default the lower numbered CPU has higher priority. @@ -7501,7 +7531,7 @@ static bool __update_blocked_others(struct rq *rq, bool *done) decayed = update_rt_rq_load_avg(now, rq, curr_class == &rt_sched_class) | update_dl_rq_load_avg(now, rq, curr_class == &dl_sched_class) | - update_thermal_load_avg(rq_clock_task(rq), rq, + update_thermal_load_avg(rq_clock_thermal(rq), rq, thermal_pressure) | update_irq_load_avg(rq, 0); @@ -10288,7 +10318,7 @@ 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_thermal_load_avg(rq_clock_task(rq), rq, thermal_pressure); + update_thermal_load_avg(rq_clock_thermal(rq), rq, thermal_pressure); } /*