* [LTP] [PATCH] syscalls/cachestat01: Fix num_shift calculation
@ 2025-09-11 8:57 Cyril Hrubis
2025-09-11 9:34 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2025-09-11 8:57 UTC (permalink / raw)
To: ltp
The calculation added in commit 8422d46 works only for 64k page size.
This commit fixes the calculation so that it properly detects maximal
num_shift regardless the page_size.
Closes #1258
Fixes: 8422d4680b21 ("cachestat01: Reduce required space on 64kb page size")
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
testcases/kernel/syscalls/cachestat/cachestat01.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/cachestat/cachestat01.c b/testcases/kernel/syscalls/cachestat/cachestat01.c
index e218747d9..aa6f21d41 100644
--- a/testcases/kernel/syscalls/cachestat/cachestat01.c
+++ b/testcases/kernel/syscalls/cachestat/cachestat01.c
@@ -72,7 +72,14 @@ static void run(unsigned int use_sync)
static void setup(void)
{
page_size = (int)sysconf(_SC_PAGESIZE);
- num_shift = MIN(tst_device->size*1024*2.5/page_size, 15);
+
+ for (num_shift = 0; num_shift <= 15; num_shift++) {
+ if ((1lu<<num_shift) * page_size / 1024 >= tst_device->size) {
+ tst_res(TINFO, "Limiting num_shift to %i\n", num_shift);
+ break;
+ }
+ }
+
page_data = SAFE_MALLOC(page_size);
memset(page_data, 'a', page_size);
}
--
2.49.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-12 8:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-11 8:57 [LTP] [PATCH] syscalls/cachestat01: Fix num_shift calculation Cyril Hrubis
2025-09-11 9:34 ` Petr Vorel
2025-09-12 8:32 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox