Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4999066imm; Tue, 31 Jul 2018 04:00:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeDecQj+3GzIPHFRryoiV1+l/P9BjSPZDGKNRYBQnJmIF/7E/ScCA1SZlsVBEVwO6PzmXW4 X-Received: by 2002:a17:902:b28c:: with SMTP id u12-v6mr19640869plr.16.1533034832631; Tue, 31 Jul 2018 04:00:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533034832; cv=none; d=google.com; s=arc-20160816; b=RFhwrmYmZhmI4rEUBv9xZ5GrY+IasqJux5hG11iMeeLoy9rBztVN7XcFMrb9Zkbc/u SP3GlVfZGRMdCR53091WFAH4Iod78fAfYSH34Pppc9n2q5Ds1AYVboUFCm0K2oXaQQIn jE++MCn9O2Z39QHvl1S0WoVn6LobRXaSb3XadNbGEFKoufiqwtpV865xflF0RPJ5cpF0 S1628zeIfGA1Joo4kTW+cRl/YlOvWigzPSpQyadlBz6QKHE+Wy0Hhz17YCdWykjv8dQV vEZ2t6SDJf6rh3D29Ka9yz0efe31LlOlUJRqveVeWxi5dZK9XSfey7JncNH+t9yY/qpO MH6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=2OHHUznN7jB/GyqlBJCzOBJLBWN8f8+sPQnsPgyBxv0=; b=npYBrUzV/rOf4YmxbdYAc4p0AQOTK+nNjmWAOPwtN/u8pQ/mGjURZBQdqr45zEqW+s 3l4wOp4jMNR5XzcLlmfug8a8s5pAS0BP5iQ2xqjCnwif5mNjC60aqFvSGmut1QwXNNU7 34FpZ6ZSpYY1+5u/U204DtqDZ2cXnpcDYkiXHJgLVu+cOFzRV9SvpSYPx5Mnd/Dq9nV5 bVnAr/7MNlYPtr0pCdrjBWBTURNWB83Bw1xlQcuC9GXekQ2/GvjxJXEVoSp4yv5U7iYf vxUsbzC7sNQc8CnMFZBllQNZfJtspj125srI2wqT38BeJw43L+6bGsaupGHC/W2FQV1A ZcfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=I10LxchS; 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 e14-v6si12798162pfi.184.2018.07.31.04.00.17; Tue, 31 Jul 2018 04:00:32 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=I10LxchS; 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 S1731579AbeGaMjO (ORCPT + 99 others); Tue, 31 Jul 2018 08:39:14 -0400 Received: from merlin.infradead.org ([205.233.59.134]:54810 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731261AbeGaMjO (ORCPT ); Tue, 31 Jul 2018 08:39:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2OHHUznN7jB/GyqlBJCzOBJLBWN8f8+sPQnsPgyBxv0=; b=I10LxchS9grrIFLT6jCpfYrmu M6R7lquL403wly61MVwzisv8ZRsPU2Jy+7D3wCGUHMdOf++RBe9J80JO7EZhUwOzzITmNX7P/LYh9 X/vdUMe25JI2QCx91v3Smb0sB+nDbFO6zqeGCjSnRLwZgKbdhUkswDlTJppqWVm0OOgUBWNFEztUk +u3B0pMyVNrGBgE/vT4uHL48YEoZ1OnH78JnoS3Qze5XsjFJdX4BtCLHHaGgHtZ2lERm30ZpUawHE 4AT3DYAn9iPndNLdn90qafOoe+wUkfpV83zgjb9RqE5FrdcIB/J1n1BHxKhd8DpPqLyFmFEkkAed3 0BM9fJocA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fkSN3-0005Qo-Cr; Tue, 31 Jul 2018 10:59:17 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1960A20268338; Tue, 31 Jul 2018 12:59:16 +0200 (CEST) Date: Tue, 31 Jul 2018 12:59:16 +0200 From: Peter Zijlstra To: Morten Rasmussen Cc: mingo@redhat.com, valentin.schneider@arm.com, dietmar.eggemann@arm.com, vincent.guittot@linaro.org, gaku.inami.xh@renesas.com, linux-kernel@vger.kernel.org Subject: Re: [PATCHv4 01/12] sched: Add static_key for asymmetric cpu capacity optimizations Message-ID: <20180731105916.GR2476@hirez.programming.kicks-ass.net> References: <1530699470-29808-1-git-send-email-morten.rasmussen@arm.com> <1530699470-29808-2-git-send-email-morten.rasmussen@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1530699470-29808-2-git-send-email-morten.rasmussen@arm.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Combined with that SD_ASYM.. rework I ended up with the below. Holler if you want it changed :-) --- Subject: sched: Add static_key for asymmetric cpu capacity optimizations From: Morten Rasmussen Date: Wed, 4 Jul 2018 11:17:39 +0100 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 Cc: valentin.schneider@arm.com Cc: mingo@redhat.com Cc: vincent.guittot@linaro.org Cc: dietmar.eggemann@arm.com Cc: gaku.inami.xh@renesas.com Signed-off-by: Morten Rasmussen Signed-off-by: Peter Zijlstra (Intel) Link: http://lkml.kernel.org/r/1530699470-29808-2-git-send-email-morten.rasmussen@arm.com --- kernel/sched/fair.c | 3 +++ kernel/sched/sched.h | 1 + kernel/sched/topology.c | 9 ++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6186,6 +6186,9 @@ static int wake_cap(struct task_struct * { 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; --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1185,6 +1185,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; --- 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) { @@ -1708,6 +1709,7 @@ build_sched_domains(const struct cpumask struct rq *rq = NULL; int i, ret = -ENOMEM; struct sched_domain_topology_level *tl_asym; + bool has_asym = false; alloc_state = __visit_domain_allocation_hell(&d, cpu_map); if (alloc_state != sa_rootdomain) @@ -1723,8 +1725,10 @@ build_sched_domains(const struct cpumask for_each_sd_topology(tl) { int dflags = 0; - if (tl == tl_asym) + if (tl == tl_asym) { dflags |= SD_ASYM_CPUCAPACITY; + has_asym = true; + } sd = build_sched_domain(tl, cpu_map, attr, sd, dflags, i); @@ -1776,6 +1780,9 @@ build_sched_domains(const struct cpumask } rcu_read_unlock(); + if (has_asym) + static_branch_enable_cpuslocked(&sched_asym_cpucapacity); + 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);