From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 C72843101A6 for ; Fri, 20 Mar 2026 22:03:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044237; cv=none; b=p7EKO20z2cildEFWtveVKxeJp+GKyzlWt65N1w7fSRGimGX0og57QQgoRLDJqUmR4VQwRt04fXmIN0YeC54+JyEfAkoG+7aYpyxhLjP36JIoiWGtXV8tH/KR+hajJu+KR3bvxwAfmeZyDcWb8lbqM5i8nYfjPpR1nW/pyUhwe7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044237; c=relaxed/simple; bh=2r426URiTXvlx3tT0QDuPcVGD3bn2C8Tq1rwhDsXsgo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fvvMLsergzmvdykMuRFKagjs+bxfZCiPT2eeBxyi121UmPv3B0LH4dJ3x1TfXynqdxinRNW0kpDCGSf9DktboSWh9oheH0Grw5ZP6cvE+7cMqS02f1ZumZhps81i4p/ax1g8jHEcKvfiSzU0rAoNzqcRvGVeHKb8FcEKpbUVs2k= 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=Hh7t11LD; arc=none smtp.client-ip=198.175.65.9 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="Hh7t11LD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044234; x=1805580234; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2r426URiTXvlx3tT0QDuPcVGD3bn2C8Tq1rwhDsXsgo=; b=Hh7t11LDonCgD7L+mJO4WlLxolXuxorhSTsooRuVzGwlw4+EpV0kAB7z 1nx3HA/slDApWt1Xj9R8PvZzhcCFEPBA6GaIctK1ywAJj2Zs1PRnllhoA MtwKmxmOWcJmVlOfiLexdmpfJIK1L2VBwuT91CV88SQWOHO9fK/Y09Xa7 1Hw9XVbhqgdxuJ4AgBD7d0J6cBvlT4KOuL8vnqCeLr0lf3SSgLz2Yt8Lf 0v0ULgjA4EcfB7Zqije/mbUY4c+akn1lvJRO5/W9b1hnnESoG2RStVVDj 7NgWVbB+4IzDhXEltdzsBTibhVpENMhnXUyJstEJvLLOqNzM/XvezxkoE w==; X-CSE-ConnectionGUID: w83HUUMQTBK77E6mHXrfbA== X-CSE-MsgGUID: YROQFboSQm+uWaFUx3Qt+Q== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758340" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758340" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:53 -0700 X-CSE-ConnectionGUID: /BRBff0JSgi+kMQRwu62aw== X-CSE-MsgGUID: 0iA09wfkTOOGB4Jo0h3t0Q== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:53 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 01/14] MAINTAINERS: Update resctrl entry Date: Fri, 20 Mar 2026 15:03:11 -0700 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The x86 maintainers handle the resctrl filesystem and x86 architectural resctrl code. Even so, the x86 maintainers are not part of the resctrl section and not returned when scripts/get_maintainer.pl is run on resctrl filesystem code. With patches flowing via x86 maintainers resctrl should also ensure it follows the tip rules. Add the x86 maintainer alias, x86@kernel.org, to the resctrl section to ensure x86 maintainers are included in associated resctrl submissions. Add a reference to the tip tree handbook to make it clear which rules resctrl follows. Signed-off-by: Reinette Chatre --- Changes since v1: - Add reference to tip tree handbook to follow similar change to other tip subsystems: https://lore.kernel.org/all/20260305212215.3188399-1-dave.hansen@linux.in= tel.com/ --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 77fdfcb55f06..622d17046db5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22134,11 +22134,13 @@ F: tools/testing/selftests/net/rds/ RDT - RESOURCE ALLOCATION M: Tony Luck M: Reinette Chatre +M: x86@kernel.org R: Dave Martin R: James Morse R: Babu Moger L: linux-kernel@vger.kernel.org S: Supported +P: Documentation/process/maintainer-tip.rst F: Documentation/filesystems/resctrl.rst F: arch/x86/include/asm/resctrl.h F: arch/x86/kernel/cpu/resctrl/ --=20 2.50.1 From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 CF16631714C for ; Fri, 20 Mar 2026 22:03:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044237; cv=none; b=h9Rparp0V0iXGU5u5D7nVDyVbeAwYzv9BRrHr1Xd5gnl0rbd3CaFB2zvx7O4Hft6pXUaxY19NJnUCEJja84jtU1s4oGQvLu/aYtYaAVvN8i3x52PXWBtaiSda9X5GwM/1dtR71Y3q+rsGOsdOusnlr4ey6bQnRLwIPVFRJ29mNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044237; c=relaxed/simple; bh=+S/4TGzCCyx9HY4E3iHxxpFMHM+peJEtYrBOdwsV+tM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ddYDHC1ybD2diMxfGD6V0ODYdVn6ZFCiODkATVvWOyxMKNSIwb37Z3RTZqi81vIYjeUnazDIAoCl40T/1U2n9U9NhTd5DgiAvvA1b4MBgLocIrkfsskOKQ4JAKeBP1ELnWfehZfh/dOsMdkxwhJRGMMAtLCkmEGOd44DTGoMMSo= 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=BZGxcbrJ; arc=none smtp.client-ip=198.175.65.9 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="BZGxcbrJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044236; x=1805580236; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+S/4TGzCCyx9HY4E3iHxxpFMHM+peJEtYrBOdwsV+tM=; b=BZGxcbrJ81VfH0mV3ftN0SA1ASuwKd7HnzrIl6rxSQ0LYjM87+xkSjSp lOFiYMZfAVkF6sYfayq1aPmJcsktlLXEB1PxfRAZMZbsoWbYsZGzqL0xx Qtfc0iM4iQIk+S/6OeHStv9FSlwcyDGLe/MDv1LWT4tms2jM2d8JlGj0H X8ahbzXzFbWdjukaFUIDtrAAtZqIHI6IlLp+ag8CjObCKK+4MY514P9jR UDWIBPQvF4pn4yBH6oFsp9f3t/P0ogcJp7y+vTEwZd14pACfV6fcMRMy+ C4W02i9vOn5lO1YzjXLEsWIsZBmfM9bEdHhiP95XFelGDtKWzS9nB/4U3 w==; X-CSE-ConnectionGUID: nhI/yyRSTQmFksD0uYKRcg== X-CSE-MsgGUID: 177ETFn5R2ihTcizr+A0Gw== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758346" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758346" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:53 -0700 X-CSE-ConnectionGUID: oa2KjgbzSKuaMUPzDUTG2Q== X-CSE-MsgGUID: gHKT/FcnQgeAiYavngLJng== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:53 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 02/14] fs/resctrl: Add missing return value descriptions Date: Fri, 20 Mar 2026 15:03:12 -0700 Message-ID: <4261365d3cba00afbe846dc85fb4a3386eb5feb2.1774043709.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Using the stricter "./tools/docs/kernel-doc -Wall -v" to verify proper formatting of documentation comments includes warnings related to return markup on functions that are omitted during the default verification checks. This stricter verification reports a couple of missing return descriptions in resctrl: Warning: .../fs/resctrl/rdtgroup.c:1536 No description found for return= value of 'rdtgroup_cbm_to_size' Warning: .../fs/resctrl/rdtgroup.c:3131 No description found for return= value of 'mon_get_kn_priv' Warning: .../fs/resctrl/rdtgroup.c:3523 No description found for return= value of 'cbm_ensure_valid' Warning: .../fs/resctrl/monitor.c:238 No description found for return v= alue of 'resctrl_find_cleanest_closid' Add the missing return descriptions. Signed-off-by: Reinette Chatre --- fs/resctrl/monitor.c | 2 ++ fs/resctrl/rdtgroup.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 49f3f6b846b2..9fd901c78dc6 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -234,6 +234,8 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 cl= osid) * * When the CLOSID and RMID are independent numbers, the first free CLOSID= will * be returned. + * + * Return: Free CLOSID on success, < 0 on failure. */ int resctrl_find_cleanest_closid(void) { diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 5da305bd36c9..111bff8e33fd 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1519,6 +1519,8 @@ static ssize_t rdtgroup_mode_write(struct kernfs_open= _file *of, * * @cbm is unsigned long, even if only 32 bits are used to make the * bitmap functions work correctly. + * + * Return: size in bytes, 0 on failure. */ unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct rdt_ctrl_domain *d, unsigned long cbm) @@ -3102,6 +3104,8 @@ static void rmdir_all_sub(void) * @mevt: The type of event file being created. * @do_sum: Whether SNC summing monitors are being created. Only set * when @rid =3D=3D RDT_RESOURCE_L3. + * + * Return: Pointer to mon_data private data of the event, NULL on failure. */ static struct mon_data *mon_get_kn_priv(enum resctrl_res_level rid, int do= mid, struct mon_evt *mevt, @@ -3496,6 +3500,8 @@ static int mkdir_mondata_all(struct kernfs_node *pare= nt_kn, * resource group is initialized. The user can follow this with a * modification to the CBM if the default does not satisfy the * requirements. + * + * Return: A CBM that is valid for resource @r. */ static u32 cbm_ensure_valid(u32 _val, struct rdt_resource *r) { --=20 2.50.1 From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 D8BF231E83E for ; Fri, 20 Mar 2026 22:03:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044239; cv=none; b=mgEZl+EHa00RPmsBd4p0JERYlq9cxz0X+nfEgEhHVSJOywOmRZenpoOcjjczJaMKuNV/eYsEqilBiRGce6pfrjf/y9pSFJ3y8cJfKB1KLDdlYMa+fK5R92cfnGyOasEARqY9VT/+APb6cqWbWVyX7Ywx+ChW8LFnAUeJLAx1hgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044239; c=relaxed/simple; bh=v12I4fNHeG9jvYo3wUAhnOp8GtSP5lv3bu1tJwepx+o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fBwc9LRUFEWiiMRbXgCdi6cxcd/9f6DW0D9O4GI4Zbs0w59P+5QTIKM1muDhEpAFg/88vcvlwt0AoKjICcsTsZQUjvlaJpUDD985n9acNsf5dJ5/e5immsxnj31a9az9KQwF4Fz0GROTKGvabmEe07cuM2nV216oD7/BCfLXL9U= 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=bIbPlLpO; arc=none smtp.client-ip=198.175.65.9 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="bIbPlLpO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044237; x=1805580237; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v12I4fNHeG9jvYo3wUAhnOp8GtSP5lv3bu1tJwepx+o=; b=bIbPlLpO1ABd5v/a/8vRq7OeCLQOrEeICEp+yw43VLZ342tkn5HotL/3 wxKel77+bAL4SKZtVOHtAEDx6xrBHPc5bhs6o6A6QHF2Nms1uDr+6+6j4 DfuS5FAQ8EFHx9wvRrjV75/GQEzf88m8iWfLlyyxz46Zj64x84X0DC0QO CKh2mdtaMLxwsD8cYAyM32UCfVtAxUCnAB2CZnOuhRZH84+Ve1mN3+uHb kMMVz9tTHm1UPkDaR/jGlNw3UWKmGFEIXDvx7Ig/LrmjwwKGc6/FDo37X c7S0VONtWCfgKEtiYxQG+ABsp0hDVlqI6XE4zFbEUFOX7JKzAfDAkSrZa w==; X-CSE-ConnectionGUID: Cdye8UIgSHSLwD8nBB+kmQ== X-CSE-MsgGUID: UYkhkZC+TriI1sc98AEiFA== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758354" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758354" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:54 -0700 X-CSE-ConnectionGUID: juNpR+9uSgqXmYawAE9nYA== X-CSE-MsgGUID: cLgOUIwQQSaNyYlEim28OQ== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:54 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 03/14] fs/resctrl: Avoid "may be used uninitialized" warning Date: Fri, 20 Mar 2026 15:03:13 -0700 Message-ID: <0e64fcf4e6be27a1144e569f591f2bbd54eb7ccf.1774043709.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Building resctrl with extra checks ("W=3D12") produces the following warnin= g: .../include/linux/ucopysize.h:22:17: warning: =E2=80=98buf=E2=80=99 may be= used uninitialized [-Wmaybe-uninitialized] 22 | __check_object_size(ptr, n, to_user); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .../include/linux/ucopysize.h: In function =E2=80=98pseudo_lock_measure_tr= igger=E2=80=99: .../include/linux/ucopysize.h:10:13: note: by argument 1 of type =E2=80=98= const void *=E2=80=99 to =E2=80=98__check_object_size=E2=80=99 declared here 10 | extern void __check_object_size(const void *ptr, unsigned long n, | ^~~~~~~~~~~~~~~~~~~ .../fs/resctrl/pseudo_lock.c:754:14: note: =E2=80=98buf=E2=80=99 declared = here 754 | char buf[32]; | ^~~ __check_object_size() ensures the provided buffer is within a valid location but does not read from the uninitialized buffer. Even so, initialize the buffer to silence the warning to help resctrl have a cleaner build. Signed-off-by: Reinette Chatre --- fs/resctrl/pseudo_lock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/resctrl/pseudo_lock.c b/fs/resctrl/pseudo_lock.c index fa3687d69ebd..e1e9134474f4 100644 --- a/fs/resctrl/pseudo_lock.c +++ b/fs/resctrl/pseudo_lock.c @@ -750,8 +750,8 @@ static ssize_t pseudo_lock_measure_trigger(struct file = *file, size_t count, loff_t *ppos) { struct rdtgroup *rdtgrp =3D file->private_data; + char buf[32] =3D {}; size_t buf_size; - char buf[32]; int ret; int sel; =20 --=20 2.50.1 From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 1CC9F314B66 for ; Fri, 20 Mar 2026 22:03:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044239; cv=none; b=KQZgYi/L1ef5voqzgb0+5PVpXVUt5uvrl8WeGb4kJ4A539P62iTxdKC/b/G6BE5e54a3BKntjAWypuxf3hChJIVqaDVM45CoIjz7TdpX+Dz4t9P+ry3rbrb7UDXDLV5gvtEE3E1dOe1DxCH/lxG+XUZuTvrSm1aVo4zj+o2pkiQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044239; c=relaxed/simple; bh=dxMeQSQAI9H8hX2jXObajzEdPFMeYDHhhrSWJaEFRwc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gkzHo/C/QlumdZCdN0lftywzFcsjhYeYKdTxKCDYbzgTntXKIZmNkPJ28HMQFmwaGjVJjeKaVaHND/1taSEUFMGr5XWKWsSRAJQYrWjR7dNr4Ci0r2lHqXJPs8ezv087ALHRYKXu8JopHyQiCdGLynuzH6x+OeSu9qinxR/vjAs= 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=Czdm6Chd; arc=none smtp.client-ip=198.175.65.9 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="Czdm6Chd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044237; x=1805580237; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dxMeQSQAI9H8hX2jXObajzEdPFMeYDHhhrSWJaEFRwc=; b=Czdm6ChdWdaIvKxZ74I6RUi2EM1Lpfxpm7jJ+dzzWldmNm4PLFeTPkIN 6Q6gjj2CNQHownRtrTnegVJE0rJUHzU/vmT51w3WsxY8M1RVQcNzqJYoz xgbZVMmsNykw4EsKckFj7d8Q5IM1obS101p+5kT2vKIkQOOdP+lUTmAqJ S3bWIMl9GL1HKHZXPHpmRMPcC5FmtBH4CrrocaBjBuODX0Gf96Yf/qAYC nJfJhzAt1VRSBLOzWtzVFAdpjXie9bKBWWAxE5+icB+AvJaTZEmJiURXC BJCGG+7GBi4k9NId/ipRUzsN5SHrxt3fbC4GwY1YX/5rV2nJzDdiehYZU w==; X-CSE-ConnectionGUID: /WS55ZOISPSg1woaV5xkzg== X-CSE-MsgGUID: u0IHqgAhSsyL77+gZtQM6g== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758364" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758364" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:54 -0700 X-CSE-ConnectionGUID: kjgW30mDRiqcqnbSuLmq9w== X-CSE-MsgGUID: D1js8yzHTdK8hJxtnJ6ogA== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:54 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 04/14] fs/resctrl: Use correct format specifier for printing error pointers Date: Fri, 20 Mar 2026 15:03:14 -0700 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use correct format specifier for error pointer as coccinelle suggests: .../fs/resctrl/monitor.c:148:8-15: WARNING: Consider using %pe to print= PTR_ERR() .../fs/resctrl/monitor.c:760:9-16: WARNING: Consider using %pe to print= PTR_ERR() Signed-off-by: Reinette Chatre --- fs/resctrl/monitor.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 9fd901c78dc6..8194fdfbea81 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -144,8 +144,8 @@ void __check_limbo(struct rdt_l3_mon_domain *d, bool fo= rce_free) arch_priv =3D mon_event_all[QOS_L3_OCCUP_EVENT_ID].arch_priv; arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(r, QOS_L3_OCCUP_EVENT_ID); if (IS_ERR(arch_mon_ctx)) { - pr_warn_ratelimited("Failed to allocate monitor context: %ld", - PTR_ERR(arch_mon_ctx)); + pr_warn_ratelimited("Failed to allocate monitor context: %pe", + arch_mon_ctx); return; } =20 @@ -752,8 +752,8 @@ static void mbm_update_one_event(struct rdt_resource *r= , struct rdt_l3_mon_domai } else { rr.arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(rr.r, evtid); if (IS_ERR(rr.arch_mon_ctx)) { - pr_warn_ratelimited("Failed to allocate monitor context: %ld", - PTR_ERR(rr.arch_mon_ctx)); + pr_warn_ratelimited("Failed to allocate monitor context: %pe", + rr.arch_mon_ctx); return; } } --=20 2.50.1 From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 D152532C923 for ; Fri, 20 Mar 2026 22:03:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044239; cv=none; b=HjIFHA4GaFaA3UhhaTRLSlGKU3P+KKj494SxpXJiJF3G9Nr3iOTwYaNu7bm5X5py016P+hrSnnjMI5xd/F4IdxHUKLiECc57QxLqPgcIKkCec3oT6NIjRL2GKhoFgYVnPXVHLUkm3NoNX8CAFSgeYE5IO5WfNG1JkMbokgSIPo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044239; c=relaxed/simple; bh=XQbrDtV7kC3BagIoRNk2xRfz81oxluInULTjgTirvbA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OxQnWC/TJhbfM5r/cXwwfT177agvkTZ5NTFZFLV34nL5oJ1w9xRKSV+YxH0bWg5H9laiBCEQ8MlcuSYNCpPIuxy55r48zpob6uUWD2LDOPuYuWTYrsgjwharJuZ/UE5sbPVDntrSkLOLhcuv21BpQBl0SiFVewsKHX4CEtnsaSc= 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=HZ/EI0mP; arc=none smtp.client-ip=198.175.65.9 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="HZ/EI0mP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044238; x=1805580238; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XQbrDtV7kC3BagIoRNk2xRfz81oxluInULTjgTirvbA=; b=HZ/EI0mPGs24b7tJ+78ZKq/G8yqHlVx5oRBNR9O05tPMjcJ5GVm+bm82 Xd3PD4ReS+KPtJYfc6gSPSnDHRYdlec8ukpiHBK4yk1zmQgmpWpR4xMF6 ftovKmWj4WLkCVaUHclnyx7+gdjILss2Mre44AWgbDU3RssZef5yHQfg+ ki+F0d+0DKrCRkO2CnjKT2pXfCqWNhfuyh1f5dYbhtg30qYIEco1wCguh lWDbJwh7UFusUl7G/47QgbdFs7UPqfHSlCxvuoluef+mv/GBaYzhGP6+l V00vbTzsT6Qlsvno7VZdm0BhPnlcRlPJoPNYvHdey+oMo41BGm8GfA42D g==; X-CSE-ConnectionGUID: /pH95JCbRoyuY1Kz1nd7NQ== X-CSE-MsgGUID: iQUFAuInSri2Kl9aunqz6w== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758374" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758374" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:54 -0700 X-CSE-ConnectionGUID: Ry5l89fCQ6C2vcyNccHOEQ== X-CSE-MsgGUID: TaiTYti/QPGKR/HrGD1zAA== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:54 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 05/14] x86/resctrl: Protect against bad shift Date: Fri, 20 Mar 2026 15:03:15 -0700 Message-ID: <18825382dd74ef5d7c7871a269204ec236da4790.1774043709.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The size of the bandwidth specifier field is enumerated from AMD hardware. resctrl uses this field width to determine the maximum bandwidth supported that is stored in resctrl_membw::max_bw to which user space allocation requests are compared for validity. resctrl_membw::max_bw is of type u32 while the register containing the bandwidth specifier field, L3QOS_BW_CONTROL_n, is 64 bits. While not an issue with current hardware it is theoretically possible that enumeration of maximum bandwidth may trigger invalid behavior if a future system can use a bandwidth specifier field larger than 32 bits. Whether this could ever represent a reasonable bandwidth value is unknown but addressing the issue will appease static checkers. Ensure resctrl can accommodate the hardware's bandwidth specifier field width with an additional check. Switch to BIT() instead of open-coding the bitshift to avoid signed integer overflow if the number of bits is a valid 31. Signed-off-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 7667cf7c4e94..db787c4dee61 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -246,7 +246,9 @@ static __init bool __rdt_get_mem_config_amd(struct rdt_= resource *r) =20 cpuid_count(0x80000020, subleaf, &eax, &ebx, &ecx, &edx); hw_res->num_closid =3D edx + 1; - r->membw.max_bw =3D 1 << eax; + if (WARN_ON(BITS_PER_TYPE(r->membw.max_bw) <=3D eax)) + return false; + r->membw.max_bw =3D BIT(eax); =20 /* AMD does not use delay */ r->membw.delay_linear =3D false; --=20 2.50.1 From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 9AB1831F9BD for ; Fri, 20 Mar 2026 22:03:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044242; cv=none; b=BYwL99GHDYoCYktSBiXIp1T2l0inFiCWTrtHfPGEoTRFuDK0xMvQcU6Uv1B5DYR7d+kbMVGjdMZgoaTEnZFC4c4L27tI224/cMIOI1WA3rwVZfNDCdvFKdxzqMMAEjAqS12sufkre5ndm/Y8tmQ4A1Lu9zby6vC9z3YEnBPg+1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044242; c=relaxed/simple; bh=oQkNYBpCA5AlmfxOePF5QgebJUzdQ5GMSBoc3afjB/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=co6xQjf5bfiv4S7sO1NXj/ZzxkdNp+GYIKJ6mLr+FIEZEUFgrPHZysnOOsxb/pAEY8VEGeM0mcPDMgo5LVmeNyIAruAFRjciDjfY1+DHWElkknpog7L1Y3Dbu7zVUh+yN81Kg6aSFaPZM/d6AgLx1rR+2s60oCa05Q7p7xBZJSo= 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=cnn19xi0; arc=none smtp.client-ip=198.175.65.9 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="cnn19xi0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044239; x=1805580239; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oQkNYBpCA5AlmfxOePF5QgebJUzdQ5GMSBoc3afjB/0=; b=cnn19xi0lI1252cICeTGX7tm/5qXHSFD8MTEzwomFunebDFDg8axW62a zUCAmIYFAFas4FH6DeuZIM3JmF2pY3E5Uyy2uqHZ+V88oNowL/LykXqa8 MUaRTJhI6lVHRgc64TM9w7qwgGdzLO/lirG2MAO02VRCoFndg79ErSUSG ntEB/7i/vyukgVk9z5/JzoPs2YFxoBt3hxKzUk/eqCok4wpB4pPVDhars zPEVSjlWbwAcZX5hZfz56hjmxh4hGExNYbQJqE8DtBC/nDpVXmT5brdGI 7qly6gpnO+D8ouIa7FBcOXEDb+7uEI/GMzCBFPzhIxw+ed5REj1c8PXE3 g==; X-CSE-ConnectionGUID: TnSAf8nuSV+z3odqGcKOXA== X-CSE-MsgGUID: qyqQP8ZwTo2gomEDfaUwFA== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758385" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758385" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:55 -0700 X-CSE-ConnectionGUID: HO/vQbH8QjWM/x/xTzQ2jw== X-CSE-MsgGUID: yAJt7dBiRZahamLcz6rihA== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:55 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 06/14] fs/resctrl: Change pattern used to track number of entries in enum Date: Fri, 20 Mar 2026 15:03:16 -0700 Message-ID: <24b86569a2d3428f7fddf3572adebaec909e696e.1774043709.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" CDP_NUM_TYPES tracks the number of different configuration types that can be applied to a resource. CDP_NUM_TYPES is required to iterate over the different configurations but is not a member of enum resctrl_conf_type to avoid the warning generated with -Wswitch when CDP_NUM_TYPES lacks a case. Add a new CDP_LAST enum entry used in CDP_NUM_TYPES definition to simplify adding a new enum entry. Do this to create a cleaner pattern for tracking the number of enum entries in resctrl in preparation for other enums needing to do so. Suggested-by: Ben Horgan Signed-off-by: Reinette Chatre Reviewed-by: Ben Horgan --- include/linux/resctrl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 006e57fd7ca5..0b28049378c8 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -69,9 +69,10 @@ enum resctrl_conf_type { CDP_NONE, CDP_CODE, CDP_DATA, + CDP_LAST =3D CDP_DATA }; =20 -#define CDP_NUM_TYPES (CDP_DATA + 1) +#define CDP_NUM_TYPES (CDP_LAST + 1) =20 /* * struct pseudo_lock_region - pseudo-lock region information --=20 2.50.1 From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 B1329358372 for ; Fri, 20 Mar 2026 22:03:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044243; cv=none; b=Nm7MfqSLdO1ZzRFs/L7Ls/zA2SQpgSPHMmxGpPLkOc4DYROUjBs78Eq7DNsqW7RtPIPooYKGKLY8j6COVF531kTPKFUMSgY+7TEGMmJItvMeXfzPpA4i3J4jh6Q7AHHEWFh9ZUXfW6iZeSM/Iwo490uB7XFvPFEHubkIr7zqWwY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044243; c=relaxed/simple; bh=6S4Kbf26Ho80olkPFiZ8UngQhelhtisWM0bMfgO68B4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cdnx3cGbs7WziPByBJZNQNL8LPNUYkCbK0se27Kv8uqFqNRXFQLKIrvtFKgKe+z4TjFsECCzskF2AC3UgXzl4pmSZwkLhIszL3YRpiExOmrAssQ8477xMdoVUoRcweKPLFnikpL2WyniyGTQHNxdPtgnhjIBxeSdZDp5Kc5WITg= 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=TB8FYYbL; arc=none smtp.client-ip=198.175.65.9 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="TB8FYYbL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044239; x=1805580239; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6S4Kbf26Ho80olkPFiZ8UngQhelhtisWM0bMfgO68B4=; b=TB8FYYbL8tcCM/bAOl5M6YLx4wfplvgSUCSmkKXR4/XgBSxhzEvKM6pM af6sdueB0vz1ZVGuyka6o6c+MPXRveFuncrSOo3U83GKdxXZ5oYIVPVGq TSHA6VuEi+vDvkCtEwq8mqjP/MgcP1PGu6LOb8yKgTyZZBajO+9FOUf+C Oxk7tLe/DVKrupq2I3+QUtWkvFcPMmAeZp9hIXaMpVhgZ134TmTXPigTk z/crfEa3YGHRVZXWV8lo5n2BekrgClzbc92Mzk3nBHjmJ0FyxxbBYG8IB Au2OIXimgrdjTotkxYjpiKNgQSugZ/mBqLn4bpG0VQoNl+mfrPAePBDRs g==; X-CSE-ConnectionGUID: 7Sn2dDuqQSO/itR8uW3Gyg== X-CSE-MsgGUID: RMSA5UfIQvG/4XmGz+v92A== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758395" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758395" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:55 -0700 X-CSE-ConnectionGUID: o6e4Ft09Sp6BLbxL0J9nUQ== X-CSE-MsgGUID: gV+OJ3KRS6KM/I9o0gt0bQ== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:55 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 07/14] fs/resctrl: Use accurate type for rdt_resource::rid Date: Fri, 20 Mar 2026 15:03:17 -0700 Message-ID: <1ae8867b43acb509f6359139297ee3a340bd0441.1774043709.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Every resctrl resource has a unique ID described by enum resctrl_res_level. enum resctrl_res_level is used in all resource ID initializations and all resource ID comparisons. All functions consuming the resource ID expects an enum resctrl_res_level. Of the four structures that contain a resource ID (struct mon_data, struct mon_evt, struct rdt_domain_hdr, and struct rdt_resource) only struct rdt_resource does not use enum resctrl_res_level. Switch the type of rdt_resource::rid to be enum resctrl_res_level to make it obvious what values are valid, match the type everywhere this member is used, and obtain benefits from tools that can flag any enum misuse. Move define of RDT_NUM_RESOURCES outside the enum to enable tools to catch when a switch() on the resource ID does not handle all the resources and thus help flag which switch statements need an update when a new resource is added. Signed-off-by: Reinette Chatre Reviewed-by: Ben Horgan --- Changes since v1: - Use RDT_RESOURCE_LAST =3D RDT_RESOURCE_PERF_PKG as last entry in enum.(Be= n) --- include/linux/resctrl.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 0b28049378c8..99a4774735c7 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -54,11 +54,11 @@ enum resctrl_res_level { RDT_RESOURCE_MBA, RDT_RESOURCE_SMBA, RDT_RESOURCE_PERF_PKG, - - /* Must be the last */ - RDT_NUM_RESOURCES, + RDT_RESOURCE_LAST =3D RDT_RESOURCE_PERF_PKG }; =20 +#define RDT_NUM_RESOURCES (RDT_RESOURCE_LAST + 1) + /** * enum resctrl_conf_type - The type of configuration. * @CDP_NONE: No prioritisation, both code and data are controlled or moni= tored. @@ -320,7 +320,7 @@ struct resctrl_mon { * @cdp_capable: Is the CDP feature available on this resource */ struct rdt_resource { - int rid; + enum resctrl_res_level rid; bool alloc_capable; bool mon_capable; enum resctrl_scope ctrl_scope; --=20 2.50.1 From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 13E6B3246E8 for ; Fri, 20 Mar 2026 22:04:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044243; cv=none; b=o7rSAaXmn5FC/1v55Bjr7svtpAS8c3A5JnGvzk2A+VyGErzxrLpDoaT4C0Vk/UER6VEAc9nPK2yNg+lk0SUn+KDf+e3HUYhKRazb94A2mBenvTpXN8+qU7a0JzAKjpq7xEBfGZvMMHNaKaXJYfF/SqAnpqPdBbpbw2YA1Ejr+MI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044243; c=relaxed/simple; bh=A21P6fI2hgZ/+eGK6RsbbZ/oeCdwqcvHzTT8GH5JBd0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gfdrlbjOfoZFqGFbfC+LneGqI4oPKWFAtRqqwIDCnXlz9XnUeehQWvvAkHsH+oEJHE/xwkb0Ue5fijrlRaRjXeg0vaz8CW9N4qcY/nzDwb9JqpsATTPvwbmvKky6pjLokH0cb9LrMUhmWRiHmOQ6XgI8392oSc3OSye0SfWkbyk= 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=XEI1Py5G; arc=none smtp.client-ip=198.175.65.9 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="XEI1Py5G" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044240; x=1805580240; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=A21P6fI2hgZ/+eGK6RsbbZ/oeCdwqcvHzTT8GH5JBd0=; b=XEI1Py5G5yZ0dhpUEiSXJD70MGwIBFvbnlF5/XJEhfCX3mpJoTJDqyrS o+RjbX7rFWfhWeO9JEK65iiq0+/ni/7QfQ8JCtVZBsA8wBgXkmBhrU1cw XelTVIyoS3nn+ZmA9QWh12bCtEkMT6QSwKdu53C5jhCSgqqBOkIENaIHE UmRGK/QNbr4SnXQSRk4ABcQQEZdvZwa3wROoES1kztl+2kOSduIc+CDgy EssKXnkX6hJqHpFX/WGJPIO2HbfujjMmqp2sBSGe7XKD9pppZWz7G0p+X 4DuHBU/ST7n/0/6uFiIzJjpbi1jaaUztCHL4eDk+PaF5Xwn3bXlQWq/7s Q==; X-CSE-ConnectionGUID: 4rad7jH8RHWooIMj3kLgng== X-CSE-MsgGUID: itlD1X9XTgiwh6neLW6i7g== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758408" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758408" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:55 -0700 X-CSE-ConnectionGUID: e4cAP81TTAiJddZq0V4Bjg== X-CSE-MsgGUID: TzSsMQ1jRQulBuQ+wuk3tg== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:55 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 08/14] fs/resctrl: Pass error reading event through to user space Date: Fri, 20 Mar 2026 15:03:18 -0700 Message-ID: <38f8735190251f75e2e8b33861cc86135aefb748.1774043709.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Reading of event data is managed through populating a struct rmid_read with properties of event needing to be read. This data is dispatched to an appropriate CPU and upon completion any error can be found in rmid_read::er= r, or on success the event data will be in rmid_read::val. rmid_read::err is not updated in the unlikely scenario that the reading of the event was dispatched to a wrong CPU. If this ever occurs due to a bug in resctrl the user space read will return "success" but the data reported will be invalid. Ensure accurate error reporting so that if there may be an issue with how resctrl picks a CPU it could be learned with an error to user space instead of silent failure. Signed-off-by: Reinette Chatre Reviewed-by: Ben Horgan --- Changes since v1: - Add Ben's RB tag. --- fs/resctrl/monitor.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 8194fdfbea81..101b2911d582 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -453,8 +453,10 @@ static int __l3_mon_event_count(struct rdtgroup *rdtgr= p, struct rmid_read *rr) } =20 /* Reading a single domain, must be on a CPU in that domain. */ - if (!cpumask_test_cpu(cpu, &d->hdr.cpu_mask)) + if (!cpumask_test_cpu(cpu, &d->hdr.cpu_mask)) { + rr->err =3D -EIO; return -EINVAL; + } if (rr->is_mbm_cntr) rr->err =3D resctrl_arch_cntr_read(rr->r, d, closid, rmid, cntr_id, rr->evt->evtid, &tval); @@ -491,8 +493,10 @@ static int __l3_mon_event_count_sum(struct rdtgroup *r= dtgrp, struct rmid_read *r } =20 /* Summing domains that share a cache, must be on a CPU for that cache. */ - if (!cpumask_test_cpu(cpu, &rr->ci->shared_cpu_map)) + if (!cpumask_test_cpu(cpu, &rr->ci->shared_cpu_map)) { + rr->err =3D -EIO; return -EINVAL; + } =20 /* * Legacy files must report the sum of an event across all --=20 2.50.1 From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 AA02F379993 for ; Fri, 20 Mar 2026 22:04:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044244; cv=none; b=DXfEIr8TKfkxzXDKlAluy8uWCbdc10S90ol8/N8pBLyXfnsEv5SMlAQffbwUYFVUaAvW5tTNnmwhLvM10mDyWX+ZjR6l0BhJWd6SZsFn6DycW8ZGilkGaUGgrgZthtO9sa4z6fFpi+8gQh9/hxSGlbyUX2L3cZeXbdhepy2I7Ik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044244; c=relaxed/simple; bh=G7LPBZHxkhwz1Ab4y/GDTNOvOY8/Q8W21Xbce4QcpJg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Oh4IcxVJjGWUyVBjY7gYWpwH28jFTYgsOWDda5ZuWLWDxD0cQHWaWZnB38KB5FbhuhCVQZz4F0bfiMK3DrG1O+qZ2t4Y4vdyhBLtB+ngB7I+HK1nc8TTf8cBAVnDQGtmGH4JxXUYXLz2mdDk9Adf5G4rQsZ5tXrjn1VgGc0hyQo= 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=K1sq+UFa; arc=none smtp.client-ip=198.175.65.9 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="K1sq+UFa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044242; x=1805580242; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G7LPBZHxkhwz1Ab4y/GDTNOvOY8/Q8W21Xbce4QcpJg=; b=K1sq+UFaKbG6KvyWjXloGrS0EdQC6Y/XIbwwWSjrKTakUtssLz+G4Zyp K4duuonnG7gwsaGsY08TMbrZ8JcBxYC1YrLc+s2VFj7i3rE8IWI78m+q0 8tHtfl9UhJp8R/9ecA/xEoaE/FdchhUt4+2XzDvNL+EjZw2hOxaWrf9On XbzQ2g1CMPkvowVbujJ0ydrUQHu4v/d9g/Asdrho4L4H92OIfI1RqMamF urHb+MgHTXbsPetAdksiOTKUowiwewT2/DLs8Wg71BCAy/Eus5rBO+ml5 vJ7LTwfr0OJ/cvx9EEx1ESqUHXGplJWePZAzSPf0hZ1Y9coyban4cEHbH A==; X-CSE-ConnectionGUID: KojIrGQcT4GGxRwaloY13Q== X-CSE-MsgGUID: x12RactaSKOzXEOMMWWhVg== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758418" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758418" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:56 -0700 X-CSE-ConnectionGUID: Qq9mNdA1Rq2BQjwHemtKfQ== X-CSE-MsgGUID: cwEdzKXpTOGCJBdgRbziOw== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:56 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 09/14] fs/resctrl: Add last_cmd_status support for writes to max_threshold_occupancy Date: Fri, 20 Mar 2026 15:03:19 -0700 Message-ID: <1477243b7c470baa920d94477b30d41405fce45c.1774043709.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" info/last_cmd_status is intended to contain more information if a write to any resctrl file fails. Writes to max_threshold_occupancy did not receive last_cmd_status support during initial last_cmd_status enabling. Add it now. Signed-off-by: Reinette Chatre Reviewed-by: Ben Horgan --- Changes since v1: - Add Ben's RB tag. --- fs/resctrl/rdtgroup.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 111bff8e33fd..6fa5c8f14e3a 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1238,16 +1238,27 @@ static ssize_t max_threshold_occ_write(struct kernf= s_open_file *of, unsigned int bytes; int ret; =20 + mutex_lock(&rdtgroup_mutex); + rdt_last_cmd_clear(); + ret =3D kstrtouint(buf, 0, &bytes); - if (ret) - return ret; + if (ret) { + rdt_last_cmd_puts("Invalid input\n"); + goto out_unlock; + } =20 - if (bytes > resctrl_rmid_realloc_limit) - return -EINVAL; + if (bytes > resctrl_rmid_realloc_limit) { + rdt_last_cmd_printf("Exceeds limit (before adjustment) of %u bytes\n", + resctrl_rmid_realloc_limit); + ret =3D -EINVAL; + goto out_unlock; + } =20 resctrl_rmid_realloc_threshold =3D resctrl_arch_round_mon_val(bytes); =20 - return nbytes; +out_unlock: + mutex_unlock(&rdtgroup_mutex); + return ret ?: nbytes; } =20 /* --=20 2.50.1 From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 1572A37F8C1 for ; Fri, 20 Mar 2026 22:04:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044245; cv=none; b=H6lCvLlKx+q+ECmL2ZKxTvHu/SanpviOuZ7VT6hXjUQQn4jsl7A+9tb/XGwPE3SYnIn7K0LFuOt8/qxaMp0DdQSbK4jkritw16smE2CJrWuG3pEZE7hvESUmxkTTXCe2eeg37o/e2BZVBdzU5O9ft3r8DuObXlk+gBhlD7yyP1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044245; c=relaxed/simple; bh=WuOr17rmOeSXijSalpBw2VvgVcngOVpjuie0BTD4cHE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R4B1P5S92m8P9BjzUGKPyZnr5A/Ouk6obXUXX48u8J7GwSxFIAI1rCWNp9v4V9u6N9iszpw2pQxBrtS4vdsOOE0PMX45Trq1YIbUTGoth29OFSubHvE47H1XXqfQmvFF9XEFfqpy4DZeG6WclDw7bBy2Hi6GufN5Fi/yubTB/ws= 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=hZxhQ3Dc; arc=none smtp.client-ip=198.175.65.9 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="hZxhQ3Dc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044243; x=1805580243; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WuOr17rmOeSXijSalpBw2VvgVcngOVpjuie0BTD4cHE=; b=hZxhQ3DcWoigMgyNlvEG3VjD4eTnnDLPWwCm5tApQjGNJakNMgdkNqWI 9rSv930FTvG3Tzh5bfjdLNDXgU40TDy5IoJjPHFQxxywZd304TEXBWXlz fI73pyYUzoVCBcwiuItwq9k33qDFe0irI1+47YfUI9E0EhYLkEFu+4YGg q9mIUXdEAsj8+5KRFJEjaa7REmbnJ8OXCXlndyqsXFcumVCZdlEFjv5QI DpwkgjRlHEUZKioXHestSZdhOGCKTbhp5JXfvK7OwSd0206iIb5TjDLEn WioOGN0CBahxvVR1rRWHZT3txETHjAbJzMoCEJ41zj7VAmjfCdTdMCzT+ g==; X-CSE-ConnectionGUID: Lgo2ZT2BROe9T0/bG1yAqw== X-CSE-MsgGUID: Lh7P/w0GRo6pX4z465jTSg== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758428" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758428" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:56 -0700 X-CSE-ConnectionGUID: zSK5T1MTT2Gc7XBDpdDXkA== X-CSE-MsgGUID: ribkLN90S4Cj7R8E95sgwA== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:56 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 10/14] fs/resctrl: Use accurate and symmetric exit flows Date: Fri, 20 Mar 2026 15:03:20 -0700 Message-ID: <445ac564270970f5736f39f892c9997728fc9bc0.1774043709.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" During schemata file write handling there is one error exit path labeled "out" that handles all cleanup and unlocking needed on exit. The staged configs cleared during an error exit may not have been used at the time of exit making the clearing of the staged configs unnecessary. Access the exit code using two labels and only clear the staged configuration if it was in use at the time of exit. Doing so makes the code flow obvious and simplifies upcoming changes that improve the handling of failures during early input parsing. Signed-off-by: Reinette Chatre --- fs/resctrl/ctrlmondata.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index cc4237c57cbe..a8e7cdcfec6e 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -331,7 +331,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file= *of, if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKED) { ret =3D -EINVAL; rdt_last_cmd_puts("Resource group is pseudo-locked\n"); - goto out; + goto out_unlock; } =20 rdt_staged_configs_clear(); @@ -341,16 +341,16 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_fi= le *of, if (!tok) { rdt_last_cmd_puts("Missing ':'\n"); ret =3D -EINVAL; - goto out; + goto out_clear_staged; } if (tok[0] =3D=3D '\0') { rdt_last_cmd_printf("Missing '%s' value\n", resname); ret =3D -EINVAL; - goto out; + goto out_clear_staged; } ret =3D rdtgroup_parse_resource(resname, tok, rdtgrp); if (ret) - goto out; + goto out_clear_staged; } =20 list_for_each_entry(s, &resctrl_schema_all, list) { @@ -365,7 +365,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file= *of, =20 ret =3D resctrl_arch_update_domains(r, rdtgrp->closid); if (ret) - goto out; + goto out_clear_staged; } =20 if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP) { @@ -378,8 +378,9 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file= *of, ret =3D rdtgroup_pseudo_lock_create(rdtgrp); } =20 -out: +out_clear_staged: rdt_staged_configs_clear(); +out_unlock: rdtgroup_kn_unlock(of->kn); return ret ?: nbytes; } --=20 2.50.1 From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 7BC553815DB for ; Fri, 20 Mar 2026 22:04:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044245; cv=none; b=V+wTURgSsuUxbhI7/doNMgxanI9wRTmtkQdAj0DVDzRBBjyYbKs6iku9Pzu2WjMXT6tZ7fgNuE/famImwQURvjqHJ2HymY7ty2TKHJqZMZuEXJLeSAvucVYbJGrUmR1ZPAthQAYSpYRPW2SjFgqMlV5+p4a92ypRr8dWubaiBYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044245; c=relaxed/simple; bh=zOWxlg7FblfuC6kp+IHmTGlYUnlqsa+9riVd1/eAi4w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hEQydxKggEd4TomWdCMRa4MThS6n8nWrUVv9KDT0uSSI54HVKK+mOYAmtCpy5Wfw02nwzSNrvTttE57OP9nklNGgZsgyF3KmfirvUtU4WI4Gjv9aK2K8I0AbInCMYY7RgTO2cuMEV5mnJ/lHw4zzgqiQPp0K5O5Xv90/f2R/eyY= 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=HK121tmI; arc=none smtp.client-ip=198.175.65.9 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="HK121tmI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044243; x=1805580243; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zOWxlg7FblfuC6kp+IHmTGlYUnlqsa+9riVd1/eAi4w=; b=HK121tmIhUeTExwU2YVbEyKLgsBSseHgRHudvGX4nBJNmZ4Tpt4xkAXK qWuoRPdvrajRBg03sA7QgZi5jBWMF6Q+txuHhoSHyT0B24PdJbPNxfKHm UoOwUirGAUYDcWQAmap+ppgpDmnyGPFrKPqrsZBhyJLdJ1a5/eZ7f6EWn la+00DRPNmlqKN6717Ov9K165kNejWMo72RmUeJ19ZnBvAEOGdDHTC0Ed crSxb6zBc+v3dQ3C278Ho38q2kzK67LtS0TFKrm5q7NohHd5lZ/yLDyHs JgvrfRCpzI7hrrlRRKWiW1YKY/NCmcJFyukw/FOVxqIwRcUGD/XV1XR1D w==; X-CSE-ConnectionGUID: 4jpANNguTOu8mYeenSaJhw== X-CSE-MsgGUID: lBfsiwGZQSqYvxJq0pM3vg== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758438" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758438" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:57 -0700 X-CSE-ConnectionGUID: Mhd5f3P5TbyKpgkA7EVB+Q== X-CSE-MsgGUID: UEjAPUgZSJiy0I5UejOINw== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:56 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 11/14] fs/resctrl: Use stricter checks on input to cpus/cpus_list file Date: Fri, 20 Mar 2026 15:03:21 -0700 Message-ID: <744ddfbc6365832a5707b4d1631158f42e121401.1774043709.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Callbacks handling writes to resctrl files are called via kernfs_fop_write_iter() that ensures that the resctrl callback is never called with a NULL buffer. Even if user space issues a write() with a NULL buffer and zero count the resctrl callback receives a valid buffer terminated with '\0' and the number of bytes parameter set to zero. The NULL buffer check at the beginning of rdtgroup_cpus_write(), while making no assumptions about caller behavior, is not useful. An empty buffer is transformed into an empty cpumask that is passed through entire flow that results in no changes. Ensure that the user provided buffer contains some data before attempting to parse it using the same check as other resctrl files (the familiar "nbytes =3D=3D 0"). The custom is for resctrl file callbacks to fail on an empty buffer and this brings interactions with the cpus/cpus_list file in line with this custom. The risk is that if there exists a user space that uses empty writes to this specific file then those successful interactions will start failing. Exit right away if there was no failure yet no cpumask could be created from the input. It is of no use to pass an empty cpumask through the entire flow, just return with success to short-circuit the existing behavior. Signed-off-by: Reinette Chatre --- fs/resctrl/rdtgroup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 6fa5c8f14e3a..5f3d89c7757c 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -515,7 +515,7 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_f= ile *of, struct rdtgroup *rdtgrp; int ret; =20 - if (!buf) + if (!buf || nbytes =3D=3D 0) return -EINVAL; =20 if (!zalloc_cpumask_var(&tmpmask, GFP_KERNEL)) @@ -555,6 +555,9 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_f= ile *of, goto unlock; } =20 + if (cpumask_empty(newmask)) + goto unlock; + /* check that user didn't specify any offline cpus */ cpumask_andnot(tmpmask, newmask, cpu_online_mask); if (!cpumask_empty(tmpmask)) { --=20 2.50.1 From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 5EB492E7635 for ; Fri, 20 Mar 2026 22:04:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044247; cv=none; b=fsEqeA6ciIGruAMcV7PJLOuoe/8q50B30t9Z5sK1N9SjKbxFa/lUa9wmawibKGtOu+IXlAovoqfROThIZOunzgjH1ZjCuBsIx8J2SnoddFOyqwgfOTstY9InHd9mvYhBOVLmtduI+VptWIy9CzZPT3xmEdfNRmuPqOPgabCFmDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044247; c=relaxed/simple; bh=StiA7mwrfaLXrcesKX7/dRTmWMHXNNui8AbSFf0pufE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IGhkpUghUFyTD0AYW4808dW9V1rubaQ3VzaMFsmU3aYR06u7pIczdEHEY7AiTTSuKjqYdarzNg1lsX/UxaOczHlWhG/5sNKHzUBpap1Zg+F+JIixE1BR3AscSi7nn7ScUnVB5mRRf+9NA51YFek/m1bjIBxN8Jdqk7leYRhlnbk= 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=ao9M0dhM; arc=none smtp.client-ip=198.175.65.9 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="ao9M0dhM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044244; x=1805580244; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=StiA7mwrfaLXrcesKX7/dRTmWMHXNNui8AbSFf0pufE=; b=ao9M0dhMkY5VTKXIT2GgmMJmY46b0THvx0EngXMgoGoJtvM/XLS1svrB 16OIiIgAHWhkWGt6wxYL3i8ZGQ3FOYQcKdHtvcucpnugUSl5Jd7oEmKqX 8bSbOUKTqfyXas7QO4mjm9nJV25TaqJJehJ9AMmcWxBtforJ4IrBGU8gG z5SaBH1nkP6XfhHwxST1Js17ohVEmzWIPtj/sQka9J7G2f2vt7eqtLfwO gU5IjbyUN6yZ3EQJecATVMcMj8cgMhj+eZfERe1xArSaeTe4iidu/LLk3 JjMRUkCdASEYC6Gn+2PyA4OisP9l8D8Azz/6S4xlkAv8GaRjTgzYlSbAv Q==; X-CSE-ConnectionGUID: 1Z9erRUeQXKikGmno9LXvg== X-CSE-MsgGUID: vGa9ezONSqGgkTFmHV2iaA== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758448" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758448" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:57 -0700 X-CSE-ConnectionGUID: rEkK+RNnSeKhEEIjvDTTcg== X-CSE-MsgGUID: dOaruskHQ3WPpbm45MD4UA== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:57 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 12/14] fs/resctrl: Change last_cmd_status custom during input parsing Date: Fri, 20 Mar 2026 15:03:22 -0700 Message-ID: <19d78fb56a210651e6e43a482aa4f5117281ed86.1774043709.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A pattern of usage of last_cmd_status was introduced during its enabling in commit c377dcfbee80 ("x86/intel_rdt: Add diagnostics when writing the schemata fil= e") and since copied throughout resctrl to result in the following custom: ..._write() { /* Early parsing of input, exit on failure. */ /* Obtain rdtgroup_mutex */ rdt_last_cmd_clear(); /* Clear last_cmd_status buffer */ /* * Act on user command, failures result in detail * error message in last_cmd_status buffer via * rdt_last_cmd_puts()/rdt_last_cmd_printf(). */ /* Release rdtgroup_mutex */ } If resctrl exits with failure during early parsing of input there are two possible scenarios: - The last_cmd_status buffer is empty and a user's read of info/last_cmd_status returns "ok". - The last_cmd_status buffer contains details from an earlier ...write() failure and a user's read of info/last_cmd_status returns this outdated error description. Writing to a resctrl file is considered a "resctrl command" and the resctrl documentation states the following about the last_cmd_status file: "If the command failed, it will provide more information that can be conveyed in the error returns from file operations." Neither of the current scenarios is correct behavior. Move early input parsing to be done with rdtgroup_mutex held after the last_cmd_status buffer is cleared. Let info/last_cmd_status be accurate when an error is encountered during parsing of user command. Signed-off-by: Reinette Chatre Reviewed-by: Ben Horgan --- Changes since v1: - Add Ben's RB tag. --- fs/resctrl/ctrlmondata.c | 54 ++++++++++++++++---------- fs/resctrl/monitor.c | 60 ++++++++++++++++------------ fs/resctrl/rdtgroup.c | 84 +++++++++++++++++++++++----------------- 3 files changed, 118 insertions(+), 80 deletions(-) diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index a8e7cdcfec6e..7b90c36ff0a6 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -312,11 +312,6 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_fil= e *of, char *tok, *resname; int ret =3D 0; =20 - /* Valid input requires a trailing newline */ - if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') - return -EINVAL; - buf[nbytes - 1] =3D '\0'; - rdtgrp =3D rdtgroup_kn_lock_live(of->kn); if (!rdtgrp) { rdtgroup_kn_unlock(of->kn); @@ -324,6 +319,15 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_fil= e *of, } rdt_last_cmd_clear(); =20 + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') { + rdt_last_cmd_puts("Invalid input\n"); + ret =3D -EINVAL; + goto out_unlock; + } + + buf[nbytes - 1] =3D '\0'; + /* * No changes to pseudo-locked region allowed. It has to be removed * and re-created instead. @@ -466,11 +470,6 @@ ssize_t rdtgroup_mba_mbps_event_write(struct kernfs_op= en_file *of, struct rdtgroup *rdtgrp; int ret =3D 0; =20 - /* Valid input requires a trailing newline */ - if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') - return -EINVAL; - buf[nbytes - 1] =3D '\0'; - rdtgrp =3D rdtgroup_kn_lock_live(of->kn); if (!rdtgrp) { rdtgroup_kn_unlock(of->kn); @@ -478,6 +477,15 @@ ssize_t rdtgroup_mba_mbps_event_write(struct kernfs_op= en_file *of, } rdt_last_cmd_clear(); =20 + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') { + rdt_last_cmd_puts("Invalid input\n"); + ret =3D -EINVAL; + goto out_unlock; + } + + buf[nbytes - 1] =3D '\0'; + if (!strcmp(buf, "mbm_local_bytes")) { if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID)) rdtgrp->mba_mbps_event =3D QOS_L3_MBM_LOCAL_EVENT_ID; @@ -495,6 +503,7 @@ ssize_t rdtgroup_mba_mbps_event_write(struct kernfs_ope= n_file *of, if (ret) rdt_last_cmd_printf("Unsupported event id '%s'\n", buf); =20 +out_unlock: rdtgroup_kn_unlock(of->kn); =20 return ret ?: nbytes; @@ -854,15 +863,17 @@ ssize_t resctrl_io_alloc_write(struct kernfs_open_fil= e *of, char *buf, bool enable; int ret; =20 - ret =3D kstrtobool(buf, &enable); - if (ret) - return ret; - cpus_read_lock(); mutex_lock(&rdtgroup_mutex); =20 rdt_last_cmd_clear(); =20 + ret =3D kstrtobool(buf, &enable); + if (ret) { + rdt_last_cmd_puts("Invalid input\n"); + goto out_unlock; + } + if (!r->cache.io_alloc_capable) { rdt_last_cmd_printf("io_alloc is not supported on %s\n", s->name); ret =3D -ENODEV; @@ -1004,16 +1015,19 @@ ssize_t resctrl_io_alloc_cbm_write(struct kernfs_op= en_file *of, char *buf, u32 io_alloc_closid; int ret =3D 0; =20 - /* Valid input requires a trailing newline */ - if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') - return -EINVAL; - - buf[nbytes - 1] =3D '\0'; - cpus_read_lock(); mutex_lock(&rdtgroup_mutex); rdt_last_cmd_clear(); =20 + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') { + rdt_last_cmd_puts("Invalid input\n"); + ret =3D -EINVAL; + goto out_unlock; + } + + buf[nbytes - 1] =3D '\0'; + if (!r->cache.io_alloc_capable) { rdt_last_cmd_printf("io_alloc is not supported on %s\n", s->name); ret =3D -ENODEV; diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 101b2911d582..1a38f3b6a1f1 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1112,13 +1112,15 @@ ssize_t resctrl_mbm_assign_on_mkdir_write(struct ke= rnfs_open_file *of, char *buf bool value; int ret; =20 - ret =3D kstrtobool(buf, &value); - if (ret) - return ret; - mutex_lock(&rdtgroup_mutex); rdt_last_cmd_clear(); =20 + ret =3D kstrtobool(buf, &value); + if (ret) { + rdt_last_cmd_puts("Invalid input\n"); + goto out_unlock; + } + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { rdt_last_cmd_puts("mbm_event counter assignment mode is not enabled\n"); ret =3D -EINVAL; @@ -1409,17 +1411,20 @@ ssize_t event_filter_write(struct kernfs_open_file = *of, char *buf, size_t nbytes u32 evt_cfg =3D 0; int ret =3D 0; =20 - /* Valid input requires a trailing newline */ - if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') - return -EINVAL; - - buf[nbytes - 1] =3D '\0'; - cpus_read_lock(); mutex_lock(&rdtgroup_mutex); =20 rdt_last_cmd_clear(); =20 + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') { + rdt_last_cmd_puts("Invalid input\n"); + ret =3D -EINVAL; + goto out_unlock; + } + + buf[nbytes - 1] =3D '\0'; + r =3D resctrl_arch_get_resource(mevt->rid); if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { rdt_last_cmd_puts("mbm_event counter assignment mode is not enabled\n"); @@ -1478,17 +1483,20 @@ ssize_t resctrl_mbm_assign_mode_write(struct kernfs= _open_file *of, char *buf, int ret =3D 0; bool enable; =20 - /* Valid input requires a trailing newline */ - if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') - return -EINVAL; - - buf[nbytes - 1] =3D '\0'; - cpus_read_lock(); mutex_lock(&rdtgroup_mutex); =20 rdt_last_cmd_clear(); =20 + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') { + rdt_last_cmd_puts("Invalid input\n"); + ret =3D -EINVAL; + goto out_unlock; + } + + buf[nbytes - 1] =3D '\0'; + if (!strcmp(buf, "default")) { enable =3D 0; } else if (!strcmp(buf, "mbm_event")) { @@ -1759,12 +1767,6 @@ ssize_t mbm_L3_assignments_write(struct kernfs_open_= file *of, char *buf, char *token, *event; int ret =3D 0; =20 - /* Valid input requires a trailing newline */ - if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') - return -EINVAL; - - buf[nbytes - 1] =3D '\0'; - rdtgrp =3D rdtgroup_kn_lock_live(of->kn); if (!rdtgrp) { rdtgroup_kn_unlock(of->kn); @@ -1772,10 +1774,19 @@ ssize_t mbm_L3_assignments_write(struct kernfs_open= _file *of, char *buf, } rdt_last_cmd_clear(); =20 + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') { + rdt_last_cmd_puts("Invalid input\n"); + ret =3D -EINVAL; + goto out_unlock; + } + + buf[nbytes - 1] =3D '\0'; + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { rdt_last_cmd_puts("mbm_event mode is not enabled\n"); - rdtgroup_kn_unlock(of->kn); - return -EINVAL; + ret =3D -EINVAL; + goto out_unlock; } =20 while ((token =3D strsep(&buf, "\n")) !=3D NULL) { @@ -1791,6 +1802,7 @@ ssize_t mbm_L3_assignments_write(struct kernfs_open_f= ile *of, char *buf, break; } =20 +out_unlock: rdtgroup_kn_unlock(of->kn); =20 return ret ?: nbytes; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 5f3d89c7757c..5100a8bb16f3 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -511,38 +511,38 @@ static int cpus_ctrl_write(struct rdtgroup *rdtgrp, c= pumask_var_t newmask, static ssize_t rdtgroup_cpus_write(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off) { - cpumask_var_t tmpmask, newmask, tmpmask1; + cpumask_var_t tmpmask =3D CPUMASK_VAR_NULL, newmask =3D CPUMASK_VAR_NULL; + cpumask_var_t tmpmask1 =3D CPUMASK_VAR_NULL; struct rdtgroup *rdtgrp; int ret; =20 - if (!buf || nbytes =3D=3D 0) - return -EINVAL; - - if (!zalloc_cpumask_var(&tmpmask, GFP_KERNEL)) - return -ENOMEM; - if (!zalloc_cpumask_var(&newmask, GFP_KERNEL)) { - free_cpumask_var(tmpmask); - return -ENOMEM; - } - if (!zalloc_cpumask_var(&tmpmask1, GFP_KERNEL)) { - free_cpumask_var(tmpmask); - free_cpumask_var(newmask); - return -ENOMEM; - } - rdtgrp =3D rdtgroup_kn_lock_live(of->kn); if (!rdtgrp) { ret =3D -ENOENT; - goto unlock; + goto out_unlock; } =20 rdt_last_cmd_clear(); =20 + if (!buf || nbytes =3D=3D 0) { + rdt_last_cmd_puts("Invalid input\n"); + ret =3D -EINVAL; + goto out_unlock; + } + + if (!zalloc_cpumask_var(&tmpmask, GFP_KERNEL) || + !zalloc_cpumask_var(&newmask, GFP_KERNEL) || + !zalloc_cpumask_var(&tmpmask1, GFP_KERNEL)) { + rdt_last_cmd_puts("Kernel allocation failure\n"); + ret =3D -ENOMEM; + goto out_free; + } + if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKED || rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP) { ret =3D -EINVAL; rdt_last_cmd_puts("Pseudo-locking in progress\n"); - goto unlock; + goto out_free; } =20 if (is_cpu_list(of)) @@ -552,18 +552,18 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open= _file *of, =20 if (ret) { rdt_last_cmd_puts("Bad CPU list/mask\n"); - goto unlock; + goto out_free; } =20 if (cpumask_empty(newmask)) - goto unlock; + goto out_free; =20 /* check that user didn't specify any offline cpus */ cpumask_andnot(tmpmask, newmask, cpu_online_mask); if (!cpumask_empty(tmpmask)) { ret =3D -EINVAL; rdt_last_cmd_puts("Can only assign online CPUs\n"); - goto unlock; + goto out_free; } =20 if (rdtgrp->type =3D=3D RDTCTRL_GROUP) @@ -573,11 +573,12 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open= _file *of, else ret =3D -EINVAL; =20 -unlock: - rdtgroup_kn_unlock(of->kn); +out_free: free_cpumask_var(tmpmask); free_cpumask_var(newmask); free_cpumask_var(tmpmask1); +out_unlock: + rdtgroup_kn_unlock(of->kn); =20 return ret ?: nbytes; } @@ -1457,11 +1458,6 @@ static ssize_t rdtgroup_mode_write(struct kernfs_ope= n_file *of, enum rdtgrp_mode mode; int ret =3D 0; =20 - /* Valid input requires a trailing newline */ - if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') - return -EINVAL; - buf[nbytes - 1] =3D '\0'; - rdtgrp =3D rdtgroup_kn_lock_live(of->kn); if (!rdtgrp) { rdtgroup_kn_unlock(of->kn); @@ -1469,6 +1465,14 @@ static ssize_t rdtgroup_mode_write(struct kernfs_ope= n_file *of, } =20 rdt_last_cmd_clear(); + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') { + rdt_last_cmd_puts("Invalid input\n"); + ret =3D -EINVAL; + goto out; + } + + buf[nbytes - 1] =3D '\0'; =20 mode =3D rdtgrp->mode; =20 @@ -1794,19 +1798,23 @@ static ssize_t mbm_total_bytes_config_write(struct = kernfs_open_file *of, struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); int ret; =20 - /* Valid input requires a trailing newline */ - if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') - return -EINVAL; - cpus_read_lock(); mutex_lock(&rdtgroup_mutex); =20 rdt_last_cmd_clear(); =20 + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') { + rdt_last_cmd_puts("Invalid input\n"); + ret =3D -EINVAL; + goto out_unlock; + } + buf[nbytes - 1] =3D '\0'; =20 ret =3D mon_config_write(r, buf, QOS_L3_MBM_TOTAL_EVENT_ID); =20 +out_unlock: mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); =20 @@ -1820,19 +1828,23 @@ static ssize_t mbm_local_bytes_config_write(struct = kernfs_open_file *of, struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); int ret; =20 - /* Valid input requires a trailing newline */ - if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') - return -EINVAL; - cpus_read_lock(); mutex_lock(&rdtgroup_mutex); =20 rdt_last_cmd_clear(); =20 + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') { + rdt_last_cmd_puts("Invalid input\n"); + ret =3D -EINVAL; + goto out_unlock; + } + buf[nbytes - 1] =3D '\0'; =20 ret =3D mon_config_write(r, buf, QOS_L3_MBM_LOCAL_EVENT_ID); =20 +out_unlock: mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); =20 --=20 2.50.1 From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 16B4B31E83E for ; Fri, 20 Mar 2026 22:04:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044246; cv=none; b=pPkRZb05VaVb4AkThdwaxuGMK5abL96wyX1j1ObbsdKMBi/uAtT7OVOU0uCHOLCPEg+Vp93td1AKuRjHOGDjV1Z/6nNcQs5VVcUceQK0Abs86Smx8nZbV0ZmEydS82OcTYaaZpL5uJzum5sVvKsPJHDPWRSJ1LLEGG5GHXnzz8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044246; c=relaxed/simple; bh=nFf5lyjZOmv1Kwhc8O1v5V+0vN0yj3DlyLSNBpRiX4o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YrPR7+fdFPUtEp3rCkmVWxgqypOIoyZc3jqTXtoCNQcBJrU7zJ1/9NtU5Us6o+kGUjBA9x6sYfDm81HbBlOwDM853TRdlM2jDOCyIgPqEiC6OTnKWMgb78FQxapFXICrJLA4LMFUa5EJRv2sOizKXVdvwIYCDB2eRbDRzn1W4/I= 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=Pm1VqTmx; arc=none smtp.client-ip=198.175.65.9 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="Pm1VqTmx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044245; x=1805580245; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nFf5lyjZOmv1Kwhc8O1v5V+0vN0yj3DlyLSNBpRiX4o=; b=Pm1VqTmxIpyT4Wx+w5aUJ8T59Cpt+IpKL0nLaZacRHEQZjo8Otrgd0on 6pP8yw0+yM7c+GxTDQDQ1LJd3bj6+MKDThGjG8jBGQqvIt9flhKQESwrR zcnGA1RjGI1z+tnD1v9R4SH0Ssd5wit88RTHF/kZB+vHetryp8PPXVVaN ldebqQMwFimJtXAePzoTWRM6x+lfNXPRYTh0IfeX1jWKjdWVVEg6wPbS+ /bur8P4Z9PJhF4cvBTBbI4e1L66dEe61A7fbd7497fcRlJ4Cn5HklTezm ZMc1JmU1T0ilw+XNHZPr4PBAn4Q7Zm5KePF2BOhjZyK40wxnCcCg7sLAH g==; X-CSE-ConnectionGUID: 80o4vS02SLqHjKC++czTAg== X-CSE-MsgGUID: myfeRdO5Tx2s1gB9lzVOFw== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758458" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758458" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:57 -0700 X-CSE-ConnectionGUID: tPfDtAp0Qm6bYGPu1sBI/w== X-CSE-MsgGUID: Pz2u+9iYSduaYSRWlV1y0w== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:57 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 13/14] fs/resctrl: Communicate resource group deleted error via last_cmd_status Date: Fri, 20 Mar 2026 15:03:23 -0700 Message-ID: <1c78707dd99102518b3205d03f0bfce611d96e6d.1774043709.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" User space expects last_cmd_status to contain additional information if any resctrl command fails. A resctrl command may be blocked waiting on the rdtgroup_mutex waiting for another command to finish and find that once the mutex is available that the resource group has since been deleted. In this scenario the command will fail while last_cmd_status contains either "ok" if the last_cmd_status buffer is empty or an outdated error from a previous command failure if last_cmd_status buffer has content. Include clearing of last_cmd_status buffer as part of rdtgroup_kn_lock_live() that is used to obtain access and needed locking to a resource group before attempting a command on the group. With the last_cmd_status buffer ready, provide an appropriate message to user space if the resource group has been deleted. No last_cmd_status treatment is needed for the remaining failure of rdtgroup_kn_lock_live() encountering a non-existent resource group since that could only occur during an attempt to obtain a resource group lock on a file in info/ which is an invalid usage. Signed-off-by: Reinette Chatre --- Changes since v1: - Add snippet about why it is safe to dereference the kn to get to resource group name when resource group is deleted. --- fs/resctrl/ctrlmondata.c | 3 --- fs/resctrl/monitor.c | 2 -- fs/resctrl/rdtgroup.c | 20 +++++++++++--------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 7b90c36ff0a6..9915f714e26a 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -317,7 +317,6 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file= *of, rdtgroup_kn_unlock(of->kn); return -ENOENT; } - rdt_last_cmd_clear(); =20 /* Valid input requires a trailing newline */ if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') { @@ -434,7 +433,6 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of, } } else if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKED) { if (!rdtgrp->plr->d) { - rdt_last_cmd_clear(); rdt_last_cmd_puts("Cache domain offline\n"); ret =3D -ENODEV; } else { @@ -475,7 +473,6 @@ ssize_t rdtgroup_mba_mbps_event_write(struct kernfs_ope= n_file *of, rdtgroup_kn_unlock(of->kn); return -ENOENT; } - rdt_last_cmd_clear(); =20 /* Valid input requires a trailing newline */ if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') { diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 1a38f3b6a1f1..88f1fa0b9d8d 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1632,7 +1632,6 @@ int mbm_L3_assignments_show(struct kernfs_open_file *= of, struct seq_file *s, voi goto out_unlock; } =20 - rdt_last_cmd_clear(); if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { rdt_last_cmd_puts("mbm_event counter assignment mode is not enabled\n"); ret =3D -EINVAL; @@ -1772,7 +1771,6 @@ ssize_t mbm_L3_assignments_write(struct kernfs_open_f= ile *of, char *buf, rdtgroup_kn_unlock(of->kn); return -ENOENT; } - rdt_last_cmd_clear(); =20 /* Valid input requires a trailing newline */ if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') { diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 5100a8bb16f3..0f753a820702 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -359,7 +359,6 @@ static int rdtgroup_cpus_show(struct kernfs_open_file *= of, if (rdtgrp) { if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKED) { if (!rdtgrp->plr->d) { - rdt_last_cmd_clear(); rdt_last_cmd_puts("Cache domain offline\n"); ret =3D -ENODEV; } else { @@ -522,8 +521,6 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_f= ile *of, goto out_unlock; } =20 - rdt_last_cmd_clear(); - if (!buf || nbytes =3D=3D 0) { rdt_last_cmd_puts("Invalid input\n"); ret =3D -EINVAL; @@ -783,7 +780,6 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_= file *of, rdtgroup_kn_unlock(of->kn); return -ENOENT; } - rdt_last_cmd_clear(); =20 if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKED || rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP) { @@ -1464,7 +1460,6 @@ static ssize_t rdtgroup_mode_write(struct kernfs_open= _file *of, return -ENOENT; } =20 - rdt_last_cmd_clear(); /* Valid input requires a trailing newline */ if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') { rdt_last_cmd_puts("Invalid input\n"); @@ -1601,7 +1596,6 @@ static int rdtgroup_size_show(struct kernfs_open_file= *of, =20 if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKED) { if (!rdtgrp->plr->d) { - rdt_last_cmd_clear(); rdt_last_cmd_puts("Cache domain offline\n"); ret =3D -ENODEV; } else { @@ -2639,10 +2633,20 @@ struct rdtgroup *rdtgroup_kn_lock_live(struct kernf= s_node *kn) =20 cpus_read_lock(); mutex_lock(&rdtgroup_mutex); + rdt_last_cmd_clear(); =20 /* Was this group deleted while we waited? */ - if (rdtgrp->flags & RDT_DELETED) + if (rdtgrp->flags & RDT_DELETED) { + /* + * It is safe to dereference kn to obtain the resource group's + * name because one extra reference to kn is obtained + * during resource group creation that will be released by + * rdtgroup_remove() called by rdtgroup_kn_put(). + */ + rdt_last_cmd_printf("Resource group %s deleted. No commands possible.\n", + rdt_kn_name(rdtgrp->kn)); return NULL; + } =20 return rdtgrp; } @@ -3765,8 +3769,6 @@ static int mkdir_rdt_prepare(struct kernfs_node *pare= nt_kn, goto out_unlock; } =20 - rdt_last_cmd_clear(); - /* * Check that the parent directory for a monitor group is a "mon_groups" * directory. --=20 2.50.1 From nobody Sat Apr 4 04:43:38 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 3D2EC31D366 for ; Fri, 20 Mar 2026 22:04:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044247; cv=none; b=lwoCGBPEUeFg1xwDN0JgAW+ViKV3OrkZKgOx5OwMG8I3AS7xyzpIL6bJYWAD+FU7nPLygyv8gKhNzSTVEXbB476HXZNbNqr1rEUdsKxnE2KQ7d22hW0NNjwK2HklEIczdTxv0wy+6+zFg1rUk8OACQ7+6y+/5mLC9c5rEbljIgI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044247; c=relaxed/simple; bh=uagmdC59hqouoC9nt3mOjxUbMXJKXQbu0do93cnTrSg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SusjV+HPiCmAmNeHawMCufJRh0WHR5siMDs+F+JkxwzqG+2yoURlUNmTZA5/YPrunUAtYo+G34kgilm/JQFtKD/qAufT7rL1ib7zPFy5V73I2PUUTZ6azRRYPNKnQ1eZSZepbFtBSXh09OoKTKyGs5FtbSfK8jjEnKwAl1twb4Y= 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=NOkdTkTd; arc=none smtp.client-ip=198.175.65.9 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="NOkdTkTd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044245; x=1805580245; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uagmdC59hqouoC9nt3mOjxUbMXJKXQbu0do93cnTrSg=; b=NOkdTkTdyENTKYvGxzxYb3eOkz2/X4oDT6sYYj2tnTDg06ab1dxBzx86 7dtv1VC2qZCAeS6+t4cRLg1fpn9e+nRTuuFu7RQ0ReUPErk5ICkAOUYvV wSHXZ+hL3ujfgd+Sbg27Uv+Z6zyx/LjMAlVyYKnlTfPWQJ0JENtmGbeDN rSq8bL329YVvce+oB6y/+VywaarGE5MoGb5ca9tFbDp5s+o5dHn/yCf4B vIC0e/8rWQ9JQ1ll5emmhmKhyACq2TVHnjbInbb4cPnsBQM3bGsPA8rFJ tTERhW5xmQK2Oi+JUiYdJPldiFtT50AP+YkjqNok1Y717Qt1XsUgLQRrm A==; X-CSE-ConnectionGUID: +/MDKB9jQy6ojaTkLbLT8g== X-CSE-MsgGUID: jNNKfLXVQGWct2u+xfpslg== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758468" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758468" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:58 -0700 X-CSE-ConnectionGUID: cVN8upLqQGmxa+GQjXHNwA== X-CSE-MsgGUID: mbKrV3A7TvKJsSOZ0m/2Tg== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:57 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 14/14] fs/resctrl: Inform user space when status buffer overflowed Date: Fri, 20 Mar 2026 15:03:24 -0700 Message-ID: <0a2c56ac55725fe3131e214297649b9416671b9e.1774043709.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" resctrl fs commands are becoming more powerful with, for example, a user able to use syntax like '*' to make broad configuration changes. Such commands that span multiple domains may result in more than one message printed to the last_cmd_status buffer with more planned. Display "[truncated]" to user space when displaying the last_cmd_status buffer to communicate if it overflowed. Upon encountering this user space is expected to combine details about the failure found in info/last_cmd_sta= tus with related resctrl files to learn the accurate system state after the command failure. Signed-off-by: Reinette Chatre Reviewed-by: Ben Horgan --- fs/resctrl/rdtgroup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 0f753a820702..85d3ec36cd95 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -973,10 +973,13 @@ static int rdt_last_cmd_status_show(struct kernfs_ope= n_file *of, =20 mutex_lock(&rdtgroup_mutex); len =3D seq_buf_used(&last_cmd_status); - if (len) + if (len) { seq_printf(seq, "%.*s", len, last_cmd_status_buf); - else + if (seq_buf_has_overflowed(&last_cmd_status)) + seq_puts(seq, "[truncated]\n"); + } else { seq_puts(seq, "ok\n"); + } mutex_unlock(&rdtgroup_mutex); return 0; } --=20 2.50.1