All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: Michal Hocko <mhocko@suse.com>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 3/5] swapon03: Try to swapon() as many files until it fails
Date: Tue, 11 Nov 2025 16:58:48 +0100	[thread overview]
Message-ID: <20251111155848.GC61698@pevik> (raw)
In-Reply-To: <aRM09edcL-6OyfPk@yuki.lan>

Hi Cyril,

> Hi!
> >  	is_swap_supported(TEST_FILE);
> > +
> > +	swapfiles = SAFE_MMAP(NULL, sizeof(*swapfiles), PROT_READ | PROT_WRITE,
> > +			MAP_SHARED | MAP_ANONYMOUS, -1, 0);
> > +	*swapfiles = 0;
> > +
> >  	setup_swap();
> >  }

> >  static void cleanup(void)
> >  {
> > -	clean_swap();
> > +	if (swapfiles) {
> > +		clean_swap();
> > +		SAFE_MUNMAP(swapfiles, sizeof(*swapfiles));
> > +	}
> >  }

First, thank you for your review!

> This gets complicated for no good reason since we run the setup code in the
> child.

If swapfiles is not mapped for some reason (can happen or "*swapfiles = 0" is
not run (that should not happen), then using *swapfiles leads to segfault.

*swapfiles is being used not only in SAFE_MUNMAP() here in cleanup(), but
also in clean_swap().

Also, this saves trying to deactivate swap files if they weren't activated.

And, unless "swapon03: Remove grep dependency" (the last commit) is accepted,
there is a corner case I found during debugging:

# ./swapon03 # quit early with ctrl+C => some swap partitions are left not being swapped off
...
Sending SIGKILL to test process...
tst_test.c:1909: TINFO: Killed the leftover descendant processes
tst_test.c:1918: TINFO: If you are running on slow machine, try exporting LTP_TIMEOUT_MUL > 1
tst_test.c:1920: TBROK: Test killed! (timeout?)

Summary:
passed   0
failed   0
broken   1
skipped  0
warnings 0
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try  1...
tst_device.c:421: TINFO: Likely gvfsd-trash is probing newly mounted fs, kill it to speed up tests.
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try  2...
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try  3...
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try  4...
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try  5...
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try  6...
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try  7...
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try  8...
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try  9...
tst_device.c:417: TINFO: umount('mntpoint') failed with EBUSY, try 10...

Then following run tries to swapoff() partition left from previous run.

# ./swapon03
...
swapon03.c:80: TWARN: Failed to swapoff mntpoint/testswap

But the last commit fixes this problem.

Kind regards,
Petr

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

  reply	other threads:[~2025-11-11 15:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-06 16:34 [LTP] [PATCH v2 0/5] swapon03: Try to swapon() as many files until it fails Petr Vorel
2025-11-06 16:34 ` [LTP] [PATCH v2 1/5] swapon03: Don't create swap file twice Petr Vorel
2025-11-11 12:52   ` Cyril Hrubis
2025-11-11 15:24     ` Petr Vorel
2025-11-06 16:34 ` [LTP] [PATCH v2 2/5] swapon03: Cleanup Petr Vorel
2025-11-11 13:04   ` Cyril Hrubis
2025-11-11 15:47     ` Petr Vorel
2025-11-06 16:34 ` [LTP] [PATCH v2 3/5] swapon03: Try to swapon() as many files until it fails Petr Vorel
2025-11-07  3:15   ` Li Wang via ltp
2025-11-11 13:07   ` Cyril Hrubis
2025-11-11 15:58     ` Petr Vorel [this message]
2025-11-11 16:03       ` Petr Vorel
2025-11-06 16:34 ` [LTP] [PATCH v2 4/5] libswap: Remove now unused tst_max_swapfiles() Petr Vorel
2025-11-06 16:35 ` [LTP] [PATCH v2 5/5] swapon03: Remove grep dependency Petr Vorel
2025-11-07 16:27   ` Avinesh Kumar
2025-11-14 10:24     ` Petr Vorel
2025-11-14 10:27       ` Cyril Hrubis
2025-11-14 12:09         ` Petr Vorel
2025-11-14 14:38           ` Cyril Hrubis
2025-11-18 12:41             ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251111155848.GC61698@pevik \
    --to=pvorel@suse.cz \
    --cc=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=mhocko@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.