Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp9037615ybl; Fri, 17 Jan 2020 05:24:18 -0800 (PST) X-Google-Smtp-Source: APXvYqzFBD8PUHXR8e062E/wxU7WxkAu/HUcQ8YB954466I/tlO1vI8/XD0EiEf+gTK1EkW1mkdo X-Received: by 2002:a05:6808:643:: with SMTP id z3mr3370295oih.19.1579267458466; Fri, 17 Jan 2020 05:24:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579267458; cv=none; d=google.com; s=arc-20160816; b=f0j1hvg81kG5tFfF9jahmFE/ByQKiQrwWDIoS8YQb22CW0OhGNVlWm7qvLd9jG1Aar u9+E4BlPoPHwfHts1VOrsJic0HYFQOdWn8MEEwi/bzcUGopxQoXTKL4qlq+Jt7iogQYR fEvcL3KZ4t+HemyBJjtsfOSln0sjQPLEKTd6dySuM/xmYfk0qT9JACFhA6OGsbAo7X5X XogxKuaicS9uLoBJr3xk+a0vonNj5m4icqC5HY04khrR7a9g/3gz92VJ5fSx4H9gx14h 7ggRzpxKaU/O5GloOId+Iq+FFbaT6oniodHc33i+vmAMZnbnOo6fNII1R2zrsRNFW7hS 438g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zllgq5fb58Nvx/kXIr9DmmFUIHHhMyq6w8QbHcZulRQ=; b=LZYPb2/F2s4AZJS2XPksspmggMBuR+u38WHKbPk/efJY19GZhB0Sm2pdFWxQ9qn7Q6 IwIEi2Uflg1sJxztKc+T1R6DsJe7cYkYbfpkBGE52YbALPqx03js92G0v4hXd8iFaogW o8ebj12Qdp3XIJy7Xx1wd4EdMbw3phZ3Zq79Iuzth6b/RErO0yrc3FDpkrG/IPsv8NIE olUtadpQpSbhppfudy3sOksCjg2R1t9D/meJWjT2WwI1iwp7nllOTYScgXUHRBm5ra3S yYh64tr5vAjnFA+AOYVf9DEAUfQu3lZvtTQ606GwVNEAyWCwsyJjm3rbEHQXvd//fpXX 3l/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hMru0rew; 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 h24si12561533oie.151.2020.01.17.05.24.05; Fri, 17 Jan 2020 05:24:18 -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=hMru0rew; 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 S1726936AbgAQNXF (ORCPT + 99 others); Fri, 17 Jan 2020 08:23:05 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35221 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726890AbgAQNXE (ORCPT ); Fri, 17 Jan 2020 08:23:04 -0500 Received: by mail-lf1-f66.google.com with SMTP id 15so18349547lfr.2 for ; Fri, 17 Jan 2020 05:23:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zllgq5fb58Nvx/kXIr9DmmFUIHHhMyq6w8QbHcZulRQ=; b=hMru0rew5W2r2jg2z4ygnA+2adJe2C3UGBlUiG/O7/HRX7zIyJEgSlO55dzdgBHDui Je/k52NLVRYzq168+P9XWOhVjZauQ60nQ2YEkPNkCNySjPHuvGUBk7gqbI4hUGjT1uUu RQvVHCH0tn2BN6QekeerisZKKPEM63JcTcTU9znAe3Pzh242vIp8qh94TknHX/2A5ZEZ ji9URHs8yTObVvPsrsrmRGGZM0syfHM86zaJxNtmELMYkcw/pmbTDIif6Ful1pEKqHm9 t1ilMST5RadIcRDMrL6+oVvXJVf+WKe4fGKpUGfalkEKzY82bb45RdQmX7FU44gADbaW Ys6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zllgq5fb58Nvx/kXIr9DmmFUIHHhMyq6w8QbHcZulRQ=; b=UIjOjlu42nUg8QEo4QJsagrAI8YBd+lAAS2JumVIHBb7ct22oppMECaNJG1mMPBbNr ou0KJS/G6JSrtG27WBC4SX/GtRcgf9Rck6Y3ueYtX+7+nEXLw2OTPRzrVlx2IFKUUaRM 8VFM6l8PW5oOoyIVgpg1yq6RozYfqX5E50GcnURut9mJkXVwKbBBqRm6Lh3Bv5oNVMVl 7w4jdC3nYbIGX1arWEAM7xUbeOevF+yi7ueUb5Kz99tOf+SFtkFgFdVJ+3hxhw7E3z90 YYLqRLjuyai6RjaP4oD1Uhn06MIb6MOmGt96rbrv6QEVbv9B8X4dPrA6Jjzx4NNuYEzI yAlA== X-Gm-Message-State: APjAAAU1N6V7K4eX2lHGT+1UByfVlIQZ6Mumth5lUywR7ZXi6258lRbT 4uqkDmtT/CO6LaAdSDOSL1RSvNph3R7/FFvHHOoylg== X-Received: by 2002:a19:114:: with SMTP id 20mr4907699lfb.25.1579267382341; Fri, 17 Jan 2020 05:23:02 -0800 (PST) MIME-Version: 1.0 References: <1579031859-18692-1-git-send-email-thara.gopinath@linaro.org> <1579031859-18692-5-git-send-email-thara.gopinath@linaro.org> <20200116151502.GQ2827@hirez.programming.kicks-ass.net> In-Reply-To: <20200116151502.GQ2827@hirez.programming.kicks-ass.net> From: Vincent Guittot Date: Fri, 17 Jan 2020 14:22:51 +0100 Message-ID: Subject: Re: [Patch v8 4/7] sched/fair: Enable periodic update of average thermal pressure To: Peter Zijlstra Cc: Thara Gopinath , Ingo Molnar , Ionela Voinescu , Dietmar Eggemann , Zhang Rui , Quentin Perret , Daniel Lezcano , viresh kumar , linux-kernel , Amit Kachhap , Javi Merino , Amit Kucheria Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 16 Jan 2020 at 16:15, Peter Zijlstra wrote: > > On Tue, Jan 14, 2020 at 02:57:36PM -0500, Thara Gopinath wrote: > > 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(+) > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index 8da0222..311bb0b 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -7470,6 +7470,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; > > + > > Given that struct sched_avg is 1 cacheline, the above is a pointless > guaranteed cacheline miss if the arch doesn't > CONFIG_HAVE_SCHED_THERMAL_PRESSURE. > > > #ifdef CONFIG_HAVE_SCHED_AVG_IRQ > > if (READ_ONCE(rq->avg_irq.util_avg)) > > return true; > > @@ -7495,6 +7498,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_cpu_thermal_pressure(cpu_of(rq)); > > bool decayed; > > > > /* > > @@ -7505,6 +7509,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)) > > That there indentation trainwreck is a reason to rename the function. > > 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); > > Is much better. > > But now that you made me look at that, I noticed it's using a different > clock -- it is _NOT_ using now/rq_clock_pelt(), which means it'll not be > in sync with the other averages. > > Is there a good reason for that? We don't need to apply frequency and cpu capacity invariance on the thermal capping signal which is what rq_clock_pelt does > > > @@ -10275,6 +10281,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_cpu_thermal_pressure(cpu_of(rq)); > > > > for_each_sched_entity(se) { > > cfs_rq = cfs_rq_of(se); > > @@ -10286,6 +10293,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); > > } > > I'm thinking this is the wrong place; should this not be in > scheduler_tick(), right before calling sched_class::task_tick() ? Surely > any execution will affect thermals, not only fair class execution.