Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp949999rwl; Fri, 31 Mar 2023 04:56:17 -0700 (PDT) X-Google-Smtp-Source: AKy350ZWQ0qCGJYuQMZ4CNdDteoU9kh02xH3632N5usJUovGhD+diL7bP10hecM5H5W3Ep4H3VS7 X-Received: by 2002:a05:6a20:8e19:b0:e4:9a37:2707 with SMTP id y25-20020a056a208e1900b000e49a372707mr1045986pzj.5.1680263777609; Fri, 31 Mar 2023 04:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680263777; cv=none; d=google.com; s=arc-20160816; b=kjAaBX8mQKGAjyXfQJvRByG7YqdkDyQTTFJOXQwaSFS1VKpYoV/8RfSe0lwMEVydtv XENxZI8L1jji5bYyH2Pul6CYnr4qy0ur+6Ph6AVNnxHYzSx6fOvYY0ZRROfii5c+DHXH hPFWrpdMuNRuOY6x7B7o6QmMcc7yPu7Z6vqP/XYjWatw1J+98x0Rgcg1a/B3pV+2DpY2 SCL1IN/IO5mUbylFPkjQOA/JNa1HXXr0gaUw852WUL5DliBylDqq6+vOExSVOmRpCZDo siX//ot/qGlYhOvr9nL0XxCQcjP/Wtqx9ER2LkS07S6W/1jdV8Pgdnqy7cUJDwKrIJcd LVLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=p3uBNORryVtsBZ7ZH27+hIhzm7Adh27jo14LHa5Fm40=; b=mhhoyLIyvfdP/WnvoZOyIWmVi+gU42WAHlybJjvxuw9cRc8MJIY+7vAd6BEXu0zcp3 recHp1/SrcM6gV872Ong3lUP6SuYpTOBjYg24SZCng9rotsP5ADrH/Mwmyt7Yjna6WlD Xmhl5+r9d/5AgtPwwzBnsyMsVOGvu3+1kxaTrJweU34Z6Ab/e7rLKxi5NW1g64dFupow Y/SjHbAkEsriqEOK9ThR7E2npEkbraDuZiYnClQ6Sq5KSnm2hMTTwuq0sCImvp2qAPEp 6DXAnZ8XIr0klthxkoQ7M2fUe2jpjiewfsV7hdXU7QpBZxD0tkiXeOmNmYZ52d39/Mld 1aoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oo1TrPYN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020aa79f4b000000b0061df95ff7desi2234535pfr.114.2023.03.31.04.56.05; Fri, 31 Mar 2023 04:56:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oo1TrPYN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231480AbjCaLy5 (ORCPT + 99 others); Fri, 31 Mar 2023 07:54:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbjCaLy4 (ORCPT ); Fri, 31 Mar 2023 07:54:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F27712CD2; Fri, 31 Mar 2023 04:54:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 205EA6280F; Fri, 31 Mar 2023 11:54:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57965C433D2; Fri, 31 Mar 2023 11:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680263694; bh=Z9WDinB4HAD4+ej+KHX2YQpkyN011VRo+nzW6UoXFGY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Oo1TrPYNGd8nHLWdOKsxsdNiwQa797E7PgKK3FmyPSd1LXbaYpp3Xto3iulKgVwPe 3jy64DZST+DnbkVEBw8E87rxAjNz6z7Led9a5LTxbY72frLGtam+PnQOe6Zy95yapz 1H3gpV970ra9/gpWH3XZpF+Nqc5HTwlU+5GLVe+okoQP2Y1zhVO01cmdDHxlFW5PEc 2GNY/ZxAkSJWIUBKA9hfICq3RmhjxtAdhOekxSJYO7SKURCpChrWQ+OJjS+KIK+B0V 2jeBhyzygyzlGqhtchgb3OM9kCmtGvoH/b9Kig15UuTAgAKgEnLm29ujfN+cI1SUsa u4S4paNcUiR0w== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id EBA324052D; Fri, 31 Mar 2023 08:54:51 -0300 (-03) Date: Fri, 31 Mar 2023 08:54:51 -0300 From: Arnaldo Carvalho de Melo To: K Prateek Nayak Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, ravi.bangoria@amd.com, sandipan.das@amd.com, ananth.narayan@amd.com, gautham.shenoy@amd.com, eranian@google.com Subject: Re: [RFC PATCH 1/4] perf: Read cache instance ID when building cache topology Message-ID: References: <20230331045117.1266-1-kprateek.nayak@amd.com> <20230331045117.1266-2-kprateek.nayak@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230331045117.1266-2-kprateek.nayak@amd.com> X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS 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 Em Fri, Mar 31, 2023 at 10:21:14AM +0530, K Prateek Nayak escreveu: > CPU cache level data currently stores cache level, type, line size, > associativity, sets, total cache size, and the CPUs sharing the cache. > Also read and store the cache instance ID from > "/sys/devices/system/cpu/cpuX/cache/indexY/id" in the cache level data. > Use instance ID as well when comparing cache levels. And if a new perf tool is used in an older kernel without this new 'id' file? Please check if the file exists, if it doesn't don't fail, just initialize with a zero, this way the latest perf will be usable in older kernels. - Arnaldo > Signed-off-by: K Prateek Nayak > --- > tools/perf/util/env.h | 1 + > tools/perf/util/header.c | 7 +++++++ > 2 files changed, 8 insertions(+) > > diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h > index 4566c51f2fd9..d761bfae76af 100644 > --- a/tools/perf/util/env.h > +++ b/tools/perf/util/env.h > @@ -17,6 +17,7 @@ struct cpu_topology_map { > > struct cpu_cache_level { > u32 level; > + u32 id; > u32 line_size; > u32 sets; > u32 ways; > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c > index 404d816ca124..5c3f5d260612 100644 > --- a/tools/perf/util/header.c > +++ b/tools/perf/util/header.c > @@ -1131,6 +1131,9 @@ static bool cpu_cache_level__cmp(struct cpu_cache_level *a, struct cpu_cache_lev > if (a->level != b->level) > return false; > > + if (a->id != b->id) > + return false; > + > if (a->line_size != b->line_size) > return false; > > @@ -1168,6 +1171,10 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 lev > if (sysfs__read_int(file, (int *) &cache->level)) > return -1; > > + scnprintf(file, PATH_MAX, "%s/id", path); > + if (sysfs__read_int(file, (int *) &cache->id)) > + return -1; > + > scnprintf(file, PATH_MAX, "%s/coherency_line_size", path); > if (sysfs__read_int(file, (int *) &cache->line_size)) > return -1; > -- > 2.34.1 > -- - Arnaldo