From patchwork Tue Oct 9 16:24:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 148516 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp5110310lji; Tue, 9 Oct 2018 09:25:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV61REO7NSpKNwwLZ3uI1W5ZyZ/grwBWjzivj3EGdyQfPvOPrd/aBGODCZskAmZHDceu3oVBO X-Received: by 2002:a63:6111:: with SMTP id v17-v6mr25909962pgb.226.1539102348467; Tue, 09 Oct 2018 09:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539102348; cv=none; d=google.com; s=arc-20160816; b=0H1SuFvHuctgQiqeM8pdnPqO86BAvYuksZK9gJs8vlG+xLK4RDlWz4K80sdPVw6g7p QxP+aLwv5Fjeln27b+xOInN7wCcOu5x51P85JQOSWcRJxc48d219XJh8FTooOii+np30 bD82EobCzQiRaBTEeQ7eTdFR9att4n9xNMnOlG+gnPZPa7OxyiQxXFXwO0DRzAwsRm+R QRXxFKZBocLV+2/swrhpgTRixT2V02MP5fDuEdFuKxsb3QYFV7YPWR9AXMbiXHROlWn8 DMbl2LqHss0E1SGEdYnserBSHHW2V6zTBLwewXLwzJICKn3xoqC3IPhBfa3zFaRUtZE4 D0Ig== 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=qbCXCRSOePNWlZULbLaHD5z+rbdqCdhX0BsGRnKqI98=; b=BLp8Znb5peWE+jbZ7p222LoEHImz4j8tpkGxW1bC316NWXJNPRvZSA5C77VWKriIFd Q0UwM2gYOaSyaPbuLyOBIzxz36a3Ou6eqAEBWU6SOpdZz8sOCQJv9nhC2qnUWy7Kxchc ldt5cGy2kQ+H7S6J3M/sXFdpUn35YZ/XTqjegAZpBSMeZap3RLYzugu/TSWRVtc84/qW NxmUZkPpiAtaawhTe66a9QeyIPpxNz32mYwonYinp3SjGaRdyePRbXAVcOWPxzsXKjnk xIAHpX24L9aCVKSm0d/Z6L2OBXS5u0kUCu4lAMQKq0Y26ImsXN5gx77JzrJ7BzWYbewI tQsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wf0ys7uZ; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 23-v6si19747716pge.453.2018.10.09.09.25.48; Tue, 09 Oct 2018 09:25:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=Wf0ys7uZ; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1726548AbeJIXmy (ORCPT + 10 others); Tue, 9 Oct 2018 19:42:54 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:44753 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727028AbeJIXmw (ORCPT ); Tue, 9 Oct 2018 19:42:52 -0400 Received: by mail-qt1-f193.google.com with SMTP id c56-v6so2270917qtd.11 for ; Tue, 09 Oct 2018 09:25:09 -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=qbCXCRSOePNWlZULbLaHD5z+rbdqCdhX0BsGRnKqI98=; b=Wf0ys7uZUptTZHdHTnhf5tZpd1u4BVhNoa1dMrTUTehXQMI5widEclWXpmET2J/UUi ARuy7IAJwYHViB65i4fUg3atGzJCISXwL41NA69Ez8RJSEKWYZ2J4+dM0jo1Qve39upJ MpuyjDSN/TOVTQQ6IUmaj/c2KXnifFczKDCCs= 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=qbCXCRSOePNWlZULbLaHD5z+rbdqCdhX0BsGRnKqI98=; b=bzXD7Tqdyi/Vav2aY7HbP0tPm2krp7pTKDWLbOytZyRXHgPzxQQ//2JNZZm3rjdElD 6n4Waqk9mxMMIFjS7hEu1iTIb7pWqject7WjX8kHpa2y7BkDQ7atOMVOR8cmBCzldZXW qBzb4Ax5mFyhsQdK21/AqGOt2AaKC6zugXXp695Fte3qFxTQ41YYci3nBiCNPlC05y3f B2Y2SOcCwq59BE81cD1B5qG1s0L33THubTFA1VI0Cv5Sz75Ks0WtDS5zy0ZtXUeFFXHx xEULL7Y0BPJb0ohlF6OOHp16BnWsuA01d6vwgktA5YUjtXgYdyH/wvoJ2p/dXULdAvZL MgzQ== X-Gm-Message-State: ABuFfojdB0HbrMOZ2UG1IgvA6u3xJlEu0ZxHWHmUbTojSmPPzKiPE7xo o5dlku8ohKeuLAEE4AeYPrsS6A== X-Received: by 2002:a0c:d285:: with SMTP id q5mr6920778qvh.46.1539102308545; Tue, 09 Oct 2018 09:25:08 -0700 (PDT) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-245-97.washdc.fios.verizon.net. [71.255.245.97]) by smtp.googlemail.com with ESMTPSA id o7-v6sm10441169qkc.67.2018.10.09.09.25.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Oct 2018 09:25:07 -0700 (PDT) From: Thara Gopinath To: linux-kernel@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, rui.zhang@intel.com Cc: gregkh@linuxfoundation.org, rafael@kernel.org, amit.kachhap@gmail.com, viresh.kumar@linaro.org, javi.merino@kernel.org, edubezval@gmail.com, daniel.lezcano@linaro.org, linux-pm@vger.kernel.org, quentin.perret@arm.com, ionela.voinescu@arm.com, vincent.guittot@linaro.org Subject: [RFC PATCH 2/7] sched/pelt.c: Add support to track thermal pressure Date: Tue, 9 Oct 2018 12:24:57 -0400 Message-Id: <1539102302-9057-3-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1539102302-9057-1-git-send-email-thara.gopinath@linaro.org> References: <1539102302-9057-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 | 14 ++++++++++++++ kernel/sched/pelt.h | 7 +++++++ kernel/sched/sched.h | 1 + 3 files changed, 22 insertions(+) -- 2.1.4 diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c index 05b8798..7034ede 100644 --- a/kernel/sched/pelt.c +++ b/kernel/sched/pelt.c @@ -362,6 +362,20 @@ 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->cpu, &rq->avg_thermal, + capacity, + capacity, + capacity, 0)) { + + ___update_load_avg(&rq->avg_thermal, 1, 1); + return 1; + } + + return 0; +} + #if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING) /* * irq: diff --git a/kernel/sched/pelt.h b/kernel/sched/pelt.h index d2894db..cc5a3ad 100644 --- a/kernel/sched/pelt.h +++ b/kernel/sched/pelt.h @@ -5,6 +5,7 @@ int __update_load_avg_se(u64 now, int cpu, struct cfs_rq *cfs_rq, struct sched_e int __update_load_avg_cfs_rq(u64 now, int cpu, 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); #if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING) int update_irq_load_avg(struct rq *rq, u64 running); @@ -67,6 +68,12 @@ update_irq_load_avg(struct rq *rq, u64 running) { return 0; } + +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 4a2e8ca..30b40a5 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -859,6 +859,7 @@ struct rq { #define HAVE_SCHED_AVG_IRQ struct sched_avg avg_irq; #endif + struct sched_avg avg_thermal; u64 idle_stamp; u64 avg_idle;