Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5932753imm; Mon, 23 Jul 2018 08:29:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdHeDFBinRmnj8CBJSlelah/0PrjA9d2/kWqvnqtOelZxwx9lZ/jJTjBSF8LtvtEhym/xSm X-Received: by 2002:a17:902:7884:: with SMTP id q4-v6mr13254953pll.174.1532359768263; Mon, 23 Jul 2018 08:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532359768; cv=none; d=google.com; s=arc-20160816; b=t6T7t2nFRUtMEMbaXgkuKCBIjak18LPuV+ZfEj9Mge/5vEnuhzYUhX3UbPd5nuMIag Wa8WWOsSvMu61opr2TyLkcuPDpVqpp8f1oTYntpleO6o8RbELKuHyo3qT7EHdVg8zZOR J0nUpg99Q+10uafm8bOWWfZvpcj79QzZyim4R7cjrMtvWjsAWEmQidzns9u6yvJpY/MR 59Ckw9PNeZdfF7ZG73sn+h5iIReRNtAg5IbeIXmDJkb184UQbcWm1dKJnXXnBg+3I/fU kv1knAPKPPrP8rXyguPLuX2WMFDjGRcu1zrw3vJykfSHQ5or8dM5SHOBkyToB3ex+ikQ Bgjw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=kk1IfBYNaoKg0lFFz6qvF8QyNRhVibw762YPTNiqcyc=; b=zWBEvUHc9uYf72ScVTa3nCbr4SrqH6qcgo+e6evgRjCIS0QFjm8/KepvD6Zd8OzKLe sOApkRhaUsOXQ436tT/sOsqezUT50LfS3OTGfS0exFZaFUJOTM3Fsf4C2J+FAedHICkD 7F6fcV8VoS/Rhm9MUAubeX4sQhYHDuYU8x/jqjewfRLw9Do9Wn457HvVwISnySHyr4mL FHpnBeZYUVAUl09jKl48o/0q8EaQGRZlLZHIMETzzv16b168rgLlYDntn3eejPo6JOpz 3IMvIMShglO96uVy417+fbXkHby2ekE7Y3hUdTC5HUI1OIgxblltFfaEBFs8Caco4tlO dlBQ== 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 34-v6si9084360pgs.243.2018.07.23.08.29.13; Mon, 23 Jul 2018 08:29:28 -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 S2388594AbeGWQ32 (ORCPT + 99 others); Mon, 23 Jul 2018 12:29:28 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:35696 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388161AbeGWQ32 (ORCPT ); Mon, 23 Jul 2018 12:29:28 -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 5DDA918A; Mon, 23 Jul 2018 08:27:43 -0700 (PDT) Received: from e105550-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D9A443F237; Mon, 23 Jul 2018 08:27:41 -0700 (PDT) Date: Mon, 23 Jul 2018 16:27:34 +0100 From: Morten Rasmussen To: Qais Yousef Cc: vincent.guittot@linaro.org, peterz@infradead.org, linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com, mingo@redhat.com, valentin.schneider@arm.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 1/4] sched/topology: SD_ASYM_CPUCAPACITY flag detection Message-ID: <20180723152551.GA29978@e105550-lin.cambridge.arm.com> References: <1532093554-30504-1-git-send-email-morten.rasmussen@arm.com> <1532093554-30504-2-git-send-email-morten.rasmussen@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 23, 2018 at 02:25:34PM +0100, Qais Yousef wrote: > Hi Morten > > On 20/07/18 14:32, Morten Rasmussen wrote: > >The SD_ASYM_CPUCAPACITY sched_domain flag is supposed to mark the > >sched_domain in the hierarchy where all cpu capacities are visible for > >any cpu's point of view on asymmetric cpu capacity systems. The > >scheduler can then take to take capacity asymmetry into account when > > Did you mean "s/take to take/try to take/"? Yes. [...] > >+ /* > >+ * Examine topology from all cpu's point of views to detect the lowest > >+ * sched_domain_topology_level where a highest capacity cpu is visible > >+ * to everyone. > >+ */ > >+ for_each_cpu(i, cpu_map) { > >+ unsigned long max_capacity = arch_scale_cpu_capacity(NULL, i); > >+ int tl_id = 0; > >+ > >+ for_each_sd_topology(tl) { > >+ if (tl_id < asym_level) > >+ goto next_level; > >+ > > I think if you increment and then continue here you might save the extra > branch. I didn't look at any disassembly though to verify the generated > code. > > I wonder if we can introduce for_each_sd_topology_from(tl, starting_level) > so that you can start searching from a provided level - which will make this > skipping logic unnecessary? So the code will look like > > ??? ??? ??? for_each_sd_topology_from(tl, asymc_level) { > ??? ??? ??? ??? ... > ??? ??? ??? } Both options would work. Increment+contrinue instead of goto would be slightly less readable I think since we would still have the increment at the end of the loop, but easy to do. Introducing for_each_sd_topology_from() improve things too, but I wonder if it is worth it. > >@@ -1647,18 +1707,27 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att > > struct s_data d; > > struct rq *rq = NULL; > > int i, ret = -ENOMEM; > >+ struct sched_domain_topology_level *tl_asym; > > alloc_state = __visit_domain_allocation_hell(&d, cpu_map); > > if (alloc_state != sa_rootdomain) > > goto error; > >+ tl_asym = asym_cpu_capacity_level(cpu_map); > >+ > > Or maybe this is not a hot path and we don't care that much about optimizing > the search since you call it unconditionally here even for systems that > don't care? It does increase the cost of things like hotplug slightly and repartitioning of root_domains a slightly but I don't see how we can avoid it if we want generic code to set this flag. If the costs are not acceptable I think the only option is to make the detection architecture specific. In any case, AFAIK rebuilding the sched_domain hierarchy shouldn't be a normal and common thing to do. If checking for the flag is not acceptable on SMP-only architectures, I can move it under arch/arm[,64] although it is not as clean. Morten