Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp875658pxj; Thu, 27 May 2021 13:49:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+VRhVVNSgDeAywA6yLBmqNNtAtfsheD3Cu1eVuS8TjWalQYhBVjh/hBsMP3hQUWrBHvE/ X-Received: by 2002:a05:6638:124b:: with SMTP id o11mr5224860jas.4.1622148555379; Thu, 27 May 2021 13:49:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622148555; cv=none; d=google.com; s=arc-20160816; b=w40p6oUVVFUCYE0IzY8mQpsjgUHGyDjqhVrH23RZ6dUc5CYk/QGwrIjwFCoYnqePaO xOiYGV8WozUUg9Muq8i3WKyroJBJVIuq7y7MqOL3E4uHUQ0gaDhDCHpZrzRxVqTOBuMW Ue/WdHArYh2i5ZBYMrnlyihWcw0fEVlVGpZ+l0zCZVHbkmhUNAbUsKlBTQKl8QJx2cz2 DjLkJCrWH1bxjSaVPT/i7XsPzl0Fa59CFd9KYKwiEbH0fnc/WkLhrCU5BdI/NSym+2ou QHgmjxiJiK55yZePbbmYRXSU6FVjRWdgC9GeqlbKAtJ1lKgXlcU43EdexejvFTUPfvxS XAsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=TZlwmH/IDqDrlEmSOvxOKROUmIW6p9bTUWGz1KIpnyg=; b=FjgU1UZHO/p3z/W8Mj/JDtEHhspv0RrQqhPQSFWS9iQLUHzqGBfYmYlcoYtRZU+lNn bkkUKT9j2I0V87MlOWQoKs30/jiJuBhncDlMPbCleCbSvKJVxdv1lR9Vz4VFpf8Ffjrl MwzfJyhqMSSYAUJ8INCSGBd7RLVnUHV78gn9ip1K6fK1OyO2BVlHLYoe4DGKZjZwc5X0 gn3vpWaNuzjJj8CkhWhLlBIAL3oV2iPRY6rOve4cN5E57h0JIp/aoMLqTCuOgRZfsT6N /h7dhVOK3LGRdpDyRRuen2kzECnPBSUPU1r/1fy07bjx6C+GHQPkeplR9V7nFqAAD91M w2ZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q7si4162666iow.93.2021.05.27.13.49.02; Thu, 27 May 2021 13:49:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235106AbhE0MYa (ORCPT + 99 others); Thu, 27 May 2021 08:24:30 -0400 Received: from foss.arm.com ([217.140.110.172]:56806 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234702AbhE0MY3 (ORCPT ); Thu, 27 May 2021 08:24:29 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0437513A1; Thu, 27 May 2021 05:22:56 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 00C963F73D; Thu, 27 May 2021 05:22:53 -0700 (PDT) Subject: Re: [PATCH v5 2/3] sched/topology: Rework CPU capacity asymmetry detection To: Peter Zijlstra Cc: Beata Michalska , Valentin Schneider , linux-kernel@vger.kernel.org, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, corbet@lwn.net, rdunlap@infradead.org, linux-doc@vger.kernel.org References: <20210524101617.8965-1-beata.michalska@arm.com> <20210524101617.8965-3-beata.michalska@arm.com> <87fsyc6mfz.mognet@arm.com> <20210524225508.GA14880@e120325.cambridge.arm.com> <87a6oj6sxo.mognet@arm.com> <20210525102945.GA24210@e120325.cambridge.arm.com> <98ad8837-b9b8-ff50-5a91-8d5951ee757c@arm.com> From: Dietmar Eggemann Message-ID: <315b4b5d-05f5-e311-8ed9-b55072cf84f9@arm.com> Date: Thu, 27 May 2021 14:22:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/05/2021 09:03, Peter Zijlstra wrote: > On Wed, May 26, 2021 at 11:52:25AM +0200, Dietmar Eggemann wrote: > >> For me asym_cpu_capacity_classify() is pretty hard to digest ;-) But I >> wasn't able to break it. It also performs correctly on (non-existing SMT) >> layer (with sd span eq. single CPU). > > This is the simplest form I could come up with this morning: > > static inline int > asym_cpu_capacity_classify(struct sched_domain *sd, > const struct cpumask *cpu_map) > { > struct asym_cap_data *entry; > int i = 0, n = 0; > > list_for_each_entry(entry, &asym_cap_list, link) { > if (cpumask_intersects(sched_domain_span(sd), entry->cpu_mask)) > i++; > else > n++; > } > > if (WARN_ON_ONCE(!i) || i == 1) /* no asymmetry */ > return 0; > > if (n) /* partial asymmetry */ > return SD_ASYM_CPUCAPACITY; > > /* full asymmetry */ > return SD_ASYM_CPUCAPACITY | SD_ASYM_CPUCAPACITY_FULL; > } > > > The early termination and everything was cute; but this isn't > performance critical code and clarity is paramount. This is definitely easier to grasp. What about the missing `if (cpumask_intersects(entry->cpu_mask, cpu_map))` condition in the else path to increment n? Example: cpus = {[446 446] [871 871] [1024 1024]} So 3 asym_cap_list entries. After hp'ing out CPU4 and CPU5: DIE: 'partial asymmetry' In case we would increment n only when the condition is met, we would have `full asymmetry`. I guess we want to allow EAS task placement, hence have sd_asym_cpucapacity set in case there are only 446 and 871 left?