Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp272712lqb; Tue, 28 May 2024 15:22:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUrhX6sgl7EZLBhX96kB8z9hehYYe9T+Vg9kresJyCL9XX9+QdYtC8PHZPmWiMgeqQR8FWw95EjkXkSKKIGLURWD7ZcYJwPs9PTNWlp9w== X-Google-Smtp-Source: AGHT+IF0sek+cCFq1Q/UAogyAKOXk7Ac9ANNg/WjZ18TLRlL1Xsod98UN1gF64T9ffCWzIHq/8QY X-Received: by 2002:a50:f68d:0:b0:579:cf9d:d6a with SMTP id 4fb4d7f45d1cf-579cf9d0e20mr4759345a12.20.1716934937679; Tue, 28 May 2024 15:22:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716934937; cv=pass; d=google.com; s=arc-20160816; b=1JFaikskjho6bq7zdATJODgqElf1zMp6gQx6jnD5W81TyB5MqpQjoTSL8J23Az8ktM JSNK33VSX18HReE6XYwteiuCm9RJVIEPjLrk7uIri7fTKFYW/FlIfrsbGOTisDHla7yb n539O+GjJ2sK7UM48ICriwhTIFhGHE7r1BeS7DRJpIXr/hQ1nYy842WRdvu3UKO0U9hF SVBqSXeiquPg1huEa5pTvb5gOJvzRrLzsn/loru5D+CsFsr41HjCHOOQ0xK8/daCSFu9 20cce5gmVpFcf6ZiIeCRvJClvRIDcd47KJvnyZY8fnWVXQtuFg+Rm0Z7LdqVoojX8XDt Jpwg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=68Ezl1++M+37BnGCklfjEtVnGQ3ntRy0l6kA+MUuoiE=; fh=qTx768JYq6oxdX3jfjUzjJGF83d0IKGtQzHdow3lchk=; b=hyiwRiYPtout5dGOxqJSZq7ddjBbQb4qzA/oh/sESAVCletQAtmubRzBnmvz3kZ0xa cXaY2ZEzfX3hsZ/bPG/eIIO0Y6qEjkwV5R/vRpF23yCUMcg9KosYS7LGp/SPfYD29KkY cT9MgXHu8g5kHXcVLn2A89SfoMOWCvGCLKppIMR5i1hlLQ06kFtN7lvGCizvQPGt16os lEBfzE0s82jU1YkP2qQ0KBWL+/O/TBn1CbamSD75rjVTHq1ueqLQVQ80X9V2HWUhoqyq 9OdOPnYVmXdsQTrrJ16Eh1zVEyMW7ixhzKVJmvq3fuNopEDV5drOdwXayKJpWFuG5sk2 wveA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e1jtw4DL; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193166-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193166-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5786400f635si4768331a12.649.2024.05.28.15.22.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 15:22:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193166-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e1jtw4DL; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193166-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193166-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 69F3B1F26384 for ; Tue, 28 May 2024 22:22:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A88C143864; Tue, 28 May 2024 22:20:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="e1jtw4DL" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 F41D613E042 for ; Tue, 28 May 2024 22:20:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716934826; cv=none; b=UwPQQiXak9SIdIvqA1+cJvAjrC5eY82x6Y3+TrI/VsDR/nNdBGGIckUpnzq+VlOrEIGMGiWyozRK0r7+fPzjJnLs2/i6hfztLZJqKDq04DxoAEBvj9gmDXOA5c8w2CsSuvSWWhyCysqw2jpKU7ojV9E9ef8N0PBTc80F3nPH0jU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716934826; c=relaxed/simple; bh=im/Pz9hg/qCEbfF9S4v7tyMMvbxX1QBNERgbrYVF2eo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zp6uJLBP32SvFKtni7WwTE/Ur9Y82oWvKma5rku6u8VXd9NdgaajnN0LKexVN57A4pns8czOqPGMkIDcrpJcVOozjL0OoQQNVUysifv0S001Dh9mkauaJcEkgSWH1JMvOybCF08zxFYzsWqETc8QnsEvfaRTJ8EiktaZ7dF6hb4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=e1jtw4DL; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716934825; x=1748470825; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=im/Pz9hg/qCEbfF9S4v7tyMMvbxX1QBNERgbrYVF2eo=; b=e1jtw4DLdApY2lHY9w5a/8K+T5fA852hvQI6BQR9l4Y1JLtnFzwKFAR4 hdwydA+VlFu4Ixh2kKzRt93PshIREG1TcL7gU306tShZUzoFdBvJ98LXn fSR1sr2NvAIPWVukGmMSw1f5Fm7T25ZkvZa/qgLEv0MaU3Xur1FNDQOOi zPKylenaQdBqGA4fQnL43LEYwHNfIRyMw+xCOUktX26NGiSn7NUzq0FRn cnq0lRcoNr+tYC+4r1xKQgu+jf47pXbpXzUR+7QM412xUzp/Df4Rty2Ey iIMso6IVJWlkpaEb2+hWIn2r5yqUoaMGxDyk7JCLUrLYT4PjstRGCLRNS w==; X-CSE-ConnectionGUID: YTzJzG6iRHm9BE2o6B9Vlw== X-CSE-MsgGUID: xwgaQRVESeCthIF12DtcwA== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="30812226" X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="30812226" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 15:20:19 -0700 X-CSE-ConnectionGUID: jkHzCNU4SBC1GnfbGCmfyw== X-CSE-MsgGUID: 3hkeNKh0RqWdZPyGmhO2kQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="40090750" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 15:20:18 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v19 13/20] x86/resctrl: Handle removing directories in Sub-NUMA Cluster (SNC) mode Date: Tue, 28 May 2024 15:19:58 -0700 Message-ID: <20240528222006.58283-14-tony.luck@intel.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240528222006.58283-1-tony.luck@intel.com> References: <20240528222006.58283-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: 8bit In SNC mode there are multiple subdirectories in each L3 level monitor directory (one for each SNC node). If all the CPUs in an SNC node are taken offline, just remove the SNC directory for that node. In non-SNC mode, or when the last SNC node directory is removed, also remove the L3 monitor directory. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 39 ++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 6a5c35a176d5..cdcae13d6c6d 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3011,17 +3011,44 @@ static int mon_addfile(struct kernfs_node *parent_kn, const char *name, * and monitor groups with given domain id. */ static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, - unsigned int dom_id) + struct rdt_mon_domain *d) { struct rdtgroup *prgrp, *crgrp; + bool remove_all = true; + struct kernfs_node *kn; + char subname[32]; char name[32]; + sprintf(name, "mon_%s_%02d", r->name, d->ci->id); + if (r->mon_scope != RESCTRL_L3_CACHE) { + /* + * SNC mode: If the last domain is being removed, the count of + * CPUs sharing the L3 cache should be 1 (current CPU). + */ + if (cpumask_weight(&d->ci->shared_cpu_map) > 1) { + remove_all = false; + sprintf(subname, "mon_sub_%s_%02d", r->name, d->hdr.id); + } + } + list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { - sprintf(name, "mon_%s_%02d", r->name, dom_id); - kernfs_remove_by_name(prgrp->mon.mon_data_kn, name); + if (remove_all) { + kernfs_remove_by_name(prgrp->mon.mon_data_kn, name); + } else { + kn = kernfs_find_and_get(prgrp->mon.mon_data_kn, name); + if (kn) + kernfs_remove_by_name(kn, subname); + } - list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) - kernfs_remove_by_name(crgrp->mon.mon_data_kn, name); + list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) { + if (remove_all) { + kernfs_remove_by_name(crgrp->mon.mon_data_kn, name); + } else { + kn = kernfs_find_and_get(crgrp->mon.mon_data_kn, name); + if (kn) + kernfs_remove_by_name(kn, subname); + } + } } } @@ -3984,7 +4011,7 @@ void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d * per domain monitor data directories. */ if (resctrl_mounted && resctrl_arch_mon_capable()) - rmdir_mondata_subdir_allrdtgrp(r, d->hdr.id); + rmdir_mondata_subdir_allrdtgrp(r, d); if (is_mbm_enabled()) cancel_delayed_work(&d->mbm_over); -- 2.45.0