Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4683041ybg; Tue, 29 Oct 2019 10:49:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqy86GLSojftl4DiJ5ybHifjEMNF+YiFdi9kjFWXCO09PUAHKSDaMyz5a+W+Cn+vtBjyY6QU X-Received: by 2002:aa7:cd79:: with SMTP id ca25mr27500880edb.33.1572371340639; Tue, 29 Oct 2019 10:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572371340; cv=none; d=google.com; s=arc-20160816; b=l2DTVLO0RJmzc0sEJY3iF9GM/SBvIrAKJWiZCI7v3tAmMwNCxhPBbmsMLHksUYOe3A INLVL5rOV5Wiv5ighZnSc4GKLTLMNyzJKSGl4zovRsRvUciGqJhwLposl0+qremDuNL/ SxTp37DNDGEH/y6c9AFcDZZIBLASWqqo1W77s2Hwz4XgQy05U5ZPeh9UEJVLBXeR/orm 8EuwmsAGsLawqFMbFQSjali+NTvO9fPVAo60smUSScakoWolv4yQWzy0YqaZEJub5GVT WbhOuOk6XGm48Qy5KcIWUzcVpNL3oHLZyjBCK731dmVSyfAu4HSfpDwxW9esvGR/+osr pHlg== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=CH49Zf4ZwjJVNYn4m0ya388lmoGoFosj5K1kDia9VMw=; b=yFV3vzyZWCQHVptszroEPEZqUzOqgtIG78CLdJTjYgaxmfvfRXNJ5sTA3gXGMqzdup u1T3PDGxj5FPebYqq19qYykGJ/EA0aoCSEGQLtbEGAf+pa5aJsI4azLrtttIUw6MpE7T b+QsaAqnVI/F8eRpN4dvzjmtVsRBrJncbuh4ncuTU1Nfgw141UOiak/xqqhpFmUhWU2F K77u8l65CEipz3EzrupdgsqV+K6+J+UT82dqrr4OAfAe5NDq1iOeU1vIwg6J2siF2zua 571tYtl185qGWXRx40I7u4Aqg8xETcWOXm1xBOTBiokSKWTlj3ze7jNYY9/5yMmdTIOT MTxA== 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 w7si2048385edj.96.2019.10.29.10.48.37; Tue, 29 Oct 2019 10:49:00 -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 S1730047AbfJ2Jwc (ORCPT + 99 others); Tue, 29 Oct 2019 05:52:32 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:47732 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726912AbfJ2Jwb (ORCPT ); Tue, 29 Oct 2019 05:52:31 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iPOAk-0004M9-Aq; Tue, 29 Oct 2019 10:52:18 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 9B4B81C0073; Tue, 29 Oct 2019 10:52:17 +0100 (CET) Date: Tue, 29 Oct 2019 09:52:17 -0000 From: "tip-bot2 for Valentin Schneider" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/topology: Allow sched_asym_cpucapacity to be disabled Cc: Valentin Schneider , "Peter Zijlstra (Intel)" , Dietmar Eggemann , Dietmar.Eggemann@arm.com, Linus Torvalds , Thomas Gleixner , hannes@cmpxchg.org, lizefan@huawei.com, morten.rasmussen@arm.com, qperret@google.com, tj@kernel.org, vincent.guittot@linaro.org, Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <20191023153745.19515-3-valentin.schneider@arm.com> References: <20191023153745.19515-3-valentin.schneider@arm.com> MIME-Version: 1.0 Message-ID: <157234273730.29376.11861956477066450978.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/urgent branch of tip: Commit-ID: e284df705cf1eeedb5ec3a66ed82d17a64659150 Gitweb: https://git.kernel.org/tip/e284df705cf1eeedb5ec3a66ed82d17a64659150 Author: Valentin Schneider AuthorDate: Wed, 23 Oct 2019 16:37:45 +01:00 Committer: Ingo Molnar CommitterDate: Tue, 29 Oct 2019 09:58:46 +01:00 sched/topology: Allow sched_asym_cpucapacity to be disabled While the static key is correctly initialized as being disabled, it will remain forever enabled once turned on. This means that if we start with an asymmetric system and hotplug out enough CPUs to end up with an SMP system, the static key will remain set - which is obviously wrong. We should detect this and turn off things like misfit migration and capacity aware wakeups. As Quentin pointed out, having separate root domains makes this slightly trickier. We could have exclusive cpusets that create an SMP island - IOW, the domains within this root domain will not see any asymmetry. This means we can't just disable the key on domain destruction, we need to count how many asymmetric root domains we have. Consider the following example using Juno r0 which is 2+4 big.LITTLE, where two identical cpusets are created: they both span both big and LITTLE CPUs: asym0 asym1 [ ][ ] L L B L L B $ cgcreate -g cpuset:asym0 $ cgset -r cpuset.cpus=0,1,3 asym0 $ cgset -r cpuset.mems=0 asym0 $ cgset -r cpuset.cpu_exclusive=1 asym0 $ cgcreate -g cpuset:asym1 $ cgset -r cpuset.cpus=2,4,5 asym1 $ cgset -r cpuset.mems=0 asym1 $ cgset -r cpuset.cpu_exclusive=1 asym1 $ cgset -r cpuset.sched_load_balance=0 . (the CPU numbering may look odd because on the Juno LITTLEs are CPUs 0,3-5 and bigs are CPUs 1-2) If we make one of those SMP (IOW remove asymmetry) by e.g. hotplugging its big core, we would end up with an SMP cpuset and an asymmetric cpuset - the static key must remain set, because we still have one asymmetric root domain. With the above example, this could be done with: $ echo 0 > /sys/devices/system/cpu/cpu2/online Which would result in: asym0 asym1 [ ][ ] L L B L L When both SMP and asymmetric cpusets are present, all CPUs will observe sched_asym_cpucapacity being set (it is system-wide), but not all CPUs observe asymmetry in their sched domain hierarchy: per_cpu(sd_asym_cpucapacity, ) == per_cpu(sd_asym_cpucapacity, ) == NULL Change the simple key enablement to an increment, and decrement the key counter when destroying domains that cover asymmetric CPUs. Signed-off-by: Valentin Schneider Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Dietmar Eggemann Cc: Dietmar.Eggemann@arm.com Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: hannes@cmpxchg.org Cc: lizefan@huawei.com Cc: morten.rasmussen@arm.com Cc: qperret@google.com Cc: tj@kernel.org Cc: vincent.guittot@linaro.org Fixes: df054e8445a4 ("sched/topology: Add static_key for asymmetric CPU capacity optimizations") Link: https://lkml.kernel.org/r/20191023153745.19515-3-valentin.schneider@arm.com Signed-off-by: Ingo Molnar --- kernel/sched/topology.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 9318acf..49b835f 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -2029,7 +2029,7 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att rcu_read_unlock(); if (has_asym) - static_branch_enable_cpuslocked(&sched_asym_cpucapacity); + static_branch_inc_cpuslocked(&sched_asym_cpucapacity); if (rq && sched_debug_enabled) { pr_info("root domain span: %*pbl (max cpu_capacity = %lu)\n", @@ -2124,8 +2124,12 @@ int sched_init_domains(const struct cpumask *cpu_map) */ static void detach_destroy_domains(const struct cpumask *cpu_map) { + unsigned int cpu = cpumask_any(cpu_map); int i; + if (rcu_access_pointer(per_cpu(sd_asym_cpucapacity, cpu))) + static_branch_dec_cpuslocked(&sched_asym_cpucapacity); + rcu_read_lock(); for_each_cpu(i, cpu_map) cpu_attach_domain(NULL, &def_root_domain, i);