All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] x86/resctrl: Fix zero cbm for AMD in cbm_validate
@ 2022-05-17  0:12 Stephane Eranian
  2022-05-17 16:33 ` Fenghua Yu
  2022-10-18 18:33 ` [tip: x86/urgent] x86/resctrl: Fix min_cbm_bits for AMD tip-bot2 for Babu Moger
  0 siblings, 2 replies; 11+ messages in thread
From: Stephane Eranian @ 2022-05-17  0:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: fenghua.yu, reinette.chatre, babu.moger, x86

AMD supports cbm with no bits set as reflected in rdt_init_res_defs_amd() by:

	r->cache.arch_has_empty_bitmaps = true;

However given the unified code in cbm_validate(), checking for:

    val == 0 && !arch_has_empty_bitmaps

is not enough because you also have in cbm_validate():
	if ((zero_bit - first_bit) < r->cache.min_cbm_bits)

Default value for if r->cache.min_cbm_bits = 1

Leading to:

$ cd /sys/fs/resctrl
$ mkdir foo
$ cd foo
$ echo L3:0=0 > schemata
-bash: echo: write error: Invalid argument

Patch initializes fixes the logic in cbm_validate() to take into account
arch_has_empty_bitmaps when true and cbm value is 0.

Fixes: 316e7f901f5a ("x86/resctrl: Add struct rdt_cache::arch_has_{sparse, empty}_bitmaps")

Signed-off-by: Stephane Eranian <eranian@google.com>
---
 arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index 87666275eed9..f376ed8bff8f 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -107,6 +107,10 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)
 	first_bit = find_first_bit(&val, cbm_len);
 	zero_bit = find_next_zero_bit(&val, cbm_len, first_bit);
 
+	/* no need to check bits if arch supports no bits set */
+	if (r->cache.arch_has_empty_bitmaps && val == 0)
+		goto done;
+
 	/* Are non-contiguous bitmaps allowed? */
 	if (!r->cache.arch_has_sparse_bitmaps &&
 	    (find_next_bit(&val, cbm_len, zero_bit) < cbm_len)) {
@@ -119,7 +123,7 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)
 				    r->cache.min_cbm_bits);
 		return false;
 	}
-
+done:
 	*data = val;
 	return true;
 }
-- 
2.36.0.550.gb090851708-goog


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-10-18 18:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17  0:12 [PATCH v2] x86/resctrl: Fix zero cbm for AMD in cbm_validate Stephane Eranian
2022-05-17 16:33 ` Fenghua Yu
2022-05-17 16:49   ` Reinette Chatre
2022-05-17 17:27     ` Fenghua Yu
2022-05-17 18:10       ` Reinette Chatre
2022-05-18 16:34         ` Fenghua Yu
2022-05-25 13:10           ` Stephane Eranian
2022-07-25 19:47             ` Babu Moger
2022-08-01 14:58               ` Moger, Babu
2022-08-01 15:19                 ` Stephane Eranian
2022-10-18 18:33 ` [tip: x86/urgent] x86/resctrl: Fix min_cbm_bits for AMD tip-bot2 for Babu Moger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.