linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: wang lian <lianux.mm@gmail.com>
To: broonie@kernel.org
Cc: Liam.Howlett@oracle.com, akpm@linux-foundation.org,
	brauner@kernel.org, david@redhat.com, gkwang@linx-info.com,
	jannh@google.com, lianux.mm@gmail.com,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-mm@kvack.org, lorenzo.stoakes@oracle.com,
	p1ucky0923@gmail.com, ryncsn@gmail.com, shuah@kernel.org,
	sj@kernel.org, vbabka@suse.cz, zijing.zhang@proton.me,
	ziy@nvidia.com
Subject: Re: [PATCH v5] selftests/mm: add process_madvise() tests
Date: Tue, 15 Jul 2025 18:58:05 +0800	[thread overview]
Message-ID: <20250715105808.3634-1-lianux.mm@gmail.com> (raw)
In-Reply-To: <b01d1d06-9d7c-4081-b3e3-c2c0fea06fad@sirena.org.uk>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=yes, Size: 1852 bytes --]

> On Mon, Jul 14, 2025 at 08:25:33PM +0800, wang lian wrote:
> > +TEST_F(process_madvise, remote_collapse)
> > +{
> > +	self->child_pid = fork();
> > +	ASSERT_NE(self->child_pid, -1);
> > +
> > +	ret = read(pipe_info[0], &info, sizeof(info));
> > +	if (ret <= 0) {
> > +		waitpid(self->child_pid, NULL, 0);
> > +		SKIP(return, "Failed to read child info from pipe.\n");
> > +	}
> > +	ASSERT_EQ(ret, sizeof(info));
> > +
> > +cleanup:
> > +	/* Cleanup */
> > +	kill(self->child_pid, SIGKILL);
> > +	waitpid(self->child_pid, NULL, 0);
> > +	if (pidfd >= 0)
> > +		close(pidfd);

> The cleanup here won't get run if we skip or assert, skipping will
> return immediately (you could replace the return with a 'goto cleanup')
> and the asserts will exit the test immediately.  This will mean we leak
> the child.  This isn't an issue for things that are memory mapped or
> tracked with file descriptors, the harness will for a new child for each
> test so anything that's cleaned up with the process will be handled, but
> that doesn't apply to child processes.

> I think doing the child setup in a fixture should DTRT but I haven't
> gone through in full detail to verify that this is the case.

Thanks a lot for pointing this out — it's a very reasonable concern.

Fortunately, this situation is handled by FIXTURE_TEARDOWN_PARENT, 
which reliably takes care of cleanup when the test exits early via ASSERT_* or SKIP(). 

During earlier testing (in v3), I did run into an issue where a missing cleanup 
led to run_vmtests hanging,which prompted me to make sure that subsequent versions 
correctly rely on the fixture teardown mechanism for child process termination.

So while your concern definitely makes sense, this specific case should be 
well-covered by the existing teardown logic.

Thanks again for the careful review!

Best regards,
wang lian


  reply	other threads:[~2025-07-15 10:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-14 12:25 wang lian
2025-07-14 13:28 ` Mark Brown
2025-07-15 10:58   ` wang lian [this message]
2025-07-15 12:12     ` Mark Brown
2025-07-16 11:13       ` wang lian

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=20250715105808.3634-1-lianux.mm@gmail.com \
    --to=lianux.mm@gmail.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=broonie@kernel.org \
    --cc=david@redhat.com \
    --cc=gkwang@linx-info.com \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=p1ucky0923@gmail.com \
    --cc=ryncsn@gmail.com \
    --cc=shuah@kernel.org \
    --cc=sj@kernel.org \
    --cc=vbabka@suse.cz \
    --cc=zijing.zhang@proton.me \
    --cc=ziy@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox