Received: by 10.213.65.68 with SMTP id h4csp1418imn; Thu, 15 Mar 2018 07:51:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELvj6gFEJ7Rk43dSHZ4yCkMDkqGl4gAJzQbFZHLEMIaAyspw8jloEzINZDaYLwj7+VE+3d3q X-Received: by 2002:a17:902:8f97:: with SMTP id z23-v6mr8453799plo.162.1521125517934; Thu, 15 Mar 2018 07:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521125517; cv=none; d=google.com; s=arc-20160816; b=gKL6y9L6+T3iaH/+sDmIWDBIw7TKJ9SzF+ZFt0ImXxLKFFJJLui5deidB+F+IlJnD8 Aqi52HMdM4Y/GZOL/IBWoLkTY8Vlneb7yAHoIlchpi35fPaW1j/uUYet6dzvH3r0twht AhQtCy/NE1AB9i7MMuie2NJWf9p+TjmLv6aUW4ExZ95wNrg3FGQKbXglMt+S2qBt3gFC 3QRvoOJpS1fcJxfQoOWQnzngXHUOskog1vgVf/zx/w0GjuIl4YQ8GH56knR3ZiudGjVn bdNpwiOJUFQWljIuGitZHOqOhAWcpOxW6oBkgLn8BHCGwbCbZsUw5rG87LFBUtzJ9nGo 8Z7Q== 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=mXhmEQ0XAG3L6f06LaK5SX9KKyKrl18PiH2cR30qkN4=; b=E9izmNGykk8UxG4lBcwfJDmui5V6eJDM2Ne4zTtU+Ya6Q6JGGR4Ep/uD9p0ewkIHYa oJvHPLOx9FAj7cBE19+sqVl/3yO8cFGihTmTPbHISFUGiH5PRleGKePlHogEymALWfIi EFwLmHL35U/CPiAerChSbhbslQfS8wI9/Lxfecp29nednpJz9W0O9tWm4kb8kZI9NTnr Ffv8yIr4+olDOzwiu0BfIw6KxG657IJSR54airQOE9BHbc9LmXjxD08yf45/E888D0Lk WT7dk6kRADLc4MAAULrKaLlDdeplPLk+95PbwW4ZXwTUvZD760ri1YhXV5APVQcmo8XY j/zQ== 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 p68si601066pga.37.2018.03.15.07.51.31; Thu, 15 Mar 2018 07:51:57 -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 S1752647AbeCOOr1 (ORCPT + 99 others); Thu, 15 Mar 2018 10:47:27 -0400 Received: from foss.arm.com ([217.140.101.70]:40002 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932388AbeCOOr0 (ORCPT ); Thu, 15 Mar 2018 10:47:26 -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 CB1BC15AD; Thu, 15 Mar 2018 07:47:25 -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 515DA3F487; Thu, 15 Mar 2018 07:47:24 -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: [PATCHv2 1/7] sched: Add static_key for asymmetric cpu capacity optimizations Date: Thu, 15 Mar 2018 14:46:58 +0000 Message-Id: <1521125224-15434-2-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521125224-15434-1-git-send-email-morten.rasmussen@arm.com> References: <1521125224-15434-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 | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 3582117e1580..e4ce572113a9 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6385,6 +6385,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 22909ffc04fb..017f62069e0b 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1140,6 +1140,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 64cc564f5255..b023a5b3665a 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,12 @@ static void update_top_cache_domain(int cpu) rcu_assign_pointer(per_cpu(sd_asym, cpu), sd); } +static void update_asym_cpucapacity(int cpu) +{ + if (lowest_flag_domain(cpu, SD_ASYM_CPUCAPACITY)) + static_branch_enable(&sched_asym_cpucapacity); +} + /* * Attach the domain 'sd' to 'cpu' as its base domain. Callers must * hold the hotplug lock. @@ -1705,6 +1712,8 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att cpu_attach_domain(sd, d.rd, i); } + + update_asym_cpucapacity(cpumask_first(cpu_map)); rcu_read_unlock(); if (rq && sched_debug_enabled) { -- 2.7.4