Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp304767lqo; Wed, 15 May 2024 15:26:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX25h4g77UUJZ6GGPOHjy4Das2Ik2WALN8XALfyOwZqDuBIhfDHs3J0ZQ5gQDCa6mPe1PobJXC3zk1HxiMnYB+fHmyJmkM5SUUF8ub1nQ== X-Google-Smtp-Source: AGHT+IExxOEcjkS23hqzLiqBXQqV/ReLkDckrd9XvGilhLtzqySpW6N4MBX/fVvVVSdILdUE7kiv X-Received: by 2002:a17:90b:124b:b0:2b2:aac3:fc2f with SMTP id 98e67ed59e1d1-2b6cc76d796mr17520650a91.18.1715811977399; Wed, 15 May 2024 15:26:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715811977; cv=pass; d=google.com; s=arc-20160816; b=aTVG4UVmQKmWKMoV0jmDdlOoljdXx2ywBc+V2sP/9hbjGnPyBOpDWAvygUePFJeTiZ i3sdrzd/5ANpesSdXrvPTROQmnhJFfrwISXS4lLCTj62C+BYjk4JfJs1EX9/hLjD0tEw Mq5CPM1Mu91tfSt4YA2WmmSy0Tuf3zOTO+3bdUthNvPBu4U/WaCY/JE2+INixK5ss+Rr tpHsUTvMWzW5ELreN9rCOWsovrZxn5dvhc+/Qhy0QATOPM2civKRBbOk73UACSXfx+mx RNev/aVnmGC92omLoaAjc6xyYKrFqJM/F545rRF8qBPD7G6d1tqlnvccmhKKrFC73ksG 7L3g== 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=VcT26LzBX/g0YgaxI/JRGXgrgz6r9bVRLLc+yXlXPZA=; fh=qTx768JYq6oxdX3jfjUzjJGF83d0IKGtQzHdow3lchk=; b=sXZng6NZVevRcKQCUAsw1S3UQ00z+pZdLNmH94tlKcAT4XEco7+wp1OEtv7HKu5y5/ FfyZiEljtXYt9JChXeBfqCfJpRzQa1Q2W4tc69rWfqmUGqFLQ+x4IalmX6JSA2Yc781R CrNoM+ttihTra3jABCouwF5Of41CC4LHtTGY9m4BxRCSOKX2sGahnfwux7G5+4ERShJ0 dO39AkOTNzJviLPBNATUSA2aVpBMbUUOWVO41INyyzWqNzw90uzalizAKk4rO+WXqnkJ vCabsi5zn0U2rg7xTVJRw0IiLWI0ehxE0p8uuS5T4rI0kaPi1+yBhJDXP4G6Ct4nRNT/ 9agQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=feFLF2Fa; 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-180437-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180437-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b670f585fcsi13906531a91.69.2024.05.15.15.26.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 15:26:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180437-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=feFLF2Fa; 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-180437-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180437-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 0C5A5B232CE for ; Wed, 15 May 2024 22:25:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DBD4615B97E; Wed, 15 May 2024 22:23:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="feFLF2Fa" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 735FB15D5A9 for ; Wed, 15 May 2024 22:23:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715811825; cv=none; b=W3idwu9W8w26N+N8qWKFCbIgOdk6nyuJq76CurH4lJpHdkWtDtA6Qw/vRbeIyiDpBF7RkGN+dWCm67r7tJn6KR0cp+P9j8tdRtHzEXJnCo1HmqDxS5YjBnQYAO3RMDmBajkH2f0m6lIbQqsn9P8lvM794qYf/vNQVUvPlR8JOBw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715811825; c=relaxed/simple; bh=czKlljQin5GaFm+0xyDc9Vi3UAAxcA5z/t7zvNVeNeg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ef8LcVu0IATmmjYuxel046UIyrCywIFoUaAMtiPFiJDmR/XgMVlzn7yI3M2YWeYBLWp2axnDPLxKTx2qZD3Oi4SLkLinfCX2S59IxJe7Sv1UEz2sTPO0uT+WeMjp8E4I3W235JN4Qv0NWj/9wtIqNGoEu9gzX0c22MiiRBGVBS0= 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=feFLF2Fa; arc=none smtp.client-ip=198.175.65.15 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=1715811823; x=1747347823; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=czKlljQin5GaFm+0xyDc9Vi3UAAxcA5z/t7zvNVeNeg=; b=feFLF2FaNGyoqWSsUehC/d5IQbkASeyrNiV8yZBDJuLOMbZf39e03k3W a4HisqVpoIYbvZVzA4YmBxvpGKGRANEnZYnX00M4SYJrP7xTt2lygVBHq 7Gjwfstn4SexvCFzLB9f0W1NgU+oCIsAKcJE5N1toKbVb6OYpMXI629YN 64xqYpJ+ovcC5uu2k6MYsLN3eIUYXnseH2CtL5Az9k3eGb1jj82pU6vzl vWgmqtrsgA6Oq4IBmluiwz3hEWusH67JZ8rSkbzArmEmg2lhqfSMFLk3Y wkrQ788SrGHtN71BUte6uWt/mugXKdbw1GILR50QdMPm1+OxuDBQkBul2 A==; X-CSE-ConnectionGUID: rucaQbfzTcCKwQtcKA6Smg== X-CSE-MsgGUID: IzF8R/H6RsG/PTvyYqwyZw== X-IronPort-AV: E=McAfee;i="6600,9927,11074"; a="15671703" X-IronPort-AV: E=Sophos;i="6.08,162,1712646000"; d="scan'208";a="15671703" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 15:23:36 -0700 X-CSE-ConnectionGUID: wQcXbIbCQlu9THH8nuwuIw== X-CSE-MsgGUID: tzW/IxadRhSXp+MSTRFJcg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,162,1712646000"; d="scan'208";a="35989187" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 15:23:36 -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 v18 13/17] x86/resctrl: Handle removing directories in Sub-NUMA (SNC) mode Date: Wed, 15 May 2024 15:23:21 -0700 Message-ID: <20240515222326.74166-14-tony.luck@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240515222326.74166-1-tony.luck@intel.com> References: <20240515222326.74166-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, then just that SNC node directory must be removed. 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 | 43 +++++++++++++++++++++----- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index f0f468babdea..cac32ddd3afd 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3011,17 +3011,46 @@ 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; + struct rdt_mon_domain *dom; + bool remove_all = true; + struct kernfs_node *kn; + char subname[32]; char name[32]; + sprintf(name, "mon_%s_%02d", r->name, d->display_id); + if (r->mon_scope != r->mon_display_scope) { + int count = 0; + + list_for_each_entry(dom, &r->mon_domains, hdr.list) + if (d->display_id == dom->display_id) + count++; + if (count > 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_ns(prgrp->mon.mon_data_kn, name, NULL); + 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_ns(prgrp->mon.mon_data_kn, name, NULL); + if (kn) + kernfs_remove_by_name(kn, subname); + } + } } } @@ -3111,8 +3140,8 @@ static int mkdir_mondata_subdir(struct kernfs_node *parent_kn, static void mkdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, struct rdt_mon_domain *d) { - struct kernfs_node *parent_kn; struct rdtgroup *prgrp, *crgrp; + struct kernfs_node *parent_kn; struct list_head *head; list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { @@ -3984,7 +4013,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.44.0