From nobody Thu Dec 18 17:45:46 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 7A9E525BAB4; Wed, 12 Mar 2025 17:20:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741800032; cv=none; b=PV/RQpkzNxmtEotmpM33tbf/5PygyphH8MHhpqF8dlEAECXYd8E8DwVBlalDKZaZTHD47lTso4KMVq8Bwq8CHPI+Qwyvv4SiVzGM8YSA5WApTKcsPdM6+4fpSzKSlHQA/rzA8zk56OrphQb83c2F5telkYl2WkW76WA24crYMIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741800032; c=relaxed/simple; bh=sGEpY/FbPMSW+WyWWKaTI2W4P9YKN/GDXHM9hNL08kc=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=aH//nPeI4rGVxRPFrDp+j1+TFjD0aufYYupc/mUT3iHmcpPMWEYBr+MLdIZapyeXs+R3txMEBI92lxNiJ/VxITubnLO1gx/ym6+ycQGU+oYdDBqXIETv9hH0Px7jl2bZPmtNxktcg/erdClCaOEsB6uSi48tI6cCWPRFu3Zud3A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=osGDAqM9; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=aVuNm4v8; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="osGDAqM9"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="aVuNm4v8" Date: Wed, 12 Mar 2025 17:20:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1741800029; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G5m5n4SC2TIcKBkCS4OfzmolVWa3HDMXCRziN3OEF9Y=; b=osGDAqM9xjcyyFEoeAkVLsD6+l/q3IVmo8WRapK4hiLajdnpGrPRyc6YZPwO4DpE7Nld6X DyJQB1WgZRK9Y52aTPaQFWVRqoEABeRUECcAhNt5bDsRTyFYSzWCocLi0rBKehYUf6qTTi Z6tY9oKy5O7dz/a68smvK19ci61/b5u63WWcJDHDs5gHapaFRQ7VFxZ3qWZmHTwhOKxIvA +EY2zdCVuYplbqj9ThaH0dynJzokgCJeylukN9NSouFd0MYUj3pG42RX/vxW5sYsrUU7Q2 MHberIHKFntJF4d2NOd03qNK2Ide8NQlkCR7J/auBFtReWL1c5YdMDyTc1wQ7A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1741800029; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G5m5n4SC2TIcKBkCS4OfzmolVWa3HDMXCRziN3OEF9Y=; b=aVuNm4v8T6JFK6ADU9WZosvXWbRlQyyUiAFK9agKgqwYrNzUhSgdz8coldu9kVtHlQVDv8 ZwwZVfAMjJnsf8Cw== From: "tip-bot2 for James Morse" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cache] x86/resctrl: Move monitor init work to a resctrl init call Cc: James Morse , "Borislav Petkov (AMD)" , Shaopeng Tan , Tony Luck , Reinette Chatre , Fenghua Yu , Babu Moger , Carl Worth , Peter Newman , Amit Singh Tomar , Shanker Donthineni , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20250311183715.16445-17-james.morse@arm.com> References: <20250311183715.16445-17-james.morse@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <174180002851.14745.13965399828209194118.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/cache branch of tip: Commit-ID: 4b6bdbf27fcee16944911155293771b880344ef0 Gitweb: https://git.kernel.org/tip/4b6bdbf27fcee16944911155293771b88= 0344ef0 Author: James Morse AuthorDate: Tue, 11 Mar 2025 18:37:01=20 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 12 Mar 2025 12:23:21 +01:00 x86/resctrl: Move monitor init work to a resctrl init call rdt_get_mon_l3_config() is called from the arch's resctrl_arch_late_init(), and initialises both architecture specific fields, such as hw_res->mon_scale and resctrl filesystem fields by calling dom_data_init(). To separate the filesystem and architecture parts of resctrl, this function needs splitting up. Add resctrl_mon_resource_init() to do the filesystem specific work, and call it from resctrl_init(). This runs later, but is still before the filesystem= is mounted and the rmid_ptrs[] array can be used. [ bp: Massage commit message. ] Signed-off-by: James Morse Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Shaopeng Tan Reviewed-by: Tony Luck Reviewed-by: Reinette Chatre Reviewed-by: Fenghua Yu Reviewed-by: Babu Moger Tested-by: Carl Worth # arm64 Tested-by: Shaopeng Tan Tested-by: Peter Newman Tested-by: Amit Singh Tomar # arm64 Tested-by: Shanker Donthineni # arm64 Tested-by: Babu Moger Link: https://lore.kernel.org/r/20250311183715.16445-17-james.morse@arm.com --- arch/x86/kernel/cpu/resctrl/internal.h | 3 +- arch/x86/kernel/cpu/resctrl/monitor.c | 40 +++++++++++++++++++------ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 22 +++++++++++++- 3 files changed, 54 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 73005ca..70fbb90 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -586,13 +586,14 @@ void closid_free(int closid); int alloc_rmid(u32 closid); void free_rmid(u32 closid, u32 rmid); int rdt_get_mon_l3_config(struct rdt_resource *r); -void __exit resctrl_mon_resource_exit(void); +void resctrl_mon_resource_exit(void); bool __init rdt_cpu_has(int flag); void mon_event_count(void *info); int rdtgroup_mondata_show(struct seq_file *m, void *arg); void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, struct rdt_mon_domain *d, struct rdtgroup *rdtgrp, cpumask_t *cpumask, int evtid, int first); +int __init resctrl_mon_resource_init(void); void mbm_setup_overflow_handler(struct rdt_mon_domain *dom, unsigned long delay_ms, int exclude_cpu); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 15e8c01..1730ba8 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1040,7 +1040,7 @@ out_unlock: return err; } =20 -static void __exit dom_data_exit(struct rdt_resource *r) +static void dom_data_exit(struct rdt_resource *r) { mutex_lock(&rdtgroup_mutex); =20 @@ -1176,12 +1176,40 @@ static __init int snc_get_config(void) return ret; } =20 +/** + * resctrl_mon_resource_init() - Initialise global monitoring structures. + * + * Allocate and initialise global monitor resources that do not belong to a + * specific domain. i.e. the rmid_ptrs[] used for the limbo and free lists. + * Called once during boot after the struct rdt_resource's have been confi= gured + * but before the filesystem is mounted. + * Resctrl's cpuhp callbacks may be called before this point to bring a do= main + * online. + * + * Returns 0 for success, or -ENOMEM. + */ +int __init resctrl_mon_resource_init(void) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + int ret; + + if (!r->mon_capable) + return 0; + + ret =3D dom_data_init(r); + if (ret) + return ret; + + l3_mon_evt_init(r); + + return 0; +} + int __init rdt_get_mon_l3_config(struct rdt_resource *r) { unsigned int mbm_offset =3D boot_cpu_data.x86_cache_mbm_width_offset; struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); unsigned int threshold; - int ret; =20 snc_nodes_per_l3_cache =3D snc_get_config(); =20 @@ -1211,10 +1239,6 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) */ resctrl_rmid_realloc_threshold =3D resctrl_arch_round_mon_val(threshold); =20 - ret =3D dom_data_init(r); - if (ret) - return ret; - if (rdt_cpu_has(X86_FEATURE_BMEC)) { u32 eax, ebx, ecx, edx; =20 @@ -1234,14 +1258,12 @@ int __init rdt_get_mon_l3_config(struct rdt_resourc= e *r) } } =20 - l3_mon_evt_init(r); - r->mon_capable =3D true; =20 return 0; } =20 -void __exit resctrl_mon_resource_exit(void) +void resctrl_mon_resource_exit(void) { struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 42c48e7..badac3f 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4102,6 +4102,19 @@ void resctrl_offline_mon_domain(struct rdt_resource = *r, struct rdt_mon_domain *d mutex_unlock(&rdtgroup_mutex); } =20 +/** + * domain_setup_mon_state() - Initialise domain monitoring structures. + * @r: The resource for the newly online domain. + * @d: The newly online domain. + * + * Allocate monitor resources that belong to this domain. + * Called when the first CPU of a domain comes online, regardless of wheth= er + * the filesystem is mounted. + * During boot this may be called before global allocations have been made= by + * resctrl_mon_resource_init(). + * + * Returns 0 for success, or -ENOMEM. + */ static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_mon_d= omain *d) { u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); @@ -4252,10 +4265,16 @@ int __init resctrl_init(void) =20 rdtgroup_setup_default(); =20 - ret =3D sysfs_create_mount_point(fs_kobj, "resctrl"); + ret =3D resctrl_mon_resource_init(); if (ret) return ret; =20 + ret =3D sysfs_create_mount_point(fs_kobj, "resctrl"); + if (ret) { + resctrl_mon_resource_exit(); + return ret; + } + ret =3D register_filesystem(&rdt_fs_type); if (ret) goto cleanup_mountpoint; @@ -4287,6 +4306,7 @@ int __init resctrl_init(void) =20 cleanup_mountpoint: sysfs_remove_mount_point(fs_kobj, "resctrl"); + resctrl_mon_resource_exit(); =20 return ret; }