Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp100999ybg; Tue, 22 Oct 2019 16:54:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzuVx4XRvoGaVQmXYY7I8PO/Z+8ZsJeVZU/+tVsxcrpWLGlrJetbn2XB+0DJTkyZs6yGOs X-Received: by 2002:a17:906:6d87:: with SMTP id h7mr30513681ejt.4.1571788473874; Tue, 22 Oct 2019 16:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571788473; cv=none; d=google.com; s=arc-20160816; b=DjYKi4cW7Ou3/bkINELUwRMA7+NNx+ixuhg4H9MNncAeHh0JnHBxIO9JcbVjjjsXEY KOBZlmLBFWrvO7+JmI4Pcvc55gXCVuflsH4dsjD8K4gShpIpRkjdNd89d4EvMa4ibDAT 8RFrdAU2u5YXxYPr7cZnkOu/hpX3JfGY2WUS5QBaF/nF16+gO251tmOSmutP14EaGEYO 2DJHwODk9PKIrHu1OBe1cpPcShwbG+0XWFNqd40hXMmSJv32NFmjLSJEMDY0Q/3H1iXk B+31yFupzFJRqGIAGuVtrwk5lIOEHg/9SqHEnX5ZS7XyKS42y+9FQmHqFHKxpefLkBuT nUGg== 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=3iXJDm64yU5kPpIovC1LUxJgR4cu+K7/3XhEF8ojNLc=; b=0zWDEYFriKzjrRAOpNPi2+CpsXTMmmOz8XQiWFl1B4zng33IXz493D9KFtd9gOoI1c omKADU3OekG8O9DOcpoxSGHQ+U1jAf7WSVI6v26z13KJgXuWb5rTkcqAVpO6Lsa7KhZf 0mweaB9E6jmKCFOFcJuaF1Jvl/Z8JTTjszl0EirxnlTyBctI75qTquz6h22upsQTWQgD v/3FH4Me2y486LzSNNdmS6LXLfwwERc5hVGAb9Z/9QkxtUOzo6RRkkfFIE32dPeV+06Z 5Yzmu3XqsTh7lRabe/wjunUjWEqQL2llol6s4Dp8zus75Hpwukydf7+hTJlwynkzAeMb 1Kqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aH+I9Mrz; 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 13si15035748edw.357.2019.10.22.16.54.10; Tue, 22 Oct 2019 16:54:33 -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=aH+I9Mrz; 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 S2389367AbfJVUea (ORCPT + 99 others); Tue, 22 Oct 2019 16:34:30 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:34339 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389153AbfJVUea (ORCPT ); Tue, 22 Oct 2019 16:34:30 -0400 Received: by mail-qt1-f194.google.com with SMTP id e14so9093382qto.1 for ; Tue, 22 Oct 2019 13:34: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=3iXJDm64yU5kPpIovC1LUxJgR4cu+K7/3XhEF8ojNLc=; b=aH+I9MrzgLa6oPfEAQB10D3S98FO/VBm9pwwROVFp920m35baZz1f5Hf+WH2033EnT 3rgTmpl/aeitOy6UGm1KCCbhrkpZkzMWjFr9utusfa7rWS26TZUhJwrfezuAkR/ekk5V yD7nKdwuFmgM8c7eJTLtfUMT8/qwInrjuxstvExOqFCNQuJY6CoEe1ElI1aOQ2nta9zz 1yZ7W68BgH+Eh9aTFsQV0AEknM3ufkenjZ0ac0dY6INUrjNqalZVnX3BHyX92XA3362N uWJzfJa1OmAD638xyJ+v/dxURzQjMBcFez8gyCTRINAAaGm9eFRW11h0HrqrEuwJOtdf HYGQ== 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=3iXJDm64yU5kPpIovC1LUxJgR4cu+K7/3XhEF8ojNLc=; b=Z8/F0DUPXOuTjlQcBqd+Z8OFP2IWplu/A4nJ3dtaX8i1AOwQIG8WDH5SDkPh1QfNnx PRjRlaVKk3/3awF9swWWNOiCYcvqO5ZVkZdbHPoY/CF0T1Dh23ZJF3jhg50i+VExJ0oG 2fS0Zp6e+8v0skiY9IYxMvOxOgZoaAHLBPoMkeaOhMHivukhi/peCNBZB94/y6VpZSej R6W102gmssl3QdxtOQ987+zDTVTB/ZLNk7d+KQJP1s+6D2BBhSG2d90M3FHWAq1lxJTo 6Ckp0GSLGK3xaf97ubPi9gBiHHk5JUQVcTPExS0k+udJzCMcFmhlVkaRaT1j6CL0aIq2 cceQ== X-Gm-Message-State: APjAAAVw7PWxarp9GKCw26o/hCugty5XWybgcO9oNq1FTr039nrZsmvZ qjdHOeJkmuwE/2offrHaaNqOsMh+uh4= X-Received: by 2002:ac8:3849:: with SMTP id r9mr5365347qtb.370.1571776469099; Tue, 22 Oct 2019 13:34:29 -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 r126sm8895038qke.98.2019.10.22.13.34.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Oct 2019 13:34: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, qperret@google.com Cc: linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, javi.merino@kernel.org, daniel.lezcano@linaro.org Subject: [Patch v4 1/6] sched/pelt.c: Add support to track thermal pressure Date: Tue, 22 Oct 2019 16:34:20 -0400 Message-Id: <1571776465-29763-2-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1571776465-29763-1-git-send-email-thara.gopinath@linaro.org> References: <1571776465-29763-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extrapolating on the exisiting framework to track rt/dl utilization using pelt signals, add a similar mechanism to track thermal pressure. The difference here from rt/dl utilization tracking is that, instead of tracking time spent by a cpu running a rt/dl task through util_avg, the average thermal pressure is tracked through load_avg. This is because thermal pressure signal is weighted "delta" capacity and is not binary(util_avg is binary). "delta capacity" here means delta between the actual capacity of a cpu and the decreased capacity a cpu due to a thermal event. In order to track average thermal pressure, a new sched_avg variable avg_thermal is introduced. Function update_thermal_avg can be called to do the periodic bookeeping (accumulate, decay and average) of the thermal pressure. Signed-off-by: Thara Gopinath --- v3->v4: - Renamed update_thermal_avg to update_thermal_load_avg. - Fixed typos as per review comments on mailing list - Reordered the code as per review comments 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..3821069 100644 --- a/kernel/sched/pelt.c +++ b/kernel/sched/pelt.c @@ -353,6 +353,19 @@ int update_dl_rq_load_avg(u64 now, struct rq *rq, int running) return 0; } +int update_thermal_load_avg(u64 now, struct rq *rq, u64 capacity) +{ + if (___update_load_sum(now, &rq->avg_thermal, + capacity, + capacity, + capacity)) { + ___update_load_avg(&rq->avg_thermal, 1, 1); + return 1; + } + + return 0; +} + #ifdef CONFIG_HAVE_SCHED_AVG_IRQ /* * irq: diff --git a/kernel/sched/pelt.h b/kernel/sched/pelt.h index afff644..c74226d 100644 --- a/kernel/sched/pelt.h +++ b/kernel/sched/pelt.h @@ -6,6 +6,7 @@ int __update_load_avg_se(u64 now, struct cfs_rq *cfs_rq, struct sched_entity *se int __update_load_avg_cfs_rq(u64 now, struct cfs_rq *cfs_rq); int update_rt_rq_load_avg(u64 now, struct rq *rq, int running); int update_dl_rq_load_avg(u64 now, struct rq *rq, int running); +int update_thermal_load_avg(u64 now, struct rq *rq, u64 capacity); #ifdef CONFIG_HAVE_SCHED_AVG_IRQ int update_irq_load_avg(struct rq *rq, u64 running); @@ -159,6 +160,12 @@ update_dl_rq_load_avg(u64 now, struct rq *rq, int running) } static inline int +update_thermal_load_avg(u64 now, struct rq *rq, u64 capacity) +{ + return 0; +} + +static inline int update_irq_load_avg(struct rq *rq, u64 running) { return 0; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 0db2c1b..d5d82c8 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -944,6 +944,7 @@ struct rq { #ifdef CONFIG_HAVE_SCHED_AVG_IRQ struct sched_avg avg_irq; #endif + struct sched_avg avg_thermal; u64 idle_stamp; u64 avg_idle; -- 2.1.4