From nobody Sat Jul 25 20:48:45 2026 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 99BAE33A005; Mon, 13 Jul 2026 21:24:38 +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=1783977880; cv=none; b=e6cc8S+6Exr0AJkntOT76rRgFZuyD/KvzEvrVxscZ3GrnWJrZU51tkJED2FvJD1gezibE3YnPy4+XEM2vY8V4YqFfkWWsKEOCMp5bsoYZTGaIxLr8TpHLviGlIBe/+Os6cRJCtQY1jhm03H/qCtAbqxK8E5frPFy2aDXLA5vrlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783977880; c=relaxed/simple; bh=Q79U6MjopD0KY9Ep4H494TzYn7gvMv+nfWNdKfJl80U=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=nT8iMZA4fW25J9/e5n6JG9wih2s1JpI+s+DcI39dqqrxv+Nqz1B3oxHgZ+wxBo8VMgTHqxqApcyg23yJ5uBK9WGy+/l03cgtcrcf4sXQCjahZ1xqR8Uq0gbIrdU+hrBH0vhh7Xa38c8Lhr2j0jBdO57VbGt8b6mZ1IoeCw300B4= 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=1wcuFzyl; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=wCVxXtnZ; 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="1wcuFzyl"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wCVxXtnZ" Date: Mon, 13 Jul 2026 21:24:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1783977876; 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=xGM+Tr2uBI8htmfVczfM82mfKSoMbG+tgxPIrz/FwVE=; b=1wcuFzyl/Uu0XVAVY20RRkUowBDXPOPQ99Rln+fO95e+0P3i9hStqEWrEhqMzCAJ4IE340 auKq8WAiyxvZ1rRXTJwlr/izHLIw5p6/l3Ciq3C7Jqd25B/3TfoY5z4rixLz4bOUDmJ7Gh +iTsKFT+xl0KKDZLraxuOVioIJ22aToSeznxao+RXMX2W/EaCuiK/et/hCWOA9Gf0PPPQQ zy7oa0VQZHwPqm3ZhUhhGfx4/xtpJPbRbDlezv3hi6tLIMNz4FWy6bUdoztXrLq9PiKkUC 1Xvo6Vpg4/mzZGrwhhHaIbpDUec4bTtOqfUlPIX2QO3aa3vd5OiEggFkOpNpNQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1783977876; 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=xGM+Tr2uBI8htmfVczfM82mfKSoMbG+tgxPIrz/FwVE=; b=wCVxXtnZHzjTpUWa9DJsTkkm/YJCAj5zmP9pWtu81LqlYu+D0wry+TytIhD82Oact+AOmd QqXYH/I/Tv+PxdAg== From: "tip-bot2 for Reinette Chatre" 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: Ensure domain fully initialized before placed on RCU list Cc: Reinette Chatre , "Borislav Petkov (AMD)" , Tony Luck , Chen Yu , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: =?utf-8?q?=3C31ae67084c983e8cb8c5ef2c65e1096de5e8f9b0=2E1783963?= =?utf-8?q?505=2Egit=2Ereinette=2Echatre=40intel=2Ecom=3E?= References: =?utf-8?q?=3C31ae67084c983e8cb8c5ef2c65e1096de5e8f9b0=2E17839635?= =?utf-8?q?05=2Egit=2Ereinette=2Echatre=40intel=2Ecom=3E?= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178397787523.1844600.16336491324685293213.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: 25afd838fb2aae6325ae13937e7db06362a05673 Gitweb: https://git.kernel.org/tip/25afd838fb2aae6325ae13937e7db0636= 2a05673 Author: Reinette Chatre AuthorDate: Mon, 13 Jul 2026 10:39:42 -07:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 13 Jul 2026 13:58:30 -07:00 x86/resctrl: Ensure domain fully initialized before placed on RCU list A resctrl domain consists of the domain structure self that includes pointers to dynamically allocated filesystem as well as architecture specific data. For example, the L3 monitoring domain structure consists of the architecture specific struct rdt_hw_l3_mon_domain that contains the dynamically allocated rdt_hw_l3_mon_domain::arch_mbm_states architectural state and the embedded struct rdt_l3_mon_domain contains the dynamically allocated rdt_l3_mon_domain::mbm_states resctrl fs state. The domains are added to and removed from an RCU protected list while cpus_write_lock() is held so that readers could access domains via cpus_read_lock() or from an RCU read-side critical section. A reader accessing a domain via the RCU list expects that the domain and all its dynamically allocated data is accessible. Only place the domain on the RCU list when all its dynamically allocated data is ready, similarly unlink it from RCU list (again with cpus_write_loc= k() held) before removing any of its dynamically allocated data. Calling resctrl_online_mon_domain() before adding the domain to the RCU list creates the kernfs files that expose the domain's monitoring data to user space before adding the domain to the RCU list. This is safe because rdtgroup_mondata_show() acquires cpus_read_lock() before it traverses the RCU list and will thus block until the domain is added to the RCU list. There are no readers accessing a domain via RCU list. Ensure safety of access when such a reader arrives. Signed-off-by: Reinette Chatre Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Tony Luck Reviewed-by: Chen Yu Link: https://patch.msgid.link/31ae67084c983e8cb8c5ef2c65e1096de5e8f9b0.178= 3963505.git.reinette.chatre@intel.com --- arch/x86/kernel/cpu/resctrl/core.c | 18 +++++++----------- arch/x86/kernel/cpu/resctrl/intel_aet.c | 5 ++--- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 9c01d25..bca7820 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -515,14 +515,12 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_r= esource *r) return; } =20 - list_add_tail_rcu(&d->hdr.list, add_pos); - err =3D resctrl_online_ctrl_domain(r, d); if (err) { - list_del_rcu(&d->hdr.list); - synchronize_rcu(); ctrl_domain_free(hw_dom); + return; } + list_add_tail_rcu(&d->hdr.list, add_pos); } =20 static void l3_mon_domain_setup(int cpu, int id, struct rdt_resource *r, s= truct list_head *add_pos) @@ -556,14 +554,12 @@ static void l3_mon_domain_setup(int cpu, int id, stru= ct rdt_resource *r, struct=20 return; } =20 - list_add_tail_rcu(&d->hdr.list, add_pos); - err =3D resctrl_online_mon_domain(r, &d->hdr); if (err) { - list_del_rcu(&d->hdr.list); - synchronize_rcu(); l3_mon_domain_free(hw_dom); + return; } + list_add_tail_rcu(&d->hdr.list, add_pos); } =20 static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) @@ -642,9 +638,9 @@ static void domain_remove_cpu_ctrl(int cpu, struct rdt_= resource *r) d =3D container_of(hdr, struct rdt_ctrl_domain, hdr); hw_dom =3D resctrl_to_arch_ctrl_dom(d); =20 - resctrl_offline_ctrl_domain(r, d); list_del_rcu(&hdr->list); synchronize_rcu(); + resctrl_offline_ctrl_domain(r, d); =20 /* * rdt_ctrl_domain "d" is going to be freed below, so clear @@ -689,9 +685,9 @@ static void domain_remove_cpu_mon(int cpu, struct rdt_r= esource *r) =20 d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); hw_dom =3D resctrl_to_arch_mon_dom(d); - resctrl_offline_mon_domain(r, hdr); list_del_rcu(&hdr->list); synchronize_rcu(); + resctrl_offline_mon_domain(r, hdr); l3_mon_domain_free(hw_dom); break; } @@ -702,9 +698,9 @@ static void domain_remove_cpu_mon(int cpu, struct rdt_r= esource *r) return; =20 pkgd =3D container_of(hdr, struct rdt_perf_pkg_mon_domain, hdr); - resctrl_offline_mon_domain(r, hdr); list_del_rcu(&hdr->list); synchronize_rcu(); + resctrl_offline_mon_domain(r, hdr); kfree(pkgd); break; } diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 89b8b61..c22c3cf 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -398,12 +398,11 @@ void intel_aet_mon_domain_setup(int cpu, int id, stru= ct rdt_resource *r, d->hdr.type =3D RESCTRL_MON_DOMAIN; d->hdr.rid =3D RDT_RESOURCE_PERF_PKG; cpumask_set_cpu(cpu, &d->hdr.cpu_mask); - list_add_tail_rcu(&d->hdr.list, add_pos); =20 err =3D resctrl_online_mon_domain(r, &d->hdr); if (err) { - list_del_rcu(&d->hdr.list); - synchronize_rcu(); kfree(d); + return; } + list_add_tail_rcu(&d->hdr.list, add_pos); }