Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2566318imm; Mon, 10 Sep 2018 03:13:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZwwRbWjTnmUZi3A5fh+fnuqZOVsPFJdH28Fk3G6DDJb9YQmebYAHNaKZoFSUl9FoBcclPw X-Received: by 2002:a17:902:9302:: with SMTP id bc2-v6mr21326961plb.280.1536574406597; Mon, 10 Sep 2018 03:13:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536574406; cv=none; d=google.com; s=arc-20160816; b=x/sST8Cu4dv+20jChlQRN4AG75DpL35rOZBR+3YEGvA0LWIoaHnDrPDF7J30oSAp+U vqZruzEYtnipvICBNRDq3I88lsutajy6VJT8cAGbjMdXm5EAzPrB4UYIV9wxUEmosblw WLUafYoBCXA/yvYp3GjxeSgizZqP2OnTh1Rs0ZK48RAAEKc8EAKjw0JvIULG/g1QXrp2 GDASdxfCo4CbeutSG+LirnsZOSplhcaSDMjOi8rs8B26MfWMNIXZzYVCU8uAq8VYTwBb Qk9snf9sd1u1C1rXj7yVJ7H02TwZgwX7yqaqIAO9iTK0VFXiUbVJc5f5UrW5xbbEBaXO MwJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=xfj2vrEvRKo+SBr+fAAB5yYB2IntkDyNsl7ro4Md6xA=; b=WEtAOHL7Y7hKNne+AkxbEqNzwa3V3OuUkBCO/npgr+9n8qlEoaIQ4baw3hX2MvnfNk 7IM48YUccIG9xI00de3iFjIl10e14F2MGgiH4OEjHiuDmtz+kdE97B57XQ0b0/29dWLt SDsptndZyQq1QfK0YyvolJYEOf1jO6bmPsXKEk3YoTvb+ecVhgxi+WlkFA69vZ6oWkNq sM+BLK/nRvWJY/YOf131+QrzAosjp1BDX+andnMyZJJkJ9Qkbbqin8gklEc0wqtkeuxe Gc5xIZcea5S9bZr2wLaLelKnMnKKWwJZVHFblJ1UVsPMv4wOQFCya7y0W0Nh5my+CxFn 53rA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e10-v6si18057827pgl.554.2018.09.10.03.13.11; Mon, 10 Sep 2018 03:13: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728226AbeIJPFV (ORCPT + 99 others); Mon, 10 Sep 2018 11:05:21 -0400 Received: from terminus.zytor.com ([198.137.202.136]:55481 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727614AbeIJPFV (ORCPT ); Mon, 10 Sep 2018 11:05:21 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w8AABe6r1807509 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 10 Sep 2018 03:11:40 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w8AABeT71807506; Mon, 10 Sep 2018 03:11:40 -0700 Date: Mon, 10 Sep 2018 03:11:40 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Morten Rasmussen Message-ID: Cc: hpa@zytor.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, mingo@kernel.org, morten.rasmussen@arm.com, tglx@linutronix.de, gregkh@linuxfoundation.org, peterz@infradead.org Reply-To: torvalds@linux-foundation.org, hpa@zytor.com, mingo@kernel.org, linux-kernel@vger.kernel.org, morten.rasmussen@arm.com, peterz@infradead.org, tglx@linutronix.de, gregkh@linuxfoundation.org In-Reply-To: <1532093554-30504-3-git-send-email-morten.rasmussen@arm.com> References: <1532093554-30504-3-git-send-email-morten.rasmussen@arm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/topology, drivers/base/arch_topology: Rebuild the sched_domain hierarchy when capacities change Git-Commit-ID: bb1fbdd3c3fd12b612c7d8cdf13bd6bfeebdefa3 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: bb1fbdd3c3fd12b612c7d8cdf13bd6bfeebdefa3 Gitweb: https://git.kernel.org/tip/bb1fbdd3c3fd12b612c7d8cdf13bd6bfeebdefa3 Author: Morten Rasmussen AuthorDate: Fri, 20 Jul 2018 14:32:32 +0100 Committer: Ingo Molnar CommitDate: Mon, 10 Sep 2018 11:05:47 +0200 sched/topology, drivers/base/arch_topology: Rebuild the sched_domain hierarchy when capacities change The setting of SD_ASYM_CPUCAPACITY depends on the per-CPU capacities. These might not have their final values when the hierarchy is initially built as the values depend on cpufreq to be initialized or the values being set through sysfs. To ensure that the flags are set correctly we need to rebuild the sched_domain hierarchy whenever the reported per-CPU capacity (arch_scale_cpu_capacity()) changes. This patch ensure that a full sched_domain rebuild happens when CPU capacity changes occur. Signed-off-by: Morten Rasmussen Signed-off-by: Peter Zijlstra (Intel) Cc: Greg Kroah-Hartman Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: dietmar.eggemann@arm.com Cc: valentin.schneider@arm.com Cc: vincent.guittot@linaro.org Link: http://lkml.kernel.org/r/1532093554-30504-3-git-send-email-morten.rasmussen@arm.com Signed-off-by: Ingo Molnar --- drivers/base/arch_topology.c | 26 ++++++++++++++++++++++++++ include/linux/arch_topology.h | 1 + 2 files changed, 27 insertions(+) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index e7cb0c6ade81..edfcf8d982e4 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -15,6 +15,7 @@ #include #include #include +#include DEFINE_PER_CPU(unsigned long, freq_scale) = SCHED_CAPACITY_SCALE; @@ -47,6 +48,9 @@ static ssize_t cpu_capacity_show(struct device *dev, return sprintf(buf, "%lu\n", topology_get_cpu_scale(NULL, cpu->dev.id)); } +static void update_topology_flags_workfn(struct work_struct *work); +static DECLARE_WORK(update_topology_flags_work, update_topology_flags_workfn); + static ssize_t cpu_capacity_store(struct device *dev, struct device_attribute *attr, const char *buf, @@ -72,6 +76,8 @@ static ssize_t cpu_capacity_store(struct device *dev, topology_set_cpu_scale(i, new_capacity); mutex_unlock(&cpu_scale_mutex); + schedule_work(&update_topology_flags_work); + return count; } @@ -96,6 +102,25 @@ static int register_cpu_capacity_sysctl(void) } subsys_initcall(register_cpu_capacity_sysctl); +static int update_topology; + +int topology_update_cpu_topology(void) +{ + return update_topology; +} + +/* + * Updating the sched_domains can't be done directly from cpufreq callbacks + * due to locking, so queue the work for later. + */ +static void update_topology_flags_workfn(struct work_struct *work) +{ + update_topology = 1; + rebuild_sched_domains(); + pr_debug("sched_domain hierarchy rebuilt, flags updated\n"); + update_topology = 0; +} + static u32 capacity_scale; static u32 *raw_capacity; @@ -201,6 +226,7 @@ init_cpu_capacity_callback(struct notifier_block *nb, if (cpumask_empty(cpus_to_visit)) { topology_normalize_cpu_scale(); + schedule_work(&update_topology_flags_work); free_raw_capacity(); pr_debug("cpu_capacity: parsing done\n"); schedule_work(&parsing_done_work); diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h index 2b709416de05..d9bdc1a7f4e7 100644 --- a/include/linux/arch_topology.h +++ b/include/linux/arch_topology.h @@ -9,6 +9,7 @@ #include void topology_normalize_cpu_scale(void); +int topology_update_cpu_topology(void); struct device_node; bool topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu);