Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3937954ybp; Sun, 13 Oct 2019 18:01:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3G0SOA18l6Zorw0nOsqs3gn2AR9lGLFY03l0Fq1+xSFqnQcmeenlKZnwVsBIEOAV4y7pu X-Received: by 2002:a17:906:1342:: with SMTP id x2mr25981769ejb.304.1571014886356; Sun, 13 Oct 2019 18:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571014886; cv=none; d=google.com; s=arc-20160816; b=icwldJdpC0R6VNeb8WxTvEgZw6rtc6Lda/Y23LqC75VKAYlMuKDrPe+zfukgp6oKzW 9ZhKbLcF9hsDUDnpzw6nEtqe26dWtXGATjeWgCv2K3ysBFdGzQGBD6jmLCeATwm287JG xWf+CqMx+zSANy9ro+ZuQLwNmHTkZRPuXlIeQm/z3+sT9OmY7+gEYzR49PMf4eiAOYQ6 uidk8V5o5k6k4l29BgJxau8sPBEKpXkTv0yHb7RPU70Ci6j3155QuE/KFSyYpTGRUIKA v8+Dk4K/J97dEXXo5kVpVHOTHmTqafoNsuN/RrSZaMXXCCLvSEI7dupH9tL4f9XK89a9 +wpA== 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 a7si9962826ejy.131.2019.10.13.18.01.03; Sun, 13 Oct 2019 18:01:26 -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 S1729721AbfJNA6b (ORCPT + 99 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(+) 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; -- 2.1.4