cachestat01: Reduce required space on 64kb page size
PATCH v2 1/1 cachestat01: Reduce required space on 64kb page size
ppc64le (6.10.1 on Tumbleweed) fails due 64kb page size requiring more space:
cachestat01.c:39: TINFO: Number of pages: 4096 cachestat01.c:56: TPASS: cachestat(fd, cs_range, cs, 0) passed cachestat01.c:59: TPASS: cs->nr_cache + cs->nr_evicted == num_pages (4096) cachestat01.c:38: TINFO: Disable file synchronization cachestat01.c:39: TINFO: Number of pages: 8192 cachestat01.c:46: TBROK: write(3,0x1000ddb0aa0,65536) failed: ENOSPC (28)
Therefore use calculation, which enables maximum number of pages 1 << 15 only for 4kb page size, for 64kb set the maximum number of pages 1 << 12 (13 would trigger ENOSPC on XFS and Btrfs).
---
changes v1->v2:
* calculate number of pages (or more precisely calculate the shift) @Cyril: I'm not sure, if you like it this way, feel free to further improve.
v1:
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
https://lore.kernel.org/ltp/[email protected]/
Kind regards,
Petr
testcases/kernel/syscalls/cachestat/cachestat01.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/cachestat/cachestat01.c +3 -3
@@ -26,7 +26,7 @@#define MNTPOINT "mntpoint"#define FILENAME MNTPOINT "/myfile.bin" -static int page_size; +static int page_size, num_shift;static char *page_data;static struct cachestat *cs;static struct cachestat_range *cs_range;
@@ -67,14 +67,14 @@ static void test_cached_pages(const unsigned int use_sync, const int num_pages)static void run (unsigned int use_sync) { -for (int i =0 ; i <15 ; i++) +for (int i =0 ; i < num_shift; i++)test_cached_pages (use_sync,1 << i); }static void setup (void ) { page_size = (int )sysconf (_SC_PAGESIZE); - + num_shift =MIN (tst_device->size*1024 *2.6 /page_size,15 ); page_data =SAFE_MALLOC (page_size);memset (page_data,'a' , page_size); }
Signature · 5 lines
2.45.2 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
testcases/kernel/syscalls/cachestat/cachestat01.c static void test_cached_pages(const unsigned int use_sync, const int num_pages) · line 77
Quoted 1 line
testcases/kernel/syscalls/cachestat/cachestat01.c +1
-0+ num_shift =MIN (tst_device->size*1024 *2.6 /page_size,15 );
I guess that we can make it future proof by rounding the 2.6 to 3 just to avoid failures in the future when filesystems consume just a bit more space for a metadata...
Other than that:
Quoted 6 lines
testcases/kernel/syscalls/cachestat/cachestat01.c +0
-0page_data =SAFE_MALLOC (page_size);memset (page_data,'a' , page_size); }Signature · 1 line
2.45.2
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 3 lines
testcases/kernel/syscalls/cachestat/cachestat01.c static void test_cached_pages(const unsigned int use_sync, const int num_pages) · line 77
Quoted 1 line
testcases/kernel/syscalls/cachestat/cachestat01.c +1
-0+ num_shift =MIN (tst_device->size*1024 *2.6 /page_size,15 );I guess that we can make it future proof by rounding the 2.6 to 3 just
And that is on the wrong side obviously, so we should do rounding down to 2 or 2.2 or something along the lines.
Quoted 20 lines
to avoid failures in the future when filesystems consume just a bit more space for a metadata...
Other than that:
Reviewed-by Cyril Hrubis <[email protected]>Quoted 6 lines
testcases/kernel/syscalls/cachestat/cachestat01.c +0
-0page_data =SAFE_MALLOC (page_size);memset (page_data,'a' , page_size); }Signature · 1 line
2.45.2Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 7 lines
Hi!
Quoted 3 lines
testcases/kernel/syscalls/cachestat/cachestat01.c static void test_cached_pages(const unsigned int use_sync, const int num_pages) · line 77
Quoted 1 line
testcases/kernel/syscalls/cachestat/cachestat01.c +1
-0+ num_shift =MIN (tst_device->size*1024 *2.6 /page_size,15 );I guess that we can make it future proof by rounding the 2.6 to 3 just
And that is on the wrong side obviously, so we should do rounding down to 2 or 2.2 or something along the lines.
Yes, 3* would fail.
FYI df on good, after last run:
2* => max num_shift < 9 => 1 << 8 (256 pages)
/dev/loop0 xfs 241664 20304 221360 9% /var/tmp/LTP_cacSuoazD/mntpoint /dev/loop0 btrfs 307200 22368 207872 10% /var/tmp/LTP_cacSuoazD/mntpoint
2.5* => max num_shift < 11 => 1 << 10 (1024 pages) Highest usage (others have 1% or even 0%):
/dev/loop0 xfs 241664 20304 221360 9% /var/tmp/LTP_cacanBaAa/mntpoint /dev/loop0 btrfs 307200 71648 158720 32% /var/tmp/LTP_cacanBaAa/mntpoint
2.6* (or 2.7) => max num_shift < 12 => 1 << 11 (2048 pages) => last OK Highest usage (others have 1% or even 0%):
/dev/loop0 xfs 241664 20304 221360 9% /var/tmp/LTP_cacFYiONa/mntpoint /dev/loop0 btrfs 307200 137344 93184 60% /var/tmp/LTP_cacrzr4vk/mntpoint
Failures:
2.8* => max num_shift < 13: 1 << 12 (4096 pages) => FAIL on XFS, Btrfs 3* => max num_shift < 14 => 1 << 13 (8192 pages) FAIL on all filesystems
Problem is only with Btrfs and XFS. Others have between 0-1% (including Bcachefs). Therefore 2.6* (or 2.7*) is IMHO still secure.
If you worry, we can have 2.5* (more secure).
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 3 lines
Problem is only with Btrfs and XFS. Others have between 0-1% (including Bcachefs). Therefore 2.6* (or 2.7*) is IMHO still secure.
If you worry, we can have 2.5* (more secure).
Let's go for 2.5 then.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 6 lines
Hi!
Quoted 3 lines
Problem is only with Btrfs and XFS. Others have between 0-1% (including Bcachefs). Therefore 2.6* (or 2.7*) is IMHO still secure.
If you worry, we can have 2.5* (more secure).Let's go for 2.5 then.
Thanks, merged!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
On 2024/8/1 pm 5:14, Petr Vorel wrote:
Hi Petr and Cyri,
I encountered the same problem when using 16K page. The calculatednum_sthift is 5 (300 * 1024 * 2.5/16384~=46), and the final write size is 16384 * (2<<15)=512MB, so num_sthift is too large.
I think we can change the calculation method of num_sthift to:
unsigned int max_shift = log2(tst_device->size*MB(1)/page_size); num_shift = MIN(max_shift, 15);
Quoted 12 lines
Quoted 6 lines
Hi!
Quoted 3 lines
Problem is only with Btrfs and XFS. Others have between 0-1% (including Bcachefs). Therefore 2.6* (or 2.7*) is IMHO still secure.
If you worry, we can have 2.5* (more secure).Let's go for 2.5 then.
Thanks, merged!
Kind regards,
Petr
Signature · 6 lines
Best Regards Hongchen Zhang -- Mailing list info: https://lists.linux.it/listinfo/ltp