public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 1/1] cachestat01: Reduce required space on 64kb page size
@ 2024-07-31  7:34 Petr Vorel
  2024-07-31 10:32 ` Cyril Hrubis
  0 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2024-07-31  7:34 UTC (permalink / raw)
  To: ltp

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

Fixes: 93b28ee69d ("Add cachestat01 test")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
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/20240729223431.1307306-1-pvorel@suse.cz/
https://lore.kernel.org/ltp/20240729223431.1307306-1-pvorel@suse.cz/

Kind regards,
Petr

 testcases/kernel/syscalls/cachestat/cachestat01.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/cachestat/cachestat01.c b/testcases/kernel/syscalls/cachestat/cachestat01.c
index f7f6275cbd..287a67f544 100644
--- a/testcases/kernel/syscalls/cachestat/cachestat01.c
+++ b/testcases/kernel/syscalls/cachestat/cachestat01.c
@@ -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);
 }
-- 
2.45.2


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

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

* Re: [LTP] [PATCH v2 1/1] cachestat01: Reduce required space on 64kb page size
  2024-07-31  7:34 [LTP] [PATCH v2 1/1] cachestat01: Reduce required space on 64kb page size Petr Vorel
@ 2024-07-31 10:32 ` Cyril Hrubis
  2024-07-31 10:39   ` Cyril Hrubis
  0 siblings, 1 reply; 7+ messages in thread
From: Cyril Hrubis @ 2024-07-31 10:32 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi!
> +	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:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

>  	page_data = SAFE_MALLOC(page_size);
>  	memset(page_data, 'a', page_size);
>  }
> -- 
> 2.45.2
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v2 1/1] cachestat01: Reduce required space on 64kb page size
  2024-07-31 10:32 ` Cyril Hrubis
@ 2024-07-31 10:39   ` Cyril Hrubis
  2024-07-31 19:30     ` Petr Vorel
  0 siblings, 1 reply; 7+ messages in thread
From: Cyril Hrubis @ 2024-07-31 10:39 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi!
> > +	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.

> to avoid failures in the future when filesystems consume just a bit more
> space for a metadata...
> 
> Other than that:
> 
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
> 
> >  	page_data = SAFE_MALLOC(page_size);
> >  	memset(page_data, 'a', page_size);
> >  }
> > -- 
> > 2.45.2
> > 
> 
> -- 
> Cyril Hrubis
> chrubis@suse.cz
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v2 1/1] cachestat01: Reduce required space on 64kb page size
  2024-07-31 10:39   ` Cyril Hrubis
@ 2024-07-31 19:30     ` Petr Vorel
  2024-08-01  9:00       ` Cyril Hrubis
  0 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2024-07-31 19:30 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

> Hi!
> > > +	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

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

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

* Re: [LTP] [PATCH v2 1/1] cachestat01: Reduce required space on 64kb page size
  2024-07-31 19:30     ` Petr Vorel
@ 2024-08-01  9:00       ` Cyril Hrubis
  2024-08-01  9:14         ` Petr Vorel
  0 siblings, 1 reply; 7+ messages in thread
From: Cyril Hrubis @ 2024-08-01  9:00 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

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

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v2 1/1] cachestat01: Reduce required space on 64kb page size
  2024-08-01  9:00       ` Cyril Hrubis
@ 2024-08-01  9:14         ` Petr Vorel
  2024-10-18  7:50           ` Hongchen Zhang
  0 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2024-08-01  9:14 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

> Hi!
> > 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

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

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

* Re: [LTP] [PATCH v2 1/1] cachestat01: Reduce required space on 64kb page size
  2024-08-01  9:14         ` Petr Vorel
@ 2024-10-18  7:50           ` Hongchen Zhang
  0 siblings, 0 replies; 7+ messages in thread
From: Hongchen Zhang @ 2024-10-18  7:50 UTC (permalink / raw)
  To: Petr Vorel; +Cc: 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 calculated 
num_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);

>> Hi!
>>> 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
> 


-- 
Best Regards
Hongchen Zhang


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

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

end of thread, other threads:[~2024-10-18  7:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-31  7:34 [LTP] [PATCH v2 1/1] cachestat01: Reduce required space on 64kb page size Petr Vorel
2024-07-31 10:32 ` Cyril Hrubis
2024-07-31 10:39   ` Cyril Hrubis
2024-07-31 19:30     ` Petr Vorel
2024-08-01  9:00       ` Cyril Hrubis
2024-08-01  9:14         ` Petr Vorel
2024-10-18  7:50           ` Hongchen Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox