From nobody Thu Apr 9 13:36:09 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E5B63AB29E for ; Tue, 7 Apr 2026 16:02:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577757; cv=none; b=EPE9A+52liJxVWKwOEm60YQuItAue3oTAokAfCgAjiHQR5rbHrKGuTArv3+qaydFUjIwO43s6iNIo52nNSE2C8MAZhuWScIAa+tquJ4oun0H4Ku65fTKL8+WJLZzO3hmSB9eB0XAsiyZXmVhwzSDzlPjPhAUK/wT9wiwgZem7M8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577757; c=relaxed/simple; bh=Yv5EcUWXDpIZAFAX7DJdvguRmY2SyKl2ADW+bcIYyWk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kxxDYtB2JZKT2lTwPblnKrZp7IVA6hfw8WIaDEqfS3yRiaUw9zQtJNF9U3XXOIY2Jf04CGed1vGjvT/nzCKjoYXYb0+DivnUV4NWxIJM/HAYeipd7GYtrq/D4r3mjadmaOTpb53KVHSBBTzCNNl7QPLSwOxPeT0Hg/KP91gthSQ= 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=cvY4YyYZ; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="cvY4YyYZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775577752; x=1807113752; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Yv5EcUWXDpIZAFAX7DJdvguRmY2SyKl2ADW+bcIYyWk=; b=cvY4YyYZYJ0T8bhV9PJuMb+MSRbcISeymYjIP+nj89/9DAmlRr6Fz3QL IZOczq6TrRH/tFfyrLkFctsWfebnJx/RHGYdOISoy2Ms4mWmldMFPDpeL JZoimtzvJV1qE0L5b2t7pNVIkCjPLyi2YDAuqTx7W/OL4C2WlTmTdd87I eEQECcwwlfgyeYkzljBuv7kEJPxKisLq7kKUkSQbm7aD2Xzqr5yrOmVVz P7MS44Pbsr7nfmXOAgLDU/e/32dCWUQsV6/xl1PJ18kmOppM9+bJuzJFb gsBkNNjEO4LMDWDFh0Tku+Pm7W0z4rTiKF1kQnnTSonDvo+Th2CxB596z Q==; X-CSE-ConnectionGUID: YqVb3rhhQkemU7WtONiQuA== X-CSE-MsgGUID: YkzFrUKbRpuSC/7Z7sOZKw== X-IronPort-AV: E=McAfee;i="6800,10657,11752"; a="80432630" X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="80432630" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -0700 X-CSE-ConnectionGUID: HYEMzCy7QbG62lW+ayVb3Q== X-CSE-MsgGUID: 1owjR8IHQA2H3+ijhLJfdQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="228119031" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -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 v3 01/13] MAINTAINERS: Update resctrl entry Date: Tue, 7 Apr 2026 09:01:58 -0700 Message-ID: <4c14dd82e81737c6413e10fe097475b1cc0886fc.1775576382.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 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 c14718adb2d8..ee218defa5f5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22157,11 +22157,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 Thu Apr 9 13:36:09 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE2F939EF38 for ; Tue, 7 Apr 2026 16:02:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577754; cv=none; b=j1SCpLaP1F+HT/9j550tCNJC5HGlYyt9C2pKH1t7eDM2qecMy3aPZKaaXr8zbI7rzTLBKyTUabyndTSFWVfSbPl7LAaEHIRe6pMe7DPgMmCVEVh4K+2y139/7yg0id9lUkvW6IAuZNgxeREUtLCuB+idYKhSfEcEv9QsM3g8Gd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577754; c=relaxed/simple; bh=3L4hXu1knEj0HBaYia4CiizUwXDzBQpm5bYUEwGIm7s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dX8R7kwlAPZHfh4nPXEPvHIaGY5RpKEQvI87u6Lhb5B949d9KeatSZ88wWnV78oiqSXagXr4xN9k/2rnUrLZpeDAY9zmI7+wtcmfXlpw0HZb6VdeD52X0YOqNje/3X3jvHSyDLDNkjsUXbH8p/YtoXVu1psxDjM/hgL26f7gYwU= 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=YPz+OLBK; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YPz+OLBK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775577744; x=1807113744; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3L4hXu1knEj0HBaYia4CiizUwXDzBQpm5bYUEwGIm7s=; b=YPz+OLBK2cfFJqFEu2jYzrBLp8rsBHuRGAWBdRZ6G6/SKmlZ7XlYo5qS OD6vkipGlhFw7pcFmGHNJqtpOXGS9EhcFRsgbwGuOElfVeohfBn6+VdT+ kv6uoarfxYO8Sgdw7nlEwG2VLcLJPRUMInIH3vUtSbne/QE9n+Vc2Zbci GS0OV6ZQe1duSDKOjsqNGQ0ZYrbRAIKh+FeQ6Imi9TtkC109GHLfi+uqp 0okUIAqITcColzboevDaL/4e77Azd15x0cJKj6ZeNi0AoIbpuMI9xCStD ZQuzPqG0GMmsVnz8MAkLVj5dEzp3WMEKc3nLKvroG4Ps+dLRB556zSjVN Q==; X-CSE-ConnectionGUID: Fy8/ZxqvR0mc0pdqorgjbg== X-CSE-MsgGUID: 8xn4M0dcQXaAJWmyBMtEog== X-IronPort-AV: E=McAfee;i="6800,10657,11752"; a="80432640" X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="80432640" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -0700 X-CSE-ConnectionGUID: VpQkY95sQRuB3nixMsMDSw== X-CSE-MsgGUID: SwhC4WK0QB2RrjANABrM5g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="228119034" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -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 v3 02/13] fs/resctrl: Add missing return value descriptions Date: Tue, 7 Apr 2026 09:01:59 -0700 Message-ID: <1c50b9f7c73251c007133590986f127e1af57780.1775576382.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 --- Changes since v2: - Provide more detail in return value description: "size in bytes" -> "Size (in bytes) of cache portion represented by CBM" --- 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..5dfdaa6f9d8f 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) of cache portion represented by CBM, 0 on failu= re. */ 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 Thu Apr 9 13:36:09 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E08443CF048 for ; Tue, 7 Apr 2026 16:02:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577761; cv=none; b=m984428dyuVmpI0ugoDKsSvcnXuuMg79TJ2KVGDEnIhDKrffmZfJkFsWLCOYHgnf06wTS5FRqe9t+6TVnegvqnLCzUZuopMIKQlFCMmRCbTR0em+eb5KknhezBcWrGRcvKCRqjtkhgRFnbEScQzLMcsTN5/qzGOBMci5vweMh1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577761; c=relaxed/simple; bh=v12I4fNHeG9jvYo3wUAhnOp8GtSP5lv3bu1tJwepx+o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l0Qpk4TVRAkdaRQBjlXXWg9JsWvagKpxPAL0ktPV9pCSQLmMCEbIZTWe14dPZrlxGwX36SyyPnOZ2/nwP30GjZfPMUUsNoJN90TQD90gjI4ZIXBCUIje5XRiDf6pSa+8OlB3GT1KDWd1j0gnX1LS0JXAWuGdNp6U7RNwJPbUJgU= 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=iDaWR5+v; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iDaWR5+v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775577755; x=1807113755; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v12I4fNHeG9jvYo3wUAhnOp8GtSP5lv3bu1tJwepx+o=; b=iDaWR5+vSECnKrSDzAEXqQpjad/ziuke911Ie5XDA4hFnA2JgZRWXTSI vWWq/04P5wYQjX/NE6+z6nDwIHqVIU0CB6WxlRjz2RRb9vI+yUIvXmhrY TI0FPG76riV0v7ahlNzhgzZViUIQS0dMfVbptR3TBpOOcE1kq9lDhMTNp 4FuCmY0xMFriSYrVmQHZijV0lja/9Es+69g4UwtmtPCx5HHsXO0nwMjO2 oHomTGj7QED2rSxmrsbX9uQ9ndrUtJNDclp6d16B1u9pMZSigqDKJlim7 9zcjhPJBguTWe3z2aBVXdrExGgSjqGVC385e1YR2tG/EK6lwpM068IbES A==; X-CSE-ConnectionGUID: Bg9rzDvBRjOjfjsYYVc5sw== X-CSE-MsgGUID: P0Cz4FJBQtWJuh4gSjZttQ== X-IronPort-AV: E=McAfee;i="6800,10657,11752"; a="80432650" X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="80432650" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -0700 X-CSE-ConnectionGUID: OWVnNBT+QpWoGLOU0SsroA== X-CSE-MsgGUID: R9UhNcoCSlOivPNisG032Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="228119037" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -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 v3 03/13] fs/resctrl: Avoid "may be used uninitialized" warning Date: Tue, 7 Apr 2026 09:02:00 -0700 Message-ID: <56fa3b5937ec6fda4eec162393463d8dbfc1abe4.1775576382.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 Thu Apr 9 13:36:09 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CC27370D6E for ; Tue, 7 Apr 2026 16:02:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577761; cv=none; b=hzVGF5V9hFCXhL3KAsNFmxPLtk9LNBEJby13r2hdZarPNXrbvj9LF+kV5JZqJWiHBJkT3onZvocqz/DWElF32sq3uLy14y6uK8YHxxvBWZOgdiYTN0XL37TahLtwtxTvV6UZxe2GENvAemMqTm0158lJ+HjsK7eXQV8Jx6VN6dQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577761; c=relaxed/simple; bh=dxMeQSQAI9H8hX2jXObajzEdPFMeYDHhhrSWJaEFRwc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GYfBUHfGpZwhEwyn211iBplSx5uat2qtDJy3/illL+8OFwfIe7Vo/r/j8AKU926omyfpF8kQuHrJqRjtrM0VoJpvYVH+uCqhuO05SWv3fv+Gr/uZe8oAWsKPNdZrg1/ZOrwR2dI/dgTLeop0Jk7ENqFLTgioNttX5fJKxLSLKq4= 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=Li92CFb+; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Li92CFb+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775577756; x=1807113756; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dxMeQSQAI9H8hX2jXObajzEdPFMeYDHhhrSWJaEFRwc=; b=Li92CFb+Idp6sLtPFFLeJ0hBxo+icTuzktroKk8MPXh44A0U1H7mfyFt lt6gJmmm+ZjjXi1lFAK+zkfLYS70ddwthq5KleZczG1lUZgpgS7N880sk cgyY5G3gc7j/YiDB+BVPNzblL8+V2QI6AylzqOXMavuStI78bKRM0uyVq +c0bcHkAGkU3iUow8xxF5KG+K7pjxDFk3S0ReFE37pBSq9duk6eY4sjaW +CH/MKfyjhkq2VQy7QZ/Q0QYejjyDlXai7LgBRvKKeqTI90tUxnDshasF nNn/rNoO9W3qeqqRG6eDsuatgzMy9bYc6iBiFdZlw5HOSFRcXubzhSSEy w==; X-CSE-ConnectionGUID: PWBT5by/TOeu5MycN6hEzQ== X-CSE-MsgGUID: y/PbdHAvR0OEiEinIboM6A== X-IronPort-AV: E=McAfee;i="6800,10657,11752"; a="80432659" X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="80432659" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -0700 X-CSE-ConnectionGUID: fCBkfvl1RguHnBh+eSDjng== X-CSE-MsgGUID: LPtNjwpASKK0lUknhoHOBQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="228119040" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -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 v3 04/13] fs/resctrl: Use correct format specifier for printing error pointers Date: Tue, 7 Apr 2026 09:02:01 -0700 Message-ID: <3ec5d5ca313451725e5e230648f3b14eb747b05f.1775576382.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" 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 Thu Apr 9 13:36:09 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 967DD3A9636 for ; Tue, 7 Apr 2026 16:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577766; cv=none; b=dFKH3lA08lz1Jeu/ah/qHffSKRqw25Gzgq1nHnWgdHRtNqlCdBGO8DqzQfo054nZF0BhRmDndzbsRjV01wSAOb6GBgO23uyr0evJ+KaF3JzwWTzLDlEXggc3KiugZBfap0d3uFrbBt08Cgh/0QAPlCRQr18kuuWADr/bvmf8v2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577766; c=relaxed/simple; bh=XQbrDtV7kC3BagIoRNk2xRfz81oxluInULTjgTirvbA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DMEhVjS5eIZkaYLmRp7CDGkwImQjQSuOwVgmP0G/+trci5KkK596qKoDDtHaU/eoU27594+6wotF9k7v/7spGT4iHiuWnRP539K9hJKwmeAyliu4+4BggRSMq8DFz11uuXiOsN33mmfD8jwlCt3C2FAMqbOrGwU9dRABrumzftA= 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=GXYJPfY+; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GXYJPfY+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775577758; x=1807113758; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XQbrDtV7kC3BagIoRNk2xRfz81oxluInULTjgTirvbA=; b=GXYJPfY+idy/0pFDLJywSbGgjAXxQvH2dRSj9CCRbmP0RUoO97rexSh5 puNfF0gt4fEwlvFYKDWQ83ivgCroX+jfFjCMX0gY6YrR8zjR16krry8O7 acYXfXbO2eCNWZJJZS+Cp6f0tRyRo1l9jbouzQJNZgExtsH+iVSrOGZIu mU2rIR8En2grUfjneES9dPCXFLsACmN3Ca4eRNTAZn+YUCTuB5iL9VU2P 7Lf/jIuBmArUx0N/UCRytNLzTT0UVVubIqVWjTB4Rk//hSPC4Ns7iHaN5 anmsjR6o3PwaPk1qFMoNSXXR0ejrlK4DkKnQys/NPbAJzddah13UKvCLg w==; X-CSE-ConnectionGUID: FZflVr3YRC+tE7YdDQouzw== X-CSE-MsgGUID: H3OA2AAiR+SW5eK/61V+Sw== X-IronPort-AV: E=McAfee;i="6800,10657,11752"; a="80432669" X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="80432669" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:19 -0700 X-CSE-ConnectionGUID: 2soKQzR9SfidKoRKe14YCg== X-CSE-MsgGUID: lYGr73d7RAK7EVqt3miV3w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="228119043" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -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 v3 05/13] x86/resctrl: Protect against bad shift Date: Tue, 7 Apr 2026 09:02:02 -0700 Message-ID: <280c162f8b935d6c755027aa382d55e84ba31116.1775576382.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 Thu Apr 9 13:36:09 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 750AF3CCFD1 for ; Tue, 7 Apr 2026 16:02:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577770; cv=none; b=NtiCaqvRervSAm+fHhPcfz0eRXcFJiCEglRmWv5fDEk2Qq3GBKVaqFhoDUBdkQpi9nQYb4GIcPlIdZ2ocbp7ouMqKnPuypV65XMerN65jkYHA9v2PpZSYUcCHDcI+8XpvZF3Unvu69j2JDITgRMfauoOrUBQPTeaHcUvVLY2XXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577770; c=relaxed/simple; bh=arnafYuhnaMZc+KiEcaSFFq8ZsggDT06JfSKTL923xY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QZDd/E1ljwsqIG/CCE8Fneuulk5WODVxk9ra31oLvmkQ1mJqkgNwImQiMerBAbGh1QCb+ax0CGMOc5eIYPm5H0X9goVNH2+q8ePKEhUt+vI0vovgvp+tG1mroIkKh2LHbUTK0BDr9UgDH7zkO6jkEFDrkcFVxvZ/ggUMx/Y2jyo= 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=ENY6hsMO; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ENY6hsMO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775577763; x=1807113763; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=arnafYuhnaMZc+KiEcaSFFq8ZsggDT06JfSKTL923xY=; b=ENY6hsMO5jJeH9ylJtP5eQvqO45sCfkUPmdUAYxryYppgF6U4mlZslNC sk9cwXNEGXZkcloWlARFF9Orakisya92C+a6cstXQSuRuWDtjdLgjxphW pwdNc8X/1G95ZwGpeiUXYMd/kzQAVxHnllPQ+Dxq3kKppsgj8UhvUL9Jc 6G5XXBySU8GGPSfBOP9eFjwwhbD19rdCYNW1HlZ9GjtVTe6UVgvnA/Bea A4lj3HFCTtG0ivcElpTbVrIhzP9yM7kmjt9BKPjaJ0zk8WMDS+nziuhC0 GdGAyquMMGJEwgtcokYL9zpntXP1WwGpwPaFMtQ90mZ/r6Zqx/GQSN0t0 w==; X-CSE-ConnectionGUID: S1LgrwPCTRCQxiplR/35pg== X-CSE-MsgGUID: ZIjh7VG1RVSMP03EWQr0Ug== X-IronPort-AV: E=McAfee;i="6800,10657,11752"; a="80432679" X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="80432679" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:19 -0700 X-CSE-ConnectionGUID: 7bd/vY/9Q5metcBEUxCBgQ== X-CSE-MsgGUID: w9yQiyHIQvytEWAeAZJ5MQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="228119046" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -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 v3 06/13] fs/resctrl: Change pattern used to track number of entries in enum Date: Tue, 7 Apr 2026 09:02:03 -0700 Message-ID: <0a7a65609a1d3b5b734716287fba59ef702e5b42.1775576382.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 --- Changes since v2: - Add Ben's RB tag. --- 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 Thu Apr 9 13:36:09 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 722BB3CAE73 for ; Tue, 7 Apr 2026 16:02:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577773; cv=none; b=jxyhrO3oAJSiccmRJJB6r7QAUtUkNFWIzNq0PgTU41Mp70LtUPOshgWKnvGXg30etiSmmaFjTw6J+SuforftgabEobwHq6iyatSqui9fvnlNN4Ro/QPKOrRYqok0UcdsOKmf7XfzYkACvn2LDnWgzxTDnSTZZ2Fx6akTaqzcIqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577773; c=relaxed/simple; bh=UmtJaEEjPND1GwglwNpwhcFwJ4D2HpzVcTyZRXsHAY0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AG1wPWWFJtw5WQQV/2TkZu/SJFxbHYlcSn1hqOyYUYZEdjYLHIv0SgjHXIQnwRupqBb2qwu7tnzJWpDEBe9diMYDsaG5YuZaWfwqJp4d1tf8O6K1C8kzL+Mi1rh/b5BAnWP+Bj/SlyNKnidK6p1UAey1tZahQBZeUXew8Bma5rs= 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=brlasXss; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="brlasXss" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775577763; x=1807113763; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UmtJaEEjPND1GwglwNpwhcFwJ4D2HpzVcTyZRXsHAY0=; b=brlasXssSpn+EchdwZe8fXc34IXWWnaTYYOFJSGKz1QdQyWk12vER8pu TwxcbogKkDld9Y8/VfuUZ3/D4S2C3SXIg+8tdken6+bM6JaEcyObHkFFX jooY4smT2O8jD3O8hQhap/54e65UxKyCMQZySkRUJpEbedO75xEbMe3v3 qp1+SUkF3yJSsSKxKgTr1whr/vhJhKoN8xKFVwbAPkiQx49mu75//8q2N zDIL0iYDG41NQJqkp7axF4AV0ZFyK7JLeqILqEEgn+ZulotM+DGSs+12n Kvk8/pfBO4KsgQufC/GkOTr0K50R6Ixi0M3u+v0TmqTV3UN8Dlq0JqCml Q==; X-CSE-ConnectionGUID: zSD/sTAtQluAlNtkpDjapg== X-CSE-MsgGUID: aP9xXxKvSuWOWNqHkqnOng== X-IronPort-AV: E=McAfee;i="6800,10657,11752"; a="80432686" X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="80432686" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:19 -0700 X-CSE-ConnectionGUID: t3q8wxuPRWqfMdBNYIPfZQ== X-CSE-MsgGUID: i809PUXPQJK3CnY31pg2GQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="228119050" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -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 v3 07/13] fs/resctrl: Use accurate type for rdt_resource::rid Date: Tue, 7 Apr 2026 09:02:04 -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" 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) Changes since v2: - Add Ben's RB tag. --- 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 Thu Apr 9 13:36:09 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 657583A16BD for ; Tue, 7 Apr 2026 16:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577779; cv=none; b=FjejBHRCvvrl0bN8J8iLPFW8vIc3IaTVLMG6hdoUmd5CUPlCoF45uY1i4WQZyf/uXjg6ayA0E5hkGGvJVu9s/Ti54iKE7Hiw1/yXkikp6HlAx+HRfqpl2ANWhGeFnrG5TZEXYm4BhrsICNQ23IkzQHGNCI+9CftvKUX6K1WzbcU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577779; c=relaxed/simple; bh=A21P6fI2hgZ/+eGK6RsbbZ/oeCdwqcvHzTT8GH5JBd0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uVgBHVT/hx4fHUQtstDCHcPGWUNZZY/LZyDMp0wO8EskliKHht9HOXCInY1YkYMtw9cYe5/8+VY1ySHGWjZgf9potTeXXFkNr4tBh2ob1lO5DTt7yZ+EpVt7b2wniIvNZt023tW6X/iGqyLeKE088pA4qTi3jLZCNJzTw7dr0QI= 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=BcN1Lnzw; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BcN1Lnzw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775577768; x=1807113768; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=A21P6fI2hgZ/+eGK6RsbbZ/oeCdwqcvHzTT8GH5JBd0=; b=BcN1LnzwNLbdE0F+yld65DZm59F/USndJ9qDI3QpbCoLhv5BhE8yYdwD 9pqUPvHc/PlK67X6ntkcmKaNC40dMSR+jJhGiLiztcPxtrEqdfPAoPWp+ DqSAZeQkSKq/mDoOQeIi8S7iyGYPOKNbYmZbRGGNYoMizDnJphAQ7QwI8 rBZpQSU3F+Ogu6SOX1NAGHLAXh6bf3jh/XgTKyOvpEa0ZCV48fBPpUPib Fs/tUwnrzx70kXxUs7DrZb9INO60UxdzsXKhrLuMhthhAgrDAWFpD4xKC +fAE0q9VqZcvhKCF9DmXWbU29hhifNDHLzMLuLgmVOdaVNmyhMsF6O224 w==; X-CSE-ConnectionGUID: DhXLlxanTP6spqrzcka1MA== X-CSE-MsgGUID: YxunRLnhRlqEZrwbZpjeVA== X-IronPort-AV: E=McAfee;i="6800,10657,11752"; a="80432698" X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="80432698" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:19 -0700 X-CSE-ConnectionGUID: NXCIx0clSHml5fMfsl7FJQ== X-CSE-MsgGUID: zKgZjHhOSMKramdnomWG9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="228119053" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -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 v3 08/13] fs/resctrl: Pass error reading event through to user space Date: Tue, 7 Apr 2026 09:02:05 -0700 Message-ID: <839082c54e02953f60706854cc0d250949b6d71d.1775576382.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 Thu Apr 9 13:36:09 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A867B213254 for ; Tue, 7 Apr 2026 16:02:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577778; cv=none; b=ZFbLEcvM2i4NQ+TPCGMNx1uDUQJv/EIZKF9BvcxwR8c05DstK2miOh3GFrsYCx8qydxrYxHIXsmHQAvLywsT7CLcYuiPBSFe4GHbNyfDFXux+N2ZNB9dCj0HIg0+e9jQQP73rKuqtWgUK+O/8mckofGv6IsBBBSmogxw8RgS7TE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577778; c=relaxed/simple; bh=/aVegcj2Gd/PPwuq0w7v0DVXLWgC36AnHuP/93CopIQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SDP6nyqKV1TtxdfiThSV3ydwWdsZXrrr/3HJq4oueDTLu8kt5Fn5mVvyVqVr7wjqrOVfCYmOog/ZKkvDP1Bct1mH7QFVenFdSvsalVw3cj3MzPNKv4YbSt7FlaSy53DQKEZoAR8xh9MTV3aU8PAiDDb/2EuvnGSl6oVWpnr1s0U= 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=Y3veEfH6; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Y3veEfH6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775577770; x=1807113770; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/aVegcj2Gd/PPwuq0w7v0DVXLWgC36AnHuP/93CopIQ=; b=Y3veEfH6BfpPZbq9BcuFckxTuAuTdJQFhXJVJUYle00WazUCjv7Mf1Rf NJR8kcXQS3WMH4GgvVY43Nnpb8B9Ko8ecllVh9xgdaJ13JeU7yaMZtfZO EcG5pv69TcZM8lNVrXWGAPZmPa6zamYmqjaB77TiD3nGDDHlEvqKCvP5s avdS0ldibjjI71FY3R35A6p5t5bTyesYZrI7wE8lVIdfnQ7DYOKN5/t+f q2elMCcFaSxNPaynh0ACU/zNk9sFppxJpBWrhuZ/gROGuReU8UsnS8pK2 aFJze0ERqY/RpI/MKgEshf0f8Jc67EY5PzOsQLtv6n1ue8C71qhVUhpDo A==; X-CSE-ConnectionGUID: b46LJf2eTtqPIsYTy6t24A== X-CSE-MsgGUID: ri7TfywVR+GF7ytrqeY1PQ== X-IronPort-AV: E=McAfee;i="6800,10657,11752"; a="80432700" X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="80432700" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:19 -0700 X-CSE-ConnectionGUID: /8YAnnejSAaDG/xdgl374A== X-CSE-MsgGUID: tiC2GrJBRM2uvnQt2g6P5g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="228119056" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -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 v3 09/13] fs/resctrl: Add last_cmd_status support for writes to max_threshold_occupancy Date: Tue, 7 Apr 2026 09:02:06 -0700 Message-ID: <3a55b9a6ced4d1cfc69894840afa747de592ce5d.1775576382.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 --- Changes since v1: - Add Ben's RB tag. Changes since v2: - Switch to guard(). (Chenyu) - Drop Ben's RB tag due to significant code change. --- fs/resctrl/rdtgroup.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 5dfdaa6f9d8f..5e3ea92cc243 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -12,6 +12,7 @@ =20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 +#include #include #include #include @@ -1238,12 +1239,20 @@ static ssize_t max_threshold_occ_write(struct kernf= s_open_file *of, unsigned int bytes; int ret; =20 + guard(mutex)(&rdtgroup_mutex); + rdt_last_cmd_clear(); + ret =3D kstrtouint(buf, 0, &bytes); - if (ret) + if (ret) { + rdt_last_cmd_puts("Invalid input\n"); return ret; + } =20 - if (bytes > resctrl_rmid_realloc_limit) + if (bytes > resctrl_rmid_realloc_limit) { + rdt_last_cmd_printf("Exceeds limit (before adjustment) of %u bytes\n", + resctrl_rmid_realloc_limit); return -EINVAL; + } =20 resctrl_rmid_realloc_threshold =3D resctrl_arch_round_mon_val(bytes); =20 --=20 2.50.1 From nobody Thu Apr 9 13:36:09 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C65839DBD9 for ; Tue, 7 Apr 2026 16:02:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577786; cv=none; b=COc35E+i2qQrkgwQGuP69b6/zFpDPVROiWjRrleH//YuZ/OA3tMgqMClu3Kr+D3DJ9GCG3U0r/hFku2VFMdM+goyTZp3jpwpYKMaiB4XR5D/Du6JGS8OhKVGAl8PNSQCQ18CeKkbbfIHjb+rhoCtOvC7NkA9Xr191n5LMmMe3Zg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577786; c=relaxed/simple; bh=DBmG70Xr4+Z1t3xjsxbRIErkOrffXvoW6wckmtG8CM4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RvHvZQUqnrM+zX9bomA13QTtw5rIs48uhHDIapS7rYTZkCo5qz/y/CaLiPummsNt2pMwdc4aisv8KXuBeZWK6RsRt+J1xdLT5rYRZ3tG5eASXOVIZynjBP5RHQuB0nUmyqogRkvku2U9bz00Fw6jG4C1HHHhei3QPAYYqVojhQI= 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=eqXnlTVc; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eqXnlTVc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775577779; x=1807113779; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DBmG70Xr4+Z1t3xjsxbRIErkOrffXvoW6wckmtG8CM4=; b=eqXnlTVcbQHiNpp4+78lHN6h78qnovyyK81YkEx19ESTey7U74MurEZu pyfeI1PpeQ8+CaNhatYT4vd+3g6mP3k5ah9jjZhAdW1WBOVNOMpW7WD2T JTd3XeECwjXsThtEf+yj53zsnrnDQXzkXcJmXwVLG2MmqTP/Qw2AaDrJU OmIvrOqIpQkXq3VjqXpHnYmteSXroeEKd+FYRDoaV2uCDvNE5PNA4+oLJ 23bapmJl9Nb8Y0C9IPykzU3dHTes0fMxdB6gJesx5SMR3A3qvH5IYC2yQ wYMj8URbBVHGMLcdzj7SpforaAHCH9n1VxMem8RrLGe4ynqZbLn48rJLo Q==; X-CSE-ConnectionGUID: rXH7KQ/vSNO01nLrDj0M+A== X-CSE-MsgGUID: IW+veAxQQpe/DTllrroIKA== X-IronPort-AV: E=McAfee;i="6800,10657,11752"; a="80432717" X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="80432717" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:19 -0700 X-CSE-ConnectionGUID: BSgNVgdgT+ml23rXCqpn/g== X-CSE-MsgGUID: SJZQJCeKT6WR5TCpc7f0bQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="228119059" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -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 v3 10/13] fs/resctrl: Use accurate and symmetric exit flows Date: Tue, 7 Apr 2026 09:02:07 -0700 Message-ID: <1762225e701717c34ba544e9d92bc1af9f453f7e.1775576382.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 9a7dfc48cb2e..8a43efe67a95 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 Thu Apr 9 13:36:09 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63B0D3CF68E for ; Tue, 7 Apr 2026 16:02:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577782; cv=none; b=upKaS90KAt6f+MCywD+KsAFjg8H2joqjOYl0fITV/bPqIU+BD+Mc5KOiAxlmRhmx0JBTAFcsDRQFKIDhbxXDX9ct+v2jT5JuBLgqEYeHrBwFccLe3tgwceMppoD7SHVg39BEi2kU4RFkk0BgK/rTuy0aVImF2FyNIzk5nonjTz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577782; c=relaxed/simple; bh=ClrkB0PcIBu61gvXQBQnJibsI5pxz5caod8xkzFYwTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B6TZ5qMc/gctJQzN270j0Pk1M+Vvu9OOQO484C11Qx4j7mfOTf3fllRTLliRrdonRVVR3AfCiqIXBw0jl0XxIrJqTSZq4Bf06d2X3fowgUD1u31neabrNttCThcLYSDTf8AKPUPNEWt0URsdE6EaPozZfRk19JuzWTLhi6OUiMw= 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=KQP7T0ua; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KQP7T0ua" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775577773; x=1807113773; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ClrkB0PcIBu61gvXQBQnJibsI5pxz5caod8xkzFYwTI=; b=KQP7T0uaPrW7Ev2Iurgs3aOlVgZmzpKq0cShmgIzBtABEV7CE46pluVV 9ybs0nrKIZ4qBAmohcDDuVYMVk0JJB38tF73weF4Qg4fgKqm94+3a2Z9Q UxbPWZFaMHIBXeQ3XJW81hdoR9uxMU4b3pAjcnuibgKTx89SHs1fM1qNg R3TXtaACQLA6NnIAoCa9y7M+fe9IDaG8rFfQtnpOXfNaT1TT2C7g1MlTl INLxybmWPI26xfNVbhLcSuRmnqt03hl+DhCpaNvC9lX9XNYD0xvCFgebX FuLFfH1ZtMAPq44Ndd7+EDw5lOeSQaMcpI7QDvdaSfUiwey2h1Ywy+8WQ g==; X-CSE-ConnectionGUID: kBVVZuzqRqetEVuAGuiZdQ== X-CSE-MsgGUID: uHgQxx8iQiavBLQ9J0C/vQ== X-IronPort-AV: E=McAfee;i="6800,10657,11752"; a="80432719" X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="80432719" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:19 -0700 X-CSE-ConnectionGUID: zBhJoni8TZGqbA/0WJ6/dg== X-CSE-MsgGUID: biHFblZpTS21NMk+P00vBA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="228119062" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -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 v3 11/13] fs/resctrl: Change last_cmd_status custom during input parsing Date: Tue, 7 Apr 2026 09:02:08 -0700 Message-ID: <3ac4f26326d704f5a31922b036e07e1b07b81763.1775576382.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 | 82 +++++++++++++++++++++++----------------- 3 files changed, 117 insertions(+), 79 deletions(-) diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 8a43efe67a95..5d5e844429df 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; @@ -1018,16 +1029,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 5e3ea92cc243..755a46ef5bdb 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -512,38 +512,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) - 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) { + 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)) @@ -553,7 +553,7 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_f= ile *of, =20 if (ret) { rdt_last_cmd_puts("Bad CPU list/mask\n"); - goto unlock; + goto out_free; } =20 /* check that user didn't specify any offline cpus */ @@ -561,7 +561,7 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_f= ile *of, 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) @@ -571,11 +571,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; } @@ -1452,11 +1453,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); @@ -1464,6 +1460,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 @@ -1789,19 +1793,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 @@ -1815,19 +1823,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 Thu Apr 9 13:36:09 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2E8E3D0916 for ; Tue, 7 Apr 2026 16:02:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577794; cv=none; b=FylqGLwaaTCITA/z/9HUEUPReRGGanc47z9QAkbGE6VWz6+c32srcYoukGXecmkiJEV9CkGsmSH+N3vTC39CPbses+77RJPm+R46bqI3bCHPmysp+BkAIiGZibH88Y2kjauzlQGvCTPwEdnBK4kPVYxTkNDtnQY0WGnAV4voIAI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577794; c=relaxed/simple; bh=3Adg0a/ffzd9vkO8eZLWDW54/0mR9Ia0jl60u5Zyr/s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qHe+8ovI+UIiXky138yn6cS152Xm8Y9pOTLHbx/b+JtIolYKviBvJ4evWNe1AO+TSkl8/o2UhsEU2wSMTUeDIf6aWCQW0hpT3HgIxFxLD6GUcHKH07hvSRqnZuk1EmAVd7ABhLDQCQQEKW7cmsb9FtZHRPiQFNNG28MKMR3iYCM= 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=W8qfNSLg; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="W8qfNSLg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775577779; x=1807113779; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3Adg0a/ffzd9vkO8eZLWDW54/0mR9Ia0jl60u5Zyr/s=; b=W8qfNSLg73TZnPgWRNI6qChw0Q1EYuxVXuFJEuLiBoGquzCUgx0pWSDb PYBo+oYXXxSIlV0bQH91EI0lVHwuaMMyT2TiFqELY5HPAs64vOlnWT2Xc 5yjYypYtgumXqXiSwKWA9PrdzSt+Co/nAgiLvkGhoSgkrWAZmaUolIodA r8JjVy7rO7X2OJnA0zatwDW9e9MlPEiIgUVllj/azNAf74Fx/ZAwJouy8 SnsyQeNDHmGsMf76cuk0hPM3MhehPkSHKKv1iosA9hoeOJXX5f0p1eXVx 9sxzTW6OGLJJbTXw/N6Y4x9z3uSZ3Ajb4EfgMqjAsvcE6gY9hyrCOPiHL w==; X-CSE-ConnectionGUID: 8RTtdqA+R42o/0fKBK05Qw== X-CSE-MsgGUID: AXPJbj5TSui+f5oBMfOsqA== X-IronPort-AV: E=McAfee;i="6800,10657,11752"; a="80432735" X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="80432735" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:19 -0700 X-CSE-ConnectionGUID: 4JasPtLARfi9esEovcd1Rw== X-CSE-MsgGUID: e65qgHUaT3+0no3+3F8zMg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="228119066" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -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 v3 12/13] fs/resctrl: Communicate resource group deleted error via last_cmd_status Date: Tue, 7 Apr 2026 09:02:09 -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" 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 5d5e844429df..26bbf4ecdbca 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 755a46ef5bdb..0677e6e4102e 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -360,7 +360,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 { @@ -523,8 +522,6 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_f= ile *of, goto out_unlock; } =20 - rdt_last_cmd_clear(); - if (!buf) { rdt_last_cmd_puts("Invalid input\n"); ret =3D -EINVAL; @@ -781,7 +778,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) { @@ -1459,7 +1455,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"); @@ -1596,7 +1591,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 { @@ -2634,10 +2628,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; } @@ -3760,8 +3764,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 Thu Apr 9 13:36:09 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C22FB3C6A56 for ; Tue, 7 Apr 2026 16:03:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577789; cv=none; b=lRVZkY6xXThS99YJ+khASeJgHpb80opn/N/iOFGGRQFhLSBaI7bC0jW9zHnBKO9ISnzqvrfWjUj+6cTrFQmYyZMLbBK1BLcwj1m5ZUGjMBhLEYKJ+Ltq2FfI4UXsAo5MTTOsHIdEde6oyQK13rRDX4wDrIoCLz2+4E4Dcy5DjZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775577789; c=relaxed/simple; bh=kmpz5ziyeYgyjq9BX9vfAEaKU1VXDjgMSNyT/xCR9+Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LltIDGc1wFEg4rOWhDhYCuM8snKmotPdixWJ0k9XTQfLgDEnD1BTLMu4dv6CrNwA9ZJ2PT6ScJAyj2si7PgUYUbibr/h+yOWK+o1PoDXNZ+RaafjyUAhmmNmk4/bbZVqrmlpgaljYqXhNm/bzeCbSPkZt6iEdqcsM01/y55zY3M= 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=jp/nIa/S; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jp/nIa/S" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775577782; x=1807113782; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kmpz5ziyeYgyjq9BX9vfAEaKU1VXDjgMSNyT/xCR9+Q=; b=jp/nIa/SWKbE5SAK+HYWpaNCpSnE7bAcq7PYRq032DtiUTXyTRGLsUb4 cZVg+7ZJLAFkqzFBo7n4TKH2Xvo2tFo4YAn4ox2SHhqe1hXeHXRmR8FWa wu+Y4WH+Tn4GiWT64RAto9rVbJfJ711b11Gg3K2Qd8Mkvslf9tDsT+6j/ YjD5BB2O/WfTKRTnG6SvW7J7ZZQ1sOuJDaosD3CN5z8Ll82qj4wwgOcLk BsN3/5ZqyLHoT0MXM4C6Jy5ir6z5sVbMIMKG/vRhfnMiIBzMQFVMb7/kb 3CIkEazlqFM7BNhStCDmf4xP6TvsINd9phpJf/QIIPpHX+LkGBRIShvgx w==; X-CSE-ConnectionGUID: MsEwkjjhT+2SeD93O0reLw== X-CSE-MsgGUID: Qb25CyuFQKyS5MegqQUM/Q== X-IronPort-AV: E=McAfee;i="6800,10657,11752"; a="80432738" X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="80432738" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:19 -0700 X-CSE-ConnectionGUID: Y85Y3FGASnaJsp9BEqyRjA== X-CSE-MsgGUID: eu0ImZeMSqKieK3u8x93bw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,165,1770624000"; d="scan'208";a="228119069" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2026 09:02:18 -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 v3 13/13] fs/resctrl: Inform user space when status buffer overflowed Date: Tue, 7 Apr 2026 09:02:10 -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" 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 --- Changes since v2: - Add Ben's RB tag. --- 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 0677e6e4102e..5413a625ff32 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -971,10 +971,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