Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1029375ybh; Mon, 13 Jul 2020 07:35:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt3eXnf8hlIPm+uEIT+uxsvqr2RF3Otzr+B+MZbYBxDSFInDYsrjBPcRXH4UDbn9+FRKoM X-Received: by 2002:aa7:c90a:: with SMTP id b10mr62902864edt.71.1594650949447; Mon, 13 Jul 2020 07:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594650949; cv=none; d=google.com; s=arc-20160816; b=XPt+LlDy5JQw52MazXQpjeOyXRyqU1w/1OywoWfXfrDq7a0UOhc4wOfq9/SGl3Zkr0 CAIrbYdXWEd+uZo35j7ffyelSp1C8vfUC/4RzyWwF9vnfqmae/m3pztZjAfL1hfqWUGY 6Iuqalcuq5driulrSoiCA6o+eWGfUDhXFP9/749eRsQ57OUspqpSN0BXll17umjcMgYu SFDZp+Eb++PSzKvpS/uuQXavW9nfMvIkiIid0SSUt2COwSOouXs8EWUHJHUgOGGVnY4O zvzVg6p2sGHGC2gZPUlYomvlIUSHN7klPxRt1i+OQa+h/REa8IPO5h4O070CsinwMPn2 BxxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=JV7XujCjT0WQ4wkjALKmlW731iVG+iPdV0Rii6HipsE=; b=s3N7IzsL48+Dq3sUlLIroOLYFzoFxsHR3iesJbMnIpmrim5aKA5ZKTVIlOwC9k/pxx FwYgTfjaV1wHc2LsYBsimo3nnlvDn/yD85kg/WBCJRlYilAp16DyiDIBT316M3D+ERhv CtSqq9xTvtsqOlnpJxj00w/osHcowfz1F6hdLW19p/DN6cZZx+cyVGfcfpzI5DMB+7Md 7Z2NVGi3R/rgH5KbxN9tdNrCEVTvLRyJKU0g8irkuf8BJx8AqeqWEpxy/xI5bDBniGec ew9ebsZzBzzd3N4Bw3nHuyg9iCsyoUbHktzkGVTzhhZ9lb2pbD0C/2b6v5CNiNL2pKb6 122g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pa6pNCMC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id m10si8835773eja.377.2020.07.13.07.35.26; Mon, 13 Jul 2020 07:35:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pa6pNCMC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730049AbgGMOcv (ORCPT + 99 others); Mon, 13 Jul 2020 10:32:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729919AbgGMOcq (ORCPT ); Mon, 13 Jul 2020 10:32:46 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 188C9C061794 for ; Mon, 13 Jul 2020 07:32:46 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id x62so10078253qtd.3 for ; Mon, 13 Jul 2020 07:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=JV7XujCjT0WQ4wkjALKmlW731iVG+iPdV0Rii6HipsE=; b=pa6pNCMCjQQsJcn6JRnuQVsJuBE0YMkf8XHeoTrN40w24whIS3UehEHKsvoDinmJTt DBQ3YUhvghGYV60Xpb5xSXl2lDujV2jF6VxwOr/aDF76DRVCvd/1dCr8LbhoyVzYBV3L NAFlykQunvALJ8h2nY2Kd+5ozXlNYyFr2YhUax8lCIosdi8C5gdumEjELCyqJFXo6xTQ ciCmX5gM3wA8fGEja7vJdp+0XTSMxXi4wzsZPZmxax9hbegn+OdYOhrpF7BF9qG8WKCE Wj/eNmqlpb8hks0b+FK0gz8HdgFmhkEOnW4f1OjEqVAwuBj04gj3DQTwT/EswUOGex76 jTHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=JV7XujCjT0WQ4wkjALKmlW731iVG+iPdV0Rii6HipsE=; b=nE84cMbZG0SjNJLNQ6s6YM54LTt2y2Nh15mAZwhqPw2jesnkB2OjYZKzIjmdsIwtTi wk3VHmrV1mM2RYvPQDiHLZgvAnFcGgHIW2bfHgs36GT3IIElsvgpzK+ZeLdghEFpk6c4 lcZJc5iz4gl6oGzkzOTwaOrfznQJaz+9I7Fuw3Hi8rKCHI8+xp4Rq9kBMWzzVkh0rZ61 s1xGDWN2/jN7w9FiXFIQO+ECP60afjgwC0TQvau/SRzDVBvg3CHSS2jLMs9WqFyIGjDq chbtVNKQot/IvcBxge5SDFLhN09B2pQ3DVGAurnQZGASgWlvYbq3DTLQ2R0ck42njwR5 IlEw== X-Gm-Message-State: AOAM532nC+75Dv6XpxKzZfRljJS+SsErQA9Sn5i2b69dykgez8X4oXtr zbF7otFzrECZg7HpEz7H3tCfpQ== X-Received: by 2002:ac8:c4e:: with SMTP id l14mr70226000qti.106.1594650765164; Mon, 13 Jul 2020 07:32:45 -0700 (PDT) Received: from [192.168.1.92] (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.gmail.com with ESMTPSA id w18sm18516302qtn.3.2020.07.13.07.32.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jul 2020 07:32:43 -0700 (PDT) Subject: Re: [PATCH v2 1/3] arch_topology, sched/core: Cleanup thermal pressure definition To: Valentin Schneider , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Cc: Russell King , Sudeep Holla , Amit Daniel Kachhap , Daniel Lezcano , Viresh Kumar , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann References: <20200712165917.9168-1-valentin.schneider@arm.com> <20200712165917.9168-2-valentin.schneider@arm.com> From: Thara Gopinath Message-ID: <88488b17-fd01-76e6-ae53-027c1016340b@linaro.org> Date: Mon, 13 Jul 2020 10:32:42 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200712165917.9168-2-valentin.schneider@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/12/20 12:59 PM, Valentin Schneider wrote: > The following commit: > > 14533a16c46d ("thermal/cpu-cooling, sched/core: Move the arch_set_thermal_pressure() API to generic scheduler code") > > moved the definition of arch_set_thermal_pressure() to sched/core.c, but > kept its declaration in linux/arch_topology.h. When building e.g. an x86 > kernel with CONFIG_SCHED_THERMAL_PRESSURE=y, cpufreq_cooling.c ends up > getting the declaration of arch_set_thermal_pressure() from > include/linux/arch_topology.h, which is somewhat awkward. > > On top of this, sched/core.c unconditionally defines > o The thermal_pressure percpu variable > o arch_set_thermal_pressure() > > while arch_scale_thermal_pressure() does nothing unless redefined by the > architecture. > > arch_*() functions are meant to be defined by architectures, so revert the > aforementioned commit and re-implement it in a way that keeps > arch_set_thermal_pressure() architecture-definable, and doesn't define the > thermal pressure percpu variable for kernels that don't need > it (CONFIG_SCHED_THERMAL_PRESSURE=n). > > Signed-off-by: Valentin Schneider > --- Reviewed-by: Thara Gopinath > arch/arm/include/asm/topology.h | 3 ++- > arch/arm64/include/asm/topology.h | 3 ++- > drivers/base/arch_topology.c | 11 +++++++++++ > include/linux/arch_topology.h | 4 ++-- > include/linux/sched/topology.h | 7 +++++++ > kernel/sched/core.c | 11 ----------- > 6 files changed, 24 insertions(+), 15 deletions(-) > > diff --git a/arch/arm/include/asm/topology.h b/arch/arm/include/asm/topology.h > index 435aba289fc5..e0593cf095d0 100644 > --- a/arch/arm/include/asm/topology.h > +++ b/arch/arm/include/asm/topology.h > @@ -16,8 +16,9 @@ > /* Enable topology flag updates */ > #define arch_update_cpu_topology topology_update_cpu_topology > > -/* Replace task scheduler's default thermal pressure retrieve API */ > +/* Replace task scheduler's default thermal pressure API */ > #define arch_scale_thermal_pressure topology_get_thermal_pressure > +#define arch_set_thermal_pressure topology_set_thermal_pressure > > #else > > diff --git a/arch/arm64/include/asm/topology.h b/arch/arm64/include/asm/topology.h > index 0cc835ddfcd1..e042f6527981 100644 > --- a/arch/arm64/include/asm/topology.h > +++ b/arch/arm64/include/asm/topology.h > @@ -34,8 +34,9 @@ void topology_scale_freq_tick(void); > /* Enable topology flag updates */ > #define arch_update_cpu_topology topology_update_cpu_topology > > -/* Replace task scheduler's default thermal pressure retrieve API */ > +/* Replace task scheduler's default thermal pressure API */ > #define arch_scale_thermal_pressure topology_get_thermal_pressure > +#define arch_set_thermal_pressure topology_set_thermal_pressure > > #include > > diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c > index 4d0a0038b476..d14cab7dfa3c 100644 > --- a/drivers/base/arch_topology.c > +++ b/drivers/base/arch_topology.c > @@ -54,6 +54,17 @@ 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(const struct cpumask *cpus, > + unsigned long th_pressure) > +{ > + int cpu; > + > + for_each_cpu(cpu, cpus) > + WRITE_ONCE(per_cpu(thermal_pressure, cpu), th_pressure); > +} > + > 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 0566cb3314ef..69b1dabe39dc 100644 > --- a/include/linux/arch_topology.h > +++ b/include/linux/arch_topology.h > @@ -39,8 +39,8 @@ 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 th_pressure); > +void topology_set_thermal_pressure(const struct cpumask *cpus, > + unsigned long th_pressure); > > struct cpu_topology { > int thread_id; > diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h > index fb11091129b3..764222d637b7 100644 > --- a/include/linux/sched/topology.h > +++ b/include/linux/sched/topology.h > @@ -232,6 +232,13 @@ unsigned long arch_scale_thermal_pressure(int cpu) > } > #endif > > +#ifndef arch_set_thermal_pressure > +static __always_inline > +void arch_set_thermal_pressure(const struct cpumask *cpus, > + unsigned long th_pressure) > +{ } > +#endif > + > static inline int task_node(const struct task_struct *p) > { > return cpu_to_node(task_cpu(p)); > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index ff0519551188..90b44f3840e4 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -3731,17 +3731,6 @@ unsigned long long task_sched_runtime(struct task_struct *p) > return ns; > } > > -DEFINE_PER_CPU(unsigned long, thermal_pressure); > - > -void arch_set_thermal_pressure(struct cpumask *cpus, > - unsigned long th_pressure) > -{ > - int cpu; > - > - for_each_cpu(cpu, cpus) > - WRITE_ONCE(per_cpu(thermal_pressure, cpu), th_pressure); > -} > - > /* > * This function gets called by the timer code, with HZ frequency. > * We call it with interrupts disabled. > -- Warm Regards Thara