Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1267519lfc; Wed, 1 Jun 2022 13:37:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5NejI0CZOmpl4j0okP42zcodbYUqphTQfakqYwjYmn6z1ijOR5UX9mHPLd8wfH7zhsPST X-Received: by 2002:a62:3646:0:b0:51b:91c7:fd4a with SMTP id d67-20020a623646000000b0051b91c7fd4amr9647469pfa.78.1654115853002; Wed, 01 Jun 2022 13:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654115852; cv=none; d=google.com; s=arc-20160816; b=IPU1J4HgOY5kPqb+RUPvyN3zn5pqpLOwpfXm/eZ3EOFOf30RzUhxkz4vBRaIrUiJ/h J0IhhLIli8lIgF0e5cLjUt/BLlCVhF1ADUom6m3uMXE2c3A/xj+vngCoD0+kUKyQE7YB +9omG8lCs02agvGe8JYsc5IPNMkIJeuo/83C1tRXl88Omuy+MhjPEKVJss27zsgEnnt2 uhDfiyfi0xjE9YlXW7W/P7PZi3/ErRucbTc4FDav2wOffVaCSF7XlBhSD+vProGNHhyt 908vuujbh763NgtEm+Uy5+nv9BruHAVIZQgYV2PCn8P8M2u12OJ4uuGsReDQjVeA0aPs 4RJw== 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:reply-to:dkim-signature; bh=YBZo/5acJzjtkfbN0zPOUXTmooXsDFbwGkdumr2Rppw=; b=bWO76FdoqGGSwBHCuHKjI63aAF3SeHZDCf1tREWa1IuUzuGxWIKitHdLoce+WLAiCT 5IEaGZHA48t622fgfgK5eLhCBpD2uJcZobWyrMQLvvCJ7sSRGfVj/zgl+x5Ylxvg1UqY 2U/bNfFyN6E0oYCtCYx6JYxXrUWJxzgDyyqV0bY57U4WP3F5TS0BIdc/1CBSnvoIFMvq Mc/qjdxKw88cUCIAV15c0EbrqcoJZ2gTql3X2LDCoLz57+lT2me4zVvPSo3n2dKdX2Io Fxi3Uwsy88DrV5MkGeoYJSAy0wBp5MbeU1K5j1d2EomB7zImvjNaGCcJarmxy5RU6Tc8 GkuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Cfc+tS+H; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 26-20020a17090a195a00b001e07470b6c0si3098935pjh.149.2022.06.01.13.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:37:32 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Cfc+tS+H; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 95EC42875AA; Wed, 1 Jun 2022 12:46:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349303AbiFADUd (ORCPT + 99 others); Tue, 31 May 2022 23:20:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349284AbiFADUb (ORCPT ); Tue, 31 May 2022 23:20:31 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 978268B0B6 for ; Tue, 31 May 2022 20:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654053629; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YBZo/5acJzjtkfbN0zPOUXTmooXsDFbwGkdumr2Rppw=; b=Cfc+tS+HvuC3/mK4nJa9EobrGl5VotDasG71zmWOTs43qXTxZFuX1pD+ph6N5oJqyhB4ps k0OK4IyVYBaYEzjIYgc8bIwC1+kU6s3VNBHuvlCu2IJJttmLW4kQywYpSTLssiqTM7YLCb nDEAbZ0FI0yFkSlcNFzY9+xv4EJLbUw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-TIkAbRDJPAKi2hnHaoJ0_w-1; Tue, 31 May 2022 23:20:22 -0400 X-MC-Unique: TIkAbRDJPAKi2hnHaoJ0_w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 82E0E811E7A; Wed, 1 Jun 2022 03:20:21 +0000 (UTC) Received: from [10.72.12.91] (ovpn-12-91.pek2.redhat.com [10.72.12.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3DB8A1731B; Wed, 1 Jun 2022 03:20:15 +0000 (UTC) Reply-To: Gavin Shan Subject: Re: [PATCH v3 04/16] cacheinfo: Add support to check if last level cache(LLC) is valid or shared To: Sudeep Holla , linux-kernel@vger.kernel.org Cc: Atish Patra , Atish Patra , Vincent Guittot , Morten Rasmussen , Dietmar Eggemann , Qing Wang , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Rob Herring References: <20220525081416.3306043-1-sudeep.holla@arm.com> <20220525081416.3306043-2-sudeep.holla@arm.com> <20220525081416.3306043-3-sudeep.holla@arm.com> <20220525081416.3306043-4-sudeep.holla@arm.com> <20220525081416.3306043-5-sudeep.holla@arm.com> From: Gavin Shan Message-ID: Date: Wed, 1 Jun 2022 11:20:12 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <20220525081416.3306043-5-sudeep.holla@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sudeep, On 5/25/22 4:14 PM, Sudeep Holla wrote: > It is useful to have helper to check if the given two CPUs share last level > cache. We can do that check by comparing fw_token or by comparing the cache > ID. Currently we check just for fw_token as the cache ID is optional. > > This helper can be used to build the llc_sibling during arch specific > topology parsing and feeding information to the sched_domains. This also > helps to get rid of llc_id in the CPU topology as it is sort of duplicate > information. > > Also add helper to check if the llc information in cacheinfo is valid or not. > > Signed-off-by: Sudeep Holla > --- > drivers/base/cacheinfo.c | 26 ++++++++++++++++++++++++++ > include/linux/cacheinfo.h | 2 ++ > 2 files changed, 28 insertions(+) > With below nits fixed: Reviewed-by: Gavin Shan > diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c > index 417e1ebf5525..ed74db18468f 100644 > --- a/drivers/base/cacheinfo.c > +++ b/drivers/base/cacheinfo.c > @@ -47,6 +47,32 @@ static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf, > return sib_leaf->fw_token == this_leaf->fw_token; > } > > +bool last_level_cache_is_valid(unsigned int cpu) > +{ > + struct cacheinfo *llc; > + > + if (!cache_leaves(cpu)) > + return false; > + > + llc = per_cpu_cacheinfo_idx(cpu, cache_leaves(cpu) - 1); > + > + return llc->fw_token; > +} > + return !!llc->fw_token; > +bool last_level_cache_is_shared(unsigned int cpu_x, unsigned int cpu_y) > +{ > + struct cacheinfo *llc_x, *llc_y; > + > + if (!last_level_cache_is_valid(cpu_x) || > + !last_level_cache_is_valid(cpu_y)) > + return false; > + > + llc_x = per_cpu_cacheinfo_idx(cpu_x, cache_leaves(cpu_x) - 1); > + llc_y = per_cpu_cacheinfo_idx(cpu_y, cache_leaves(cpu_y) - 1); > + > + return cache_leaves_are_shared(llc_x, llc_y); > +} > + > #ifdef CONFIG_OF > /* OF properties to query for a given cache type */ > struct cache_type_info { > diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h > index 4ff37cb763ae..7e429bc5c1a4 100644 > --- a/include/linux/cacheinfo.h > +++ b/include/linux/cacheinfo.h > @@ -82,6 +82,8 @@ struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu); > int init_cache_level(unsigned int cpu); > int populate_cache_leaves(unsigned int cpu); > int cache_setup_acpi(unsigned int cpu); > +bool last_level_cache_is_valid(unsigned int cpu); > +bool last_level_cache_is_shared(unsigned int cpu_x, unsigned int cpu_y); > #ifndef CONFIG_ACPI_PPTT > /* > * acpi_find_last_cache_level is only called on ACPI enabled > Thanks, Gavin