Message ID | 20240425211042.299714-2-pvorel@suse.cz |
---|---|
State | Accepted |
Headers | show |
Series | swap{on,off} fixes for page size > 4KB | expand |
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 > >
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
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). */
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(+)