* [LTP] [PATCH v3 0/2] swap{on,off} fixes for page size > 4KB
@ 2024-04-25 21:10 Petr Vorel
2024-04-25 21:10 ` [LTP] [PATCH v3 1/2] libswap: Add {SAFE_, }MAKE_SMALL_SWAPFILE() macros Petr Vorel
2024-04-25 21:10 ` [LTP] [PATCH v3 2/2] libswap: Use {SAFE_,}MAKE_MINIMAL_SWAPFILE() Petr Vorel
0 siblings, 2 replies; 6+ messages in thread
From: Petr Vorel @ 2024-04-25 21:10 UTC (permalink / raw)
To: ltp
Changes v2->v3:
* s/MAKE_MINIMAL_SWAPFILE/MAKE_SMALL_SWAPFILE/
Petr Vorel (2):
libswap: Add {SAFE_,}MAKE_SMALL_SWAPFILE() macros
libswap: Use {SAFE_,}MAKE_MINIMAL_SWAPFILE()
include/libswap.h | 18 ++++++++++++++++++
libs/libltpswap/libswap.c | 2 +-
testcases/kernel/syscalls/swapoff/swapoff02.c | 2 +-
testcases/kernel/syscalls/swapon/swapon02.c | 4 ++--
testcases/kernel/syscalls/swapon/swapon03.c | 4 ++--
5 files changed, 24 insertions(+), 6 deletions(-)
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread* [LTP] [PATCH v3 1/2] libswap: Add {SAFE_, }MAKE_SMALL_SWAPFILE() macros 2024-04-25 21:10 [LTP] [PATCH v3 0/2] swap{on,off} fixes for page size > 4KB Petr Vorel @ 2024-04-25 21:10 ` Petr Vorel 2024-04-26 2:31 ` Li Wang 2024-04-25 21:10 ` [LTP] [PATCH v3 2/2] libswap: Use {SAFE_,}MAKE_MINIMAL_SWAPFILE() Petr Vorel 1 sibling, 1 reply; 6+ messages in thread From: Petr Vorel @ 2024-04-25 21:10 UTC (permalink / raw) To: ltp 65536 bytes triggered warning on systems with 64 kb page size (e.g. on aarch64 with CONFIG_ARM64_64K_PAGES=y or on ppc64le with CONFIG_PAGE_SIZE_64KB=y): TWARN: Swapfile size is less than the system page size. Using page size (65536 bytes) instead of block size (4096 bytes). 1 MB should be ok for most of the systems. Suggested-by: Cyril Hrubis <chrubis@suse.cz> Signed-off-by: Petr Vorel <pvorel@suse.cz> --- include/libswap.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/libswap.h b/include/libswap.h index 87e32328e..f757073cc 100644 --- a/include/libswap.h +++ b/include/libswap.h @@ -23,6 +23,24 @@ int make_swapfile(const char *file, const int lineno, const char *swapfile, unsigned int num, int safe, enum swapfile_method method); +/** 65536 bytes is minimum for 64kb page size, let's use 1 MB */ +#define MINIMAL_SWAP_SIZE_MB 1 + +/** + * Macro to create minimal swapfile. + */ +#define MAKE_SMALL_SWAPFILE(swapfile) \ + make_swapfile(__FILE__, __LINE__, swapfile, MINIMAL_SWAP_SIZE_MB, 0, \ + SWAPFILE_BY_SIZE) + +/** + * Macro to create minimal swapfile. + * Includes safety checks to handle potential errors. + */ +#define SAFE_MAKE_SMALL_SWAPFILE(swapfile) \ + make_swapfile(__FILE__, __LINE__, swapfile, MINIMAL_SWAP_SIZE_MB, 1, \ + SWAPFILE_BY_SIZE) + /** * Macro to create swapfile size in megabytes (MB). */ -- 2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v3 1/2] libswap: Add {SAFE_, }MAKE_SMALL_SWAPFILE() macros 2024-04-25 21:10 ` [LTP] [PATCH v3 1/2] libswap: Add {SAFE_, }MAKE_SMALL_SWAPFILE() macros Petr Vorel @ 2024-04-26 2:31 ` Li Wang 2024-04-26 4:23 ` Petr Vorel 0 siblings, 1 reply; 6+ messages in thread From: Li Wang @ 2024-04-26 2:31 UTC (permalink / raw) To: Petr Vorel; +Cc: ltp On Fri, Apr 26, 2024 at 5:26 AM Petr Vorel <pvorel@suse.cz> wrote: > 65536 bytes triggered warning on systems with 64 kb page size (e.g. on > aarch64 with CONFIG_ARM64_64K_PAGES=y or on ppc64le with > CONFIG_PAGE_SIZE_64KB=y): > > TWARN: Swapfile size is less than the system page size. Using page size > (65536 bytes) instead of block size (4096 bytes). > > 1 MB should be ok for most of the systems. > > Suggested-by: Cyril Hrubis <chrubis@suse.cz> > Signed-off-by: Petr Vorel <pvorel@suse.cz> > Reviewed-by: Li Wang <liwang@redhat.com> --- > include/libswap.h | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/include/libswap.h b/include/libswap.h > index 87e32328e..f757073cc 100644 > --- a/include/libswap.h > +++ b/include/libswap.h > @@ -23,6 +23,24 @@ int make_swapfile(const char *file, const int lineno, > const char *swapfile, unsigned int num, > int safe, enum swapfile_method method); > > +/** 65536 bytes is minimum for 64kb page size, let's use 1 MB */ > +#define MINIMAL_SWAP_SIZE_MB 1 > + > +/** > + * Macro to create minimal swapfile. > + */ > +#define MAKE_SMALL_SWAPFILE(swapfile) \ > + make_swapfile(__FILE__, __LINE__, swapfile, MINIMAL_SWAP_SIZE_MB, 0, \ > + SWAPFILE_BY_SIZE) > + > +/** > + * Macro to create minimal swapfile. > + * Includes safety checks to handle potential errors. > + */ > +#define SAFE_MAKE_SMALL_SWAPFILE(swapfile) \ > + make_swapfile(__FILE__, __LINE__, swapfile, MINIMAL_SWAP_SIZE_MB, 1, \ > + SWAPFILE_BY_SIZE) > + > /** > * Macro to create swapfile size in megabytes (MB). > */ > -- > 2.43.0 > > -- Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v3 1/2] libswap: Add {SAFE_, }MAKE_SMALL_SWAPFILE() macros 2024-04-26 2:31 ` Li Wang @ 2024-04-26 4:23 ` Petr Vorel 0 siblings, 0 replies; 6+ messages in thread From: Petr Vorel @ 2024-04-26 4:23 UTC (permalink / raw) To: Li Wang; +Cc: ltp Hi Li, all, ... > Reviewed-by: Li Wang <liwang@redhat.com> Merged, thank you for your review! > --- > > include/libswap.h | 18 ++++++++++++++++++ ... > > +/** 65536 bytes is minimum for 64kb page size, let's use 1 MB */ > > +#define MINIMAL_SWAP_SIZE_MB 1 > > + > > +/** > > + * Macro to create minimal swapfile. This could have been done better, e.g.: @swapfile: swap file name. But I kept it the same, just to fix broken test. Ands I'm going to send patch implement it. Kind regards, Petr -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH v3 2/2] libswap: Use {SAFE_,}MAKE_MINIMAL_SWAPFILE() 2024-04-25 21:10 [LTP] [PATCH v3 0/2] swap{on,off} fixes for page size > 4KB Petr Vorel 2024-04-25 21:10 ` [LTP] [PATCH v3 1/2] libswap: Add {SAFE_, }MAKE_SMALL_SWAPFILE() macros Petr Vorel @ 2024-04-25 21:10 ` Petr Vorel 2024-04-26 2:32 ` [LTP] [PATCH v3 2/2] libswap: Use {SAFE_, }MAKE_MINIMAL_SWAPFILE() Li Wang 1 sibling, 1 reply; 6+ messages in thread From: Petr Vorel @ 2024-04-25 21:10 UTC (permalink / raw) To: ltp This effectively increases the minimal used number of blocks to 256. All {SAFE_,}MAKE_SWAPFILE_SIZE() calls which were creating swap used 10 blocks. While this is ok on 4kb page size, it's too low on systems with 64kb page size (e.g. on aarch64 with CONFIG_ARM64_64K_PAGES=y or on ppc64le with CONFIG_PAGE_SIZE_64KB=y): TWARN: Swapfile size is less than the system page size. Using page size (65536 bytes) instead of block size (4096 bytes). Obviously it would fail also on kernels with CONFIG_PAGE_SIZE_256KB. Reviewed-by: Cyril Hrubis <chrubis@suse.cz> Signed-off-by: Petr Vorel <pvorel@suse.cz> --- libs/libltpswap/libswap.c | 2 +- testcases/kernel/syscalls/swapoff/swapoff02.c | 2 +- testcases/kernel/syscalls/swapon/swapon02.c | 4 ++-- testcases/kernel/syscalls/swapon/swapon03.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/libltpswap/libswap.c b/libs/libltpswap/libswap.c index aed76dfe2..eb066df71 100644 --- a/libs/libltpswap/libswap.c +++ b/libs/libltpswap/libswap.c @@ -192,7 +192,7 @@ int make_swapfile(const char *file, const int lineno, bool is_swap_supported(const char *filename) { int i, sw_support = 0; - int ret = SAFE_MAKE_SWAPFILE_BLKS(filename, 10); + int ret = SAFE_MAKE_SMALL_SWAPFILE(filename); int fi_contiguous = file_is_contiguous(filename); long fs_type = tst_fs_type(filename); const char *fstype = tst_fs_type_name(fs_type); diff --git a/testcases/kernel/syscalls/swapoff/swapoff02.c b/testcases/kernel/syscalls/swapoff/swapoff02.c index 5a15826e4..0ab8338c5 100644 --- a/testcases/kernel/syscalls/swapoff/swapoff02.c +++ b/testcases/kernel/syscalls/swapoff/swapoff02.c @@ -87,7 +87,7 @@ static void setup(void) nobody_uid = nobody->pw_uid; is_swap_supported(TEST_FILE); - SAFE_MAKE_SWAPFILE_BLKS(SWAP_FILE, 10); + SAFE_MAKE_SMALL_SWAPFILE(SWAP_FILE); } static struct tst_test test = { diff --git a/testcases/kernel/syscalls/swapon/swapon02.c b/testcases/kernel/syscalls/swapon/swapon02.c index e5e29b8e7..54796bdcc 100644 --- a/testcases/kernel/syscalls/swapon/swapon02.c +++ b/testcases/kernel/syscalls/swapon/swapon02.c @@ -50,8 +50,8 @@ static void setup(void) is_swap_supported(TEST_FILE); SAFE_TOUCH(NOTSWAP_FILE, 0777, NULL); - MAKE_SWAPFILE_BLKS(SWAP_FILE, 10); - MAKE_SWAPFILE_BLKS(USED_FILE, 10); + MAKE_SMALL_SWAPFILE(SWAP_FILE); + MAKE_SMALL_SWAPFILE(USED_FILE); if (tst_syscall(__NR_swapon, USED_FILE, 0)) tst_res(TWARN | TERRNO, "swapon(alreadyused) failed"); diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c index 5295a6a73..ecce28bdc 100644 --- a/testcases/kernel/syscalls/swapon/swapon03.c +++ b/testcases/kernel/syscalls/swapon/swapon03.c @@ -49,7 +49,7 @@ static int setup_swap(void) /* Create the swapfile */ snprintf(filename, sizeof(filename), "%s%02d", TEST_FILE, j + 2); - MAKE_SWAPFILE_BLKS(filename, 10); + MAKE_SMALL_SWAPFILE(filename); /* turn on the swap file */ TST_EXP_PASS_SILENT(swapon(filename, 0)); @@ -62,7 +62,7 @@ static int setup_swap(void) tst_brk(TFAIL, "Failed to setup swap files"); tst_res(TINFO, "Successfully created %d swap files", swapfiles); - MAKE_SWAPFILE_BLKS(TEST_FILE, 10); + MAKE_SMALL_SWAPFILE(TEST_FILE); return 0; } -- 2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v3 2/2] libswap: Use {SAFE_, }MAKE_MINIMAL_SWAPFILE() 2024-04-25 21:10 ` [LTP] [PATCH v3 2/2] libswap: Use {SAFE_,}MAKE_MINIMAL_SWAPFILE() Petr Vorel @ 2024-04-26 2:32 ` Li Wang 0 siblings, 0 replies; 6+ messages in thread From: Li Wang @ 2024-04-26 2:32 UTC (permalink / raw) To: Petr Vorel; +Cc: ltp On Fri, Apr 26, 2024 at 5:11 AM Petr Vorel <pvorel@suse.cz> wrote: > This effectively increases the minimal used number of blocks to 256. > > All {SAFE_,}MAKE_SWAPFILE_SIZE() calls which were creating swap used 10 > blocks. While this is ok on 4kb page size, it's too low on systems with > 64kb page size (e.g. on aarch64 with CONFIG_ARM64_64K_PAGES=y or on > ppc64le with CONFIG_PAGE_SIZE_64KB=y): > > TWARN: Swapfile size is less than the system page size. Using page size > (65536 bytes) instead of block size (4096 bytes). > > Obviously it would fail also on kernels with CONFIG_PAGE_SIZE_256KB. > > Reviewed-by: Cyril Hrubis <chrubis@suse.cz> > Signed-off-by: Petr Vorel <pvorel@suse.cz> > Reviewed-by: Li Wang <liwang@redhat.com> > --- > libs/libltpswap/libswap.c | 2 +- > testcases/kernel/syscalls/swapoff/swapoff02.c | 2 +- > testcases/kernel/syscalls/swapon/swapon02.c | 4 ++-- > testcases/kernel/syscalls/swapon/swapon03.c | 4 ++-- > 4 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/libs/libltpswap/libswap.c b/libs/libltpswap/libswap.c > index aed76dfe2..eb066df71 100644 > --- a/libs/libltpswap/libswap.c > +++ b/libs/libltpswap/libswap.c > @@ -192,7 +192,7 @@ int make_swapfile(const char *file, const int lineno, > bool is_swap_supported(const char *filename) > { > int i, sw_support = 0; > - int ret = SAFE_MAKE_SWAPFILE_BLKS(filename, 10); > + int ret = SAFE_MAKE_SMALL_SWAPFILE(filename); > int fi_contiguous = file_is_contiguous(filename); > long fs_type = tst_fs_type(filename); > const char *fstype = tst_fs_type_name(fs_type); > diff --git a/testcases/kernel/syscalls/swapoff/swapoff02.c > b/testcases/kernel/syscalls/swapoff/swapoff02.c > index 5a15826e4..0ab8338c5 100644 > --- a/testcases/kernel/syscalls/swapoff/swapoff02.c > +++ b/testcases/kernel/syscalls/swapoff/swapoff02.c > @@ -87,7 +87,7 @@ static void setup(void) > nobody_uid = nobody->pw_uid; > > is_swap_supported(TEST_FILE); > - SAFE_MAKE_SWAPFILE_BLKS(SWAP_FILE, 10); > + SAFE_MAKE_SMALL_SWAPFILE(SWAP_FILE); > } > > static struct tst_test test = { > diff --git a/testcases/kernel/syscalls/swapon/swapon02.c > b/testcases/kernel/syscalls/swapon/swapon02.c > index e5e29b8e7..54796bdcc 100644 > --- a/testcases/kernel/syscalls/swapon/swapon02.c > +++ b/testcases/kernel/syscalls/swapon/swapon02.c > @@ -50,8 +50,8 @@ static void setup(void) > is_swap_supported(TEST_FILE); > > SAFE_TOUCH(NOTSWAP_FILE, 0777, NULL); > - MAKE_SWAPFILE_BLKS(SWAP_FILE, 10); > - MAKE_SWAPFILE_BLKS(USED_FILE, 10); > + MAKE_SMALL_SWAPFILE(SWAP_FILE); > + MAKE_SMALL_SWAPFILE(USED_FILE); > > if (tst_syscall(__NR_swapon, USED_FILE, 0)) > tst_res(TWARN | TERRNO, "swapon(alreadyused) failed"); > diff --git a/testcases/kernel/syscalls/swapon/swapon03.c > b/testcases/kernel/syscalls/swapon/swapon03.c > index 5295a6a73..ecce28bdc 100644 > --- a/testcases/kernel/syscalls/swapon/swapon03.c > +++ b/testcases/kernel/syscalls/swapon/swapon03.c > @@ -49,7 +49,7 @@ static int setup_swap(void) > > /* Create the swapfile */ > snprintf(filename, sizeof(filename), "%s%02d", > TEST_FILE, j + 2); > - MAKE_SWAPFILE_BLKS(filename, 10); > + MAKE_SMALL_SWAPFILE(filename); > > /* turn on the swap file */ > TST_EXP_PASS_SILENT(swapon(filename, 0)); > @@ -62,7 +62,7 @@ static int setup_swap(void) > tst_brk(TFAIL, "Failed to setup swap files"); > > tst_res(TINFO, "Successfully created %d swap files", swapfiles); > - MAKE_SWAPFILE_BLKS(TEST_FILE, 10); > + MAKE_SMALL_SWAPFILE(TEST_FILE); > > return 0; > } > -- > 2.43.0 > > -- Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-04-26 4:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-25 21:10 [LTP] [PATCH v3 0/2] swap{on,off} fixes for page size > 4KB Petr Vorel
2024-04-25 21:10 ` [LTP] [PATCH v3 1/2] libswap: Add {SAFE_, }MAKE_SMALL_SWAPFILE() macros Petr Vorel
2024-04-26 2:31 ` Li Wang
2024-04-26 4:23 ` Petr Vorel
2024-04-25 21:10 ` [LTP] [PATCH v3 2/2] libswap: Use {SAFE_,}MAKE_MINIMAL_SWAPFILE() Petr Vorel
2024-04-26 2:32 ` [LTP] [PATCH v3 2/2] libswap: Use {SAFE_, }MAKE_MINIMAL_SWAPFILE() Li Wang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox