From: Gregory Price <gourry@gourry.net>
To: Sarthak Sharma <sarthak.sharma@arm.com>
Cc: linux-kselftest@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, kernel-team@meta.com,
akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org,
liam@infradead.org, vbabka@kernel.org, rppt@kernel.org,
surenb@google.com, mhocko@suse.com, shuah@kernel.org
Subject: Re: [PATCH 7/8] selftests/mm: check MADV_PAGEOUT file permissions
Date: Fri, 16 Oct 2026 09:48:40 -0400 [thread overview]
Message-ID: <atImwW1ONQQ9Hv7p@gourry-fedora-PF4VCD3F> (raw)
In-Reply-To: <cba2a01d-630c-42d3-b6e4-b498f10c4b45@arm.com>
On Fri, Oct 16, 2026 at 05:48:11PM +0530, Sarthak Sharma wrote:
> > +/*
> > + * The owner of a file may page out its clean page-cache pages. Run as an
> > + * unprivileged owner, so that capabilities cannot stand in for ownership.
> > + */
> > +TEST_F(madvise, pageout_evicts_owned_file_page)
> > +{
> > + char *mapping, *control;
> > +
> > + if (!geteuid() && !drop_privileges())
> > + SKIP(return, "could not drop privileges");
> > + pin_to_current_cpu(_metadata);
>
> Is there a reason why we are pinning to the current CPU here and not in
> the next two tests?
Oversight on my part. I added it where i got a failure, but didn't
carry it forward to the other tests.
> > + ASSERT_EQ(mapping[0], 0);
> > + ASSERT_EQ(mapping[page_size], 0);
> > + mapping[0] = 1;
>
> If both pages are on CPU 1's per CPU LRU batch here and then hte task
> migrates to CPU 2 here
>
> > +
> > + ASSERT_EQ(madvise(mapping, 2 * page_size, MADV_PAGEOUT), 0);
>
> Then this can cause lru_add_drain() on CPU 2, and therefore both pages
> do not reach the main LRU list. Thus they won't be reclaimed and the
> test can skip here since the CoW page wasn't swapped.
I think there are other corner cases here as well. So yes i'll set up
thei pinning - probably worth it to just pin the entire suite of tests.
My original set had a bunch of this tested more explicitly, but this is
really implementation details that are not worth the additional test
complexity. I think we can just rid ourselves of that and just pin
every test and make sure it does what we expect in that case.
>
> > + ASSERT_TRUE(pagemap_is_populated(self->pagemap_fd,
> > + mapping + page_size));
> > + swapped = pagemap_is_swapped(self->pagemap_fd, mapping);
> > + ASSERT_EQ(mapping[0], 1);
> > + ASSERT_EQ(mapping[page_size], 0);
> > + if (!swapped)
> > + SKIP(return, "MADV_PAGEOUT did not swap the COW page");
>
> Also, here we skip if we couldn't swap out the CoW page. Won't it make
> more sense to check with pageout_until_swapped() first if pages can be
> skipped, and then fail here if the CoW page wasn't skipped after all the
> retries, similar to how some other tests implement it?
>
Ah yeah good catch. I'll adjust like this:
/* Ensure pageout-swap actually works first with a control page */
control[0] = 1;
if (!pageout_until_swapped(_metadata, control, page_size,
self->pagemap_fd))
SKIP(return, "MADV_PAGEOUT did not swap the control page");
/* Run the actual test */
ASSERT_EQ(mapping[0], 0);
ASSERT_EQ(mapping[page_size], 0);
mapping[0] = 1;
ASSERT_TRUE(pageout_until_swapped(_metadata, mapping, 2 * page_size,
self->pagemap_fd));
ASSERT_TRUE(pagemap_is_populated(self->pagemap_fd,
mapping + page_size));
ASSERT_EQ(mapping[0], 1);
ASSERT_EQ(mapping[page_size], 0);
~Gregory
next prev parent reply other threads:[~2026-10-16 13:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 17:57 [PATCH 0/8] selftests/mm: add MADV_COLD and MADV_PAGEOUT contract tests Gregory Price (Meta)
2026-10-14 17:57 ` [PATCH 1/8] " Gregory Price (Meta)
2026-10-14 17:57 ` [PATCH 2/8] selftests/mm: check that MADV_PAGEOUT skips holes and swapped pages Gregory Price (Meta)
2026-10-14 17:57 ` [PATCH 3/8] selftests/mm: check MADV_COLD and MADV_PAGEOUT range handling Gregory Price (Meta)
2026-10-14 21:31 ` [PATCH] fixup! " Gregory Price (Meta)
2026-10-16 12:17 ` [PATCH 3/8] " Sarthak Sharma
2026-10-16 13:22 ` Gregory Price
2026-10-16 14:07 ` Gregory Price
2026-10-14 17:57 ` [PATCH 4/8] selftests/mm: check that MADV_COLD and MADV_PAGEOUT reject hugetlb Gregory Price (Meta)
2026-10-14 17:57 ` [PATCH 5/8] selftests/mm: check that MADV_COLD and MADV_PAGEOUT preserve shared memory Gregory Price (Meta)
2026-10-14 17:57 ` [PATCH 6/8] selftests/mm: check MADV_COLD and MADV_PAGEOUT on partly advised THPs Gregory Price (Meta)
2026-10-14 17:57 ` [PATCH 7/8] selftests/mm: check MADV_PAGEOUT file permissions Gregory Price (Meta)
2026-10-16 12:18 ` Sarthak Sharma
2026-10-16 13:48 ` Gregory Price [this message]
2026-10-14 17:57 ` [PATCH 8/8] selftests/mm: check that unauthorized MADV_PAGEOUT skips large file folios Gregory Price (Meta)
2026-10-14 21:26 ` Gregory Price
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=atImwW1ONQQ9Hv7p@gourry-fedora-PF4VCD3F \
--to=gourry@gourry.net \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=kernel-team@meta.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=sarthak.sharma@arm.com \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
/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
all inboxes | Powered by JetHome®