public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [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

* Re: [LTP] [PATCH] syscalls/cachestat01: Fix num_shift calculation
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2025-09-11  9:34 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril,

> 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.

Thanks for fixing this!
Reviewed-by: Petr Vorel <pvorel@suse.cz>

> Closes #1258
very nit: I tend to use a regular link, i.e.:
Closes: https://github.com/linux-test-project/ltp/pull/1258

Why? in case project project will be moved elsewhere (gitlab?) and one will need
to figure out the link (whether it's an issue or PR).

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH] syscalls/cachestat01: Fix num_shift calculation
  2025-09-11  9:34 ` Petr Vorel
@ 2025-09-12  8:32   ` Cyril Hrubis
  0 siblings, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2025-09-12  8:32 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi!
> > Closes #1258
> very nit: I tend to use a regular link, i.e.:
> Closes: https://github.com/linux-test-project/ltp/pull/1258
> 
> Why? in case project project will be moved elsewhere (gitlab?) and one will need
> to figure out the link (whether it's an issue or PR).

Updated the Closes: tag and pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[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