Re: [PATCH] selftests/mm: Specify requirement for PROC_MEM_ALWAYS_FORCE=y

Mike Rapoport
2026-04-17T12:41:51Z

On Fri, Apr 17, 2026 at 08:26:36AM +0530, Anshuman Khandual wrote:
> On 17/04/26 12:58 AM, Mike Rapoport wrote:
> > On Thu, Apr 16, 2026 at 08:10:53PM +0100, Mark Brown wrote:
> >> On Thu, Apr 16, 2026 at 09:05:11PM +0200, David Hildenbrand (Arm) wrote:
> >>> On 4/16/26 20:40, Mark Brown wrote:
> >>
> >>>> Several of the mm selftests made use of /proc/pid/mem as part of their
> >>>> operation but we do not specify this in the config fragment for them, at
> >>>> least mkdirty and ksm_functional_tests have this requirement.
> >>
> >>> I guess we could teach most tests to SKIP if /proc/pid/mem is unusable.
> >>
> >> That would be nicer, yes. I imagine some of these will predate there
> >> being a configuration option here at all, it's possible there's newer
> >> tests that skip cleanly - I didn't look at the skips.
> >
> > Enabling access to /proc/pid/mem keeps the coverage, not that it's great
> > right now, but still.
> >
> > + mem_fd = open("/proc/self/mem", O_RDWR);
> > + if (mem_fd < 0) {
> > + ksft_test_result_skip("opening /proc/self/mem failed\n");
> > + return;
> > + }
> > +
>
> Change LGTM making these tests skip rather gracefully.

Yeah, the issue though is that open() succeeds regardless of PROC_MEM_
setting in Kconfig. With restricted /proc/pid/mem the failure happens in
write(), and there we don't know what actually went wrong.

We can try checking errno, but it's fragile and it's better to fail the
test if write() failed IMO.

--
Sincerely yours,
Mike.