Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp521975imm; Wed, 20 Jun 2018 02:10:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIYTDDXRRHDxLsv8AxnSvbwmW+LYwiyPFuB6KdWq4VXOghPw8lAPQKG+ZHvLkG7rXD9LKd1 X-Received: by 2002:a17:902:2f84:: with SMTP id t4-v6mr22816824plb.24.1529485853751; Wed, 20 Jun 2018 02:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529485853; cv=none; d=google.com; s=arc-20160816; b=oIxPyqvJuOS1tCTkkMF9MO7UlMOZznTau4/0RRQrfmU9yUKB4NMcfb72KBs3U+c1ze MAMMt0j4iC3p9bMevY3MahLg+a0W6j0VVfwM1baSO8aJ8VmQd4m4gjeYx248y5Sh3XmZ vmHg37jgM3y5PZuxAdyXn9XAD5hIAdMrevxKVd+wAsjT3xBoU6P4nKOp1I7PEZtJxvDD sHeHJMR3t/Wnn35tTPegWDznug4UqdXfFe7Et44sZ81HXjJUvl2Eygo44KUsW6xbeD8q 9paTfMHi/QEhe9sxOw8mFTMTtx9UyAKF0e4fEsaIqNR++qkHVwl+SR6gzLIhCGIVB1DM wj+A== 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:arc-authentication-results; bh=dhtTytGpzOPG1Qbwmvkfm6l5+wW3R+yGEU3EyPoeUio=; b=WfHOXJGLKjq2XhuO+fLww3/Mvcrrmz4Xsbd5adQmbja/sHLbxYTrmREQpYzTadJbsa DPg8T98YLIOcvfjIZmTpPj1lLDEyNQ3QM/q8w1pb/tPjZhf5detHHku+8VTgrD6ELmDP re/w7nvKH5Zi3oUZXPGZ0aTMtBX6kTKtSmSI5pBVIVA8u2PPhLjQqLnudvfDO9LMxf9n S9EJKb1kXzAXxk1/1NMinbideSi7hRGEkF+eqKqQjWPeEZucc1hznGUvqNBSj9KcA1ZC Kpc1Fhxk+sckrGJ+QcopfykpaVeyo4YBDgAG5J2PDQavcxKaB5R9xuzOfSgyAf0dZuWz o89A== 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 v28-v6si1624579pgc.531.2018.06.20.02.10.39; Wed, 20 Jun 2018 02:10:53 -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 S1754652AbeFTJGn (ORCPT + 99 others); Wed, 20 Jun 2018 05:06:43 -0400 Received: from foss.arm.com ([217.140.101.70]:33954 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752595AbeFTJGk (ORCPT ); Wed, 20 Jun 2018 05:06:40 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3C0A215AB; Wed, 20 Jun 2018 02:06:40 -0700 (PDT) Received: from e105550-lin.cambridge.arm.com (e105550-lin.cambridge.arm.com [10.1.211.30]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B98313F246; Wed, 20 Jun 2018 02:06:38 -0700 (PDT) From: Morten Rasmussen To: peterz@infradead.org, mingo@redhat.com Cc: valentin.schneider@arm.com, dietmar.eggemann@arm.com, vincent.guittot@linaro.org, gaku.inami.xh@renesas.com, linux-kernel@vger.kernel.org, Morten Rasmussen Subject: [PATCHv3 1/9] sched: Add static_key for asymmetric cpu capacity optimizations Date: Wed, 20 Jun 2018 10:05:41 +0100 Message-Id: <1529485549-5191-2-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529485549-5191-1-git-send-email-morten.rasmussen@arm.com> References: <1529485549-5191-1-git-send-email-morten.rasmussen@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The existing asymmetric cpu capacity code should cause minimal overhead for others. Putting it behind a static_key, it has been done for SMT optimizations, would make it easier to extend and improve without causing harm to others moving forward. cc: Ingo Molnar cc: Peter Zijlstra Signed-off-by: Morten Rasmussen --- kernel/sched/fair.c | 3 +++ kernel/sched/sched.h | 1 + kernel/sched/topology.c | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e497c05aab7f..6116d1b7e441 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6585,6 +6585,9 @@ static int wake_cap(struct task_struct *p, int cpu, int prev_cpu) { long min_cap, max_cap; + if (!static_branch_unlikely(&sched_asym_cpucapacity)) + return 0; + min_cap = min(capacity_orig_of(prev_cpu), capacity_orig_of(cpu)); max_cap = cpu_rq(cpu)->rd->max_cpu_capacity; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 67702b4d9ac7..0fbfbcf5c551 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1153,6 +1153,7 @@ DECLARE_PER_CPU(int, sd_llc_id); DECLARE_PER_CPU(struct sched_domain_shared *, sd_llc_shared); DECLARE_PER_CPU(struct sched_domain *, sd_numa); DECLARE_PER_CPU(struct sched_domain *, sd_asym); +extern struct static_key_false sched_asym_cpucapacity; struct sched_group_capacity { atomic_t ref; diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 61a1125c1ae4..edc87e35fc75 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -398,6 +398,7 @@ DEFINE_PER_CPU(int, sd_llc_id); DEFINE_PER_CPU(struct sched_domain_shared *, sd_llc_shared); DEFINE_PER_CPU(struct sched_domain *, sd_numa); DEFINE_PER_CPU(struct sched_domain *, sd_asym); +DEFINE_STATIC_KEY_FALSE(sched_asym_cpucapacity); static void update_top_cache_domain(int cpu) { @@ -425,6 +426,21 @@ static void update_top_cache_domain(int cpu) rcu_assign_pointer(per_cpu(sd_asym, cpu), sd); } +static void update_asym_cpucapacity(int cpu) +{ + int enable = false; + + rcu_read_lock(); + if (lowest_flag_domain(cpu, SD_ASYM_CPUCAPACITY)) + enable = true; + rcu_read_unlock(); + + if (enable) { + /* This expects to be hotplug-safe */ + static_branch_enable_cpuslocked(&sched_asym_cpucapacity); + } +} + /* * Attach the domain 'sd' to 'cpu' as its base domain. Callers must * hold the hotplug lock. @@ -1707,6 +1723,8 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att } rcu_read_unlock(); + update_asym_cpucapacity(cpumask_first(cpu_map)); + if (rq && sched_debug_enabled) { pr_info("root domain span: %*pbl (max cpu_capacity = %lu)\n", cpumask_pr_args(cpu_map), rq->rd->max_cpu_capacity); -- 2.7.4