[LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Petr Vorel
pvorel@suse.cz
Tue Mar 19 20:24:22 CET 2024
> On Tue, Mar 19, 2024 at 1:43 PM Li Wang <liwang@redhat.com> wrote:
> > On Tue, Mar 19, 2024 at 1:04 PM Petr Vorel <pvorel@suse.cz> wrote:
> >> > On Mon, Mar 18, 2024 at 8:40 PM Wei Gao <wegao@suse.com> wrote:
> >> > > > That's because the available swapfile on your SUT is too small,
> >> > > > you can adjust it (then retest it) by yourself to find a proper
> >> size.
> >> > > > This is fine as long as the swapfile size is less than 300MB,
> >> > > > otherwise we need to set .dev_min_size like what we did
> >> > > > for swapoff01.c.
> >> > > > And, on the other side, we can't guarantee the system SwapCached
> >> > > > happened every time, it depends on the system's configuration.
> >> > > 100M is good enough for current system, could you help check following
> >> > > patch?
> >> > Can we rewrite the make_swapfile() API to support passing MB size for
> >> > making the swapfile?
> >> I guess it would be desirable (but keep also possible to pass that 10
> >> blocks,
> >> therefore maybe use flag to distinguish between MB and blocks?).
> > That's fine but a bit complex for users to distinguish flags.
> > Or, what about making the function use the flag as static, and
> > export two additional functions with MB and blocks?
> > enum swapfile_method {
> > SWAPFILE_BY_SIZE,
> > SWAPFILE_BY_BLOCKS
> > };
> > static int make_swapfile(const char *swapfile, unsigned int para, int
> > safe, enum swapfile_method method) {
> > // The main logic to achieve the swapfile-making process
> > // ...
> > }
> > int make_swapfile_size(const char *swapfile, unsigned int size, int safe) {
> > return make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE);
> > }
> > int make_swapfile_blks(const char *swapfile, unsigned int blocks, int
> > safe) {
> > return make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS);
> > }
> Even simpler to define two macros with one make_swapfile():
> #define MAKE_SWAPFILE_SIZE(swapfile, size, safe) \
> make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE)
> #define MAKE_SWAPFILE_BLKS(swapfile, blocks, safe) \
> make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS)
+1
Kind regards,
Petr
More information about the ltp
mailing list