Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp726671lqc; Fri, 8 Mar 2024 09:52:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW7goyFKWbFtSo72zqApvbDG+nrTcVqpN+mlFrOyxVmAJSVL8ZWZpk7rlpSYoGuLcdwfYqPWNtlwkgmqzWlw6qq+M76rdZTSOAoFzqSYw== X-Google-Smtp-Source: AGHT+IGCbAymEwioQIq2q/eAGIz+a4aqxT5Nq7Gz8PdPeYKGqO94LVwiypCTquOz179NKczcDy5v X-Received: by 2002:a05:6e02:1a8e:b0:363:e7c8:2180 with SMTP id k14-20020a056e021a8e00b00363e7c82180mr27766011ilv.12.1709920338088; Fri, 08 Mar 2024 09:52:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709920338; cv=pass; d=google.com; s=arc-20160816; b=LSJCjUHzpaI2qCntXz6rlekMr91KrABrPdpiq75c4maZnOp8IgapCCWBBU/b6K1Ywm 4KD0iZ/eXhiHDdHajx0vTxOrThjMYy+BaFssxYs5VM69HtOhhPZBfHj+rRMLE4z1y/rd UWfqIf4iJoWFMtlj3RdkkUn7BGseQ5zrbfvfDOY4n9S3KVb/zPK8j6i8uT9AMyyw8mKi I8iKbO0uoscqHmHx3CMDEx6mKkzvjFcLLoJOV/z8r8xVlVJ7aOmOMdDlxzx976ZKWixy iGlE0n9LyU2sLsS0Yo9HVYzSDWOUQNINB8jlvnZL79t74ZBw6jhCKiL43KsG9bUGNFXZ rxmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:date:from :dkim-signature; bh=rjPSMiO7k8I2svYKtuuvMesXk7QTGyyWc1MJs9zdffs=; fh=q09h0p4+MN5uYGFk4mRrkTXpXKByEQFQaaMxiPQhvlQ=; b=AIBYccdzhDwowRSXCIUFKgzcVnRXAfCB6/F+usrKul9mt19COe9Wo0WuxgXFBTPjLK lbdVJ1PfewWFfEGBLIF5f0owlKd+E1DEpSixUICw53skwlW+dlSzC/ZQQdNZbqovT+Tt Ud0sFT2S0g5Ny0+aivGA9c2yEFNwVPUQv7xO9DOi9pFgc5Qxz/4GyJaHM9UTs4e/dCmW zyICZTGg2Px46ZsxULBCVzEjMLUnCTLP57ZPv2otseCLCejQJjiIrZfT9ivlVfkvb3cm 3KjkuUA/gfW60j4MguzAw0CdR2lmlkyD72GLe9MVRXSyOe6kzK77oTUmX2QQWy7gRGzo D5HA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=abQY7zjk; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-97114-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97114-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q27-20020a63505b000000b005dc1b5b386asi16654576pgl.339.2024.03.08.09.52.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 09:52:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97114-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=abQY7zjk; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-97114-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97114-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DD026285329 for ; Fri, 8 Mar 2024 13:53:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0DE3D3BBF5; Fri, 8 Mar 2024 13:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="abQY7zjk" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A71E038DF9; Fri, 8 Mar 2024 13:53:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709906009; cv=none; b=ufCoFWWe9pnq3lAwv/C0Nampc0r+ctQGorWE2J/Aux9Zt11j9amKP3U8PfODNBrolc6sk3pV8M9Wq9mqRdQuKJlA5dE744HQYpXsKc6whWNKRzVy7B4QuM9vbZ3i+yo+zRJmX8EIF8ayahO1rTZAlLD3SZZ27c5L2NRD5CoPbuE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709906009; c=relaxed/simple; bh=NITzIM94nELtuCjZkBEgy9jlRwa/xY4KvHM838qFBec=; h=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=BYrsyZvVsSC5mFOg2/iT47koZ/sXyv+2GImF6zenUvnT45y2orNHcMdFbBOeGWngqBdAFw9Qt4DR9vMeCyCo+sw7MeSCJWAM3IKT6SJZ9vx0wfHCbsatQ9fnqUlebsmwC1/3X3gisNU9O2BK2FRrRRA6m9QNBl11EMGasB6qVtM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=abQY7zjk; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709906008; x=1741442008; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=NITzIM94nELtuCjZkBEgy9jlRwa/xY4KvHM838qFBec=; b=abQY7zjkzSJAJHTQ2jyk4Fx8dk5ia6mwX8PDFsMocjCLDwQ0BjdEDCGL 4zMpgpw57yfo0q5vDDOJg9mAqNJhuY2ZY7x0A3SNKhf8TL0JiMzn/tVmW ARua/F/+QJAuaKps5iWOHuRrRDwFhTXbOcJBynocAbDYnuIjQuwg54s/s Nnk668oEK7dyzHOswsLDILRep005a95fnPSob+vHBRpPJ94PfwNLV4hW+ hBIfCXk3HUcdPESKeDMELc0cKfrLaWpKaTfksokb9CrDBB1KfJDQ1/NE/ SBf4t+wrMYlSwhTytkJXj5P9vlHXs087otb1c210fiVzDp7hT2no7SwUY Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4469818" X-IronPort-AV: E=Sophos;i="6.07,109,1708416000"; d="scan'208";a="4469818" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 05:53:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,109,1708416000"; d="scan'208";a="41444446" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.186]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 05:53:24 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Fri, 8 Mar 2024 15:53:19 +0200 (EET) To: Maciej Wieczor-Retman cc: Fenghua Yu , Reinette Chatre , Shuah Khan , tony.luck@intel.com, "Shaopeng Tan (Fujitsu)" , LKML , linux-kselftest@vger.kernel.org Subject: Re: [PATCH 2/4] selftests/resctrl: SNC support for CMT In-Reply-To: <75849cb145429798b21c23b6be4abd7ece9df57b.1709721159.git.maciej.wieczor-retman@intel.com> Message-ID: <6181937a-54b4-8b17-0c24-734764a205d1@linux.intel.com> References: <75849cb145429798b21c23b6be4abd7ece9df57b.1709721159.git.maciej.wieczor-retman@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Wed, 6 Mar 2024, Maciej Wieczor-Retman wrote: > Cache Monitoring Technology (CMT) works by measuring how much data in L3 > cache is occupied by a given process identified by its Resource > Monitoring ID (RMID). > > On systems with Sub-Numa Clusters (SNC) enabled, a process can occupy > not only the cache that belongs to its own NUMA node but also pieces of > other NUMA nodes' caches that lie on the same socket. > > A simple correction to make the CMT selftest NUMA-aware is to sum values > reported by all nodes on the same socket for a given RMID. > > Reported-by: "Shaopeng Tan (Fujitsu)" > Closes: https://lore.kernel.org/all/TYAPR01MB6330B9B17686EF426D2C3F308B25A@TYAPR01MB6330.jpnprd01.prod.outlook.com/ > Signed-off-by: Maciej Wieczor-Retman > --- > tools/testing/selftests/resctrl/cache.c | 17 +++++++++++------ > tools/testing/selftests/resctrl/resctrl.h | 4 +++- > tools/testing/selftests/resctrl/resctrl_val.c | 9 ++++++--- > 3 files changed, 20 insertions(+), 10 deletions(-) > > diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c > index 1b339d6bbff1..dab81920033b 100644 > --- a/tools/testing/selftests/resctrl/cache.c > +++ b/tools/testing/selftests/resctrl/cache.c > @@ -161,16 +161,21 @@ int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, > * > * Return: =0 on success. <0 on failure. > */ > -int measure_llc_resctrl(const char *filename, int bm_pid) > +int measure_llc_resctrl(const char *filename, int bm_pid, const char *ctrlgrp, > + const char *mongrp, int res_id) > { > - unsigned long llc_occu_resc = 0; > + unsigned long sum = 0, llc_occu_resc = 0; > int ret; > > - ret = get_llc_occu_resctrl(&llc_occu_resc); > - if (ret < 0) > - return ret; > + for (int i = 0 ; i < snc_ways() ; i++) { Spaces as per usual coding style: for (int i = 0; i < snc_ways(); i++) { > + set_cmt_path(ctrlgrp, mongrp, res_id + i); > + ret = get_llc_occu_resctrl(&llc_occu_resc); > + if (ret < 0) > + return ret; > + sum += llc_occu_resc; > + } > > - return print_results_cache(filename, bm_pid, llc_occu_resc); > + return print_results_cache(filename, bm_pid, sum); > } > > /* > @@ -828,6 +828,8 @@ int resctrl_val(const struct resctrl_test *test, > sleep(1); > > /* Test runs until the callback setup() tells the test to stop. */ > + get_domain_id("L3", uparams->cpu, &res_id); Hardcoding L3 here limits the genericness of this function. You don't even need to do it, get_domain_id() does "MB" -> "L3" transformation implicitly for you so you can just pass test->resource instead. Also, I don't understand why you now again make the naming inconsistent with "res_id". If you based this on top of the patches I just posted, resctl_val() already the domain_id variable. -- i. > + res_id *= snc_ways(); > while (1) { > ret = param->setup(test, uparams, param); > if (ret == END_OF_TESTS) { > @@ -844,7 +846,8 @@ int resctrl_val(const struct resctrl_test *test, > break; > } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { > sleep(1); > - ret = measure_llc_resctrl(param->filename, bm_pid); > + ret = measure_llc_resctrl(param->filename, bm_pid, param->ctrlgrp, > + param->mongrp, res_id); > if (ret) > break; > } >