From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 BEF06390C85 for ; Wed, 29 Jul 2026 17:28:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785346093; cv=none; b=Yz1LxhKOYEvBrLlIqX5/C/92R3Zi1jP9eT9kxtq2BSv3DXS6fOWiuAvsV7SUBPvGUuqMowOBnNWLsyBLkQMyIGM9ARooji7te+UnrYtqCQiX9EQtrN841uFkmJIq7Ooq3e7ApXj+wn3gXLG1zdZC4b0/0+992gmYq/ctUWiCJI0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785346093; c=relaxed/simple; bh=1FdEg/UZ9Xp0GoVXeNtjBirJm6FyFDzslgcIi6zqvZE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=heWAtKtBZF9Am2WImxKjNjxBEIdErvpUB4BBy508i97UVM9gqNXxbqBGu7/AQacK1UMiU6R3P7VhcMlRAIM67jmTy5w8iaETJ3+AVak6a+8gKXYBnxPpz3idE1m0n4nFTXXYh/fxWKk7Qf+nqK5fqN470m+xmndzC+ajH0D8n6I= 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=NDTF+ODK; arc=none smtp.client-ip=198.175.65.12 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NDTF+ODK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1785346091; x=1816882091; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1FdEg/UZ9Xp0GoVXeNtjBirJm6FyFDzslgcIi6zqvZE=; b=NDTF+ODKxaeRfKWj8lQkRBRH3ii7jfHvJDAjLszkTySTMbpuQkvrNgWM ibNlEc/PGFtfdapJQp2X0VGNBsELfw1Q7hgmeASvr+wMluhY7Z+VzkWCG WVY2B178zf/1FUAaVhXi4IS+h1F1y/7q/ouRs66inbmcTwE/Gyyv/Ayu4 X9x5rxFdCHf20+S4+l1R0qCzlJBvCXYl/Obb8WW78ySsy1GG4AEyr8e96 DN122kPCSSol+YhsWUkMvdlqT/HCErOxdkOhxvfXWdJMQkxwmTp+rtrnJ TcE2MK0XWnzwRBz5ohI9iaWmHlwzMw8WrXswD8Pm+/Yr3FKpi6qOkICv6 g==; X-CSE-ConnectionGUID: f0UjY1pXQoGyZ3i7U5AhkQ== X-CSE-MsgGUID: 1cBYr88jRIyZy2hpz/QBGg== X-IronPort-AV: E=McAfee;i="6800,10657,11859"; a="97473671" X-IronPort-AV: E=Sophos;i="6.25,192,1779174000"; d="scan'208";a="97473671" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2026 10:28:03 -0700 X-CSE-ConnectionGUID: l03TEhNIRIyAyRqQ1uo1oA== X-CSE-MsgGUID: Mc4FLG6/QZ6hd8Bxw63yLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,192,1779174000"; d="scan'208";a="262024610" Received: from iherna2-mobl4.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.238]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2026 10:28:02 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v10 13/17] fs/resctrl: Call architecture hooks for every mount/unmount Date: Wed, 29 Jul 2026 10:27:48 -0700 Message-ID: <20260729172752.11561-14-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260729172752.11561-1-tony.luck@intel.com> References: <20260729172752.11561-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 The intel_pmt module should only be pinned while the resctrl file system is mounted. Add hooks for every mount/unmount of the resctrl file system so that architecture code can increment the intel_pmt module reference count on mount and decrement on unmount. Signed-off-by: Tony Luck --- v10: Don't call resctrl_arch_unmount() when failing a nested mount. include/linux/resctrl.h | 2 +- fs/resctrl/rdtgroup.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 65245f2fdad0..1e4ca75a02de 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -576,7 +576,7 @@ void resctrl_online_cpu(unsigned int cpu); void resctrl_offline_cpu(unsigned int cpu); /* - * Architecture hook called at beginning of first file system mount attempt. + * Architecture hook called before attempting to mount the file system. * No locks are held. */ int resctrl_arch_pre_mount(void); diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 0a9645c35f43..6f12537f89b7 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -3166,6 +3165,8 @@ static void resctrl_unmount(void) resctrl_mounted = false; mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); + + resctrl_arch_unmount(); } static int rdt_get_tree(struct fs_context *fc) @@ -3175,9 +3176,11 @@ static int rdt_get_tree(struct fs_context *fc) struct kernfs_node *rdt_root_kn; struct rdt_l3_mon_domain *dom; struct rdt_resource *r; + bool cleanup = true; int ret; - DO_ONCE_SLEEPABLE(resctrl_arch_pre_mount); + if (resctrl_arch_pre_mount() == -EBUSY) + return -EBUSY; cpus_read_lock(); mutex_lock(&rdtgroup_mutex); @@ -3186,6 +3189,7 @@ static int rdt_get_tree(struct fs_context *fc) */ if (resctrl_mounted) { ret = -EBUSY; + cleanup = false; goto out; } @@ -3316,6 +3320,10 @@ static int rdt_get_tree(struct fs_context *fc) out: mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); + + if (cleanup) + resctrl_arch_unmount(); + return ret; } -- 2.55.0