From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52DA9C43334 for ; Fri, 10 Jun 2022 06:54:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240312AbiFJGy3 (ORCPT ); Fri, 10 Jun 2022 02:54:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241047AbiFJGyV (ORCPT ); Fri, 10 Jun 2022 02:54:21 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EDDDD113 for ; Thu, 9 Jun 2022 23:54:13 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LKBTv5cxkzgYg9; Fri, 10 Jun 2022 14:52:19 +0800 (CST) Received: from [10.67.102.169] (10.67.102.169) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 10 Jun 2022 14:54:10 +0800 CC: , , , , , , , , , <21cnbao@gmail.com>, , , , Subject: Re: [PATCH v4 1/2] sched: Add per_cpu cluster domain info and cpus_share_resources API To: Tim Chen , Yicong Yang , , , , , , , References: <20220609120622.47724-1-yangyicong@hisilicon.com> <20220609120622.47724-2-yangyicong@hisilicon.com> <05472b4ed10c694bce1a2b6dd4a0ef13ea337db3.camel@linux.intel.com> From: Yicong Yang Message-ID: <47e3aafa-aae6-051d-99ec-528f7b609b38@huawei.com> Date: Fri, 10 Jun 2022 14:54:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <05472b4ed10c694bce1a2b6dd4a0ef13ea337db3.camel@linux.intel.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.169] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/6/10 6:28, Tim Chen wrote: > On Thu, 2022-06-09 at 20:06 +0800, Yicong Yang wrote: >> >> >> +/* >> + * Whether CPUs are share cache resources, which means LLC on non-cluster >> + * machines and LLC tag or L2 on machines with clusters. >> + */ >> +bool cpus_share_resources(int this_cpu, int that_cpu) > > Suggest cpus_share_lowest_cache to be a bit more informative > >> +{ >> + if (this_cpu == that_cpu) >> + return true; >> + >> + return per_cpu(sd_share_id, this_cpu) == per_cpu(sd_share_id, that_cpu); >> +} >> + >> static inline bool ttwu_queue_cond(int cpu, int wake_flags) >> { >> /* >> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h >> index 01259611beb9..b9bcfcf8d14d 100644 >> --- a/kernel/sched/sched.h >> +++ b/kernel/sched/sched.h >> @@ -1753,7 +1753,9 @@ static inline struct sched_domain *lowest_flag_domain(int cpu, int flag) >> DECLARE_PER_CPU(struct sched_domain __rcu *, sd_llc); >> DECLARE_PER_CPU(int, sd_llc_size); >> DECLARE_PER_CPU(int, sd_llc_id); >> +DECLARE_PER_CPU(int, sd_share_id); >> DECLARE_PER_CPU(struct sched_domain_shared __rcu *, sd_llc_shared); >> +DECLARE_PER_CPU(struct sched_domain __rcu *, sd_cluster); >> DECLARE_PER_CPU(struct sched_domain __rcu *, sd_numa); >> DECLARE_PER_CPU(struct sched_domain __rcu *, sd_asym_packing); >> DECLARE_PER_CPU(struct sched_domain __rcu *, sd_asym_cpucapacity); >> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c >> index 05b6c2ad90b9..0595827d481d 100644 >> --- a/kernel/sched/topology.c >> +++ b/kernel/sched/topology.c >> @@ -664,6 +664,8 @@ static void destroy_sched_domains(struct sched_domain *sd) >> DEFINE_PER_CPU(struct sched_domain __rcu *, sd_llc); >> DEFINE_PER_CPU(int, sd_llc_size); >> DEFINE_PER_CPU(int, sd_llc_id); >> +DEFINE_PER_CPU(int, sd_share_id); > > Some minor nits about the name of "sd_share_id". > It is not quite obvious what it is. > > Maybe something like sd_lowest_cache_id to denote > it is the id of lowest shared cache domain between CPU. > Thanks for the suggestion! Since Vincent and Gautham have suggested this in v1 [1], I'd like to wait a bit before changing to this to see if they have any comment. > Otherwise the patch looks good to me. You can add > > Reviewed-by: Tim Chen > Thanks. [1] https://lore.kernel.org/lkml/CAKfTPtBKLDyNPXg7uLbQ3jUnEwppfC+E29=oJ1tWzzqHsNpApw@mail.gmail.com/