From nobody Fri Dec 19 03:46:24 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 7FD6F34A3BF for ; Wed, 17 Dec 2025 17:22:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765992140; cv=none; b=hsMFzteE33ghg/4V4C5RG1T6+edkJFd8yCSEFtOxCtuTr+TpaAfspJKzho67oGumqWoolSmlP00wopL+sUV7rLE0x1I96vCAg2eqDLWnOHo3oKYiPNuQ7lXA1kHhdO8Xil9F8/v5XgNy7RmKMqa6UtGBqf8pl4EugRpmj64yvJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765992140; c=relaxed/simple; bh=6eDfgjELhcmSW90C74/6awyAJ2/BjysR0ixtjTPYPbM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fZpyR443bwinZYOfkM9grWhm5KcrHxWl73pk/fkPYFCmN9Oh4rMgIzlsk9YskmUuB3TGLP3iESUczR8aJ4UgP213u5Zrv+fLzLJqjXcfYfG2gE3vrvf4Cs9+9ehwFB5qM5k4RQidzriiiw5EbTmKl9s85wEuGiK/yTJDJtTs2TY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=fail smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TFjr6M+2; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TFjr6M+2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765992135; x=1797528135; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6eDfgjELhcmSW90C74/6awyAJ2/BjysR0ixtjTPYPbM=; b=TFjr6M+28RsOi2PbnvQYgww7FyQNL0MN7xuKm5f5Var+wfSQyMjLKAr0 vQxkr4vbDY3yBAILZNvi8Veai94Eo481YKkEEHBEEZm8DsbzOJdyvy6R9 bjdLEYaqrH01XjVKmA6GwQjzY/zUmfLqly5Dyszb+pQDr3KmFOe467024 VFZuYqnS/X8IYrBIXQm5zJmhGC+L8sqNPyuxc56xPpFDVMFQpNTwY8ZvA x2+68OzxZucUbC6lJ09mAwIBi5lraj0sWPvPjFIfmgSW/WYR5Vqh6MpEW NW0O2AUNb0+tMLiqkTHCrzHPS+nvi+S68bGH6enGtYmwpxtmP1xjcZ2nI w==; X-CSE-ConnectionGUID: NQw6C0OPSKux2hfFtyDfFQ== X-CSE-MsgGUID: W9AsLaCISKeuOu/KS6v0nA== X-IronPort-AV: E=McAfee;i="6800,10657,11645"; a="90594797" X-IronPort-AV: E=Sophos;i="6.21,156,1763452800"; d="scan'208";a="90594797" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Dec 2025 09:21:36 -0800 X-CSE-ConnectionGUID: bAflHPHoT/Gj7eqN+1qrbQ== X-CSE-MsgGUID: BcxbriBqSfKv3hD9pYnnvw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,156,1763452800"; d="scan'208";a="221748240" Received: from pgcooper-mobl3.ger.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.131]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Dec 2025 09:21:35 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v17 22/32] fs/resctrl: Refactor rmdir_mondata_subdir_allrdtgrp() Date: Wed, 17 Dec 2025 09:21:09 -0800 Message-ID: <20251217172121.12030-23-tony.luck@intel.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251217172121.12030-1-tony.luck@intel.com> References: <20251217172121.12030-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Clearing a monitor group's mon_data directory is complicated because of the support for Sub-NUMA Cluster (SNC) mode. Refactor the SNC case into a helper function to make it easier to add suppo= rt for a new telemetry resource. Suggested-by: Reinette Chatre Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- fs/resctrl/rdtgroup.c | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index c0db5d8999ee..679247c43b1a 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -3228,28 +3228,24 @@ static void mon_rmdir_one_subdir(struct kernfs_node= *pkn, char *name, char *subn } =20 /* - * Remove all subdirectories of mon_data of ctrl_mon groups - * and monitor groups for the given domain. - * Remove files and directories containing "sum" of domain data - * when last domain being summed is removed. + * Remove files and directories for one SNC node. If it is the last node + * sharing an L3 cache, then remove the upper level directory containing + * the "sum" files too. */ -static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, - struct rdt_domain_hdr *hdr) +static void rmdir_mondata_subdir_allrdtgrp_snc(struct rdt_resource *r, + struct rdt_domain_hdr *hdr) { struct rdtgroup *prgrp, *crgrp; struct rdt_l3_mon_domain *d; char subname[32]; - bool snc_mode; char name[32]; =20 if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) return; =20 d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); - snc_mode =3D r->mon_scope =3D=3D RESCTRL_L3_NODE; - sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci_id : hdr->id); - if (snc_mode) - sprintf(subname, "mon_sub_%s_%02d", r->name, hdr->id); + sprintf(name, "mon_%s_%02d", r->name, d->ci_id); + sprintf(subname, "mon_sub_%s_%02d", r->name, hdr->id); =20 list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { mon_rmdir_one_subdir(prgrp->mon.mon_data_kn, name, subname); @@ -3259,6 +3255,30 @@ static void rmdir_mondata_subdir_allrdtgrp(struct rd= t_resource *r, } } =20 +/* + * Remove all subdirectories of mon_data of ctrl_mon groups + * and monitor groups for the given domain. + */ +static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, + struct rdt_domain_hdr *hdr) +{ + struct rdtgroup *prgrp, *crgrp; + char name[32]; + + if (r->rid =3D=3D RDT_RESOURCE_L3 && r->mon_scope =3D=3D RESCTRL_L3_NODE)= { + rmdir_mondata_subdir_allrdtgrp_snc(r, hdr); + return; + } + + sprintf(name, "mon_%s_%02d", r->name, hdr->id); + list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { + kernfs_remove_by_name(prgrp->mon.mon_data_kn, name); + + list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) + kernfs_remove_by_name(crgrp->mon.mon_data_kn, name); + } +} + /* * Create a directory for a domain and populate it with monitor files. Cre= ate * summing monitors when @hdr is NULL. No need to initialize summing monit= ors. --=20 2.52.0