[<prev] [next>] [day] [month] [year] [list]
Message-ID: <c5807e73e0f4068392036a867d24a8e21c200421.1761464280.git.christophe.jaillet@wanadoo.fr>
Date: Sun, 26 Oct 2025 08:39:52 +0100
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Tony Luck <tony.luck@...el.com>,
Reinette Chatre <reinette.chatre@...el.com>,
Dave Martin <Dave.Martin@....com>,
James Morse <james.morse@....com>,
Babu Moger <babu.moger@....com>
Cc: linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org,
Christophe JAILLET <christophe.jaillet@...adoo.fr>
Subject: [PATCH] fs/resctrl: Slightly optimize cbm_validate()
'first_bit' is known to be 1, so it can be skipped when searching for the
next 0 bit. Doing so mimics bitmap_next_set_region() and can save a few
cycles.
Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
Compile tested only.
For the records, on x86, the diff of the asm code is:
--- fs/resctrl/ctrlmondata.s.old 2025-10-26 08:21:46.928920563 +0100
+++ fs/resctrl/ctrlmondata.s 2025-10-26 08:21:40.864024143 +0100
@@ -1603,11 +1603,12 @@
call _find_first_bit
# ./include/linux/find.h:192: return _find_next_zero_bit(addr, size, offset);
movq %r12, %rsi
- leaq 48(%rsp), %rdi
- movq %rax, %rdx
+# fs/resctrl/ctrlmondata.c:133: zero_bit = find_next_zero_bit(&val, cbm_len, first_bit + 1);
+ leaq 1(%rax), %rdx
# ./include/linux/find.h:214: return _find_first_bit(addr, size);
movq %rax, 8(%rsp)
# ./include/linux/find.h:192: return _find_next_zero_bit(addr, size, offset);
+ leaq 48(%rsp), %rdi
call _find_next_zero_bit
# fs/resctrl/ctrlmondata.c:136: if (!r->cache.arch_has_sparse_bitmasks &&
leaq 28(%rbx), %rdi
---
fs/resctrl/ctrlmondata.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c
index 0d0ef54fc4de..1ff479a2dbbc 100644
--- a/fs/resctrl/ctrlmondata.c
+++ b/fs/resctrl/ctrlmondata.c
@@ -130,7 +130,7 @@ 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);
+ zero_bit = find_next_zero_bit(&val, cbm_len, first_bit + 1);
/* Are non-contiguous bitmasks allowed? */
if (!r->cache.arch_has_sparse_bitmasks &&
--
2.51.0
Powered by blists - more mailing lists