On 10/16/26 7:37 PM, Gregory Price wrote:
> On Fri, Oct 16, 2026 at 09:22:54AM -0400, Gregory Price wrote:
>> On Fri, Oct 16, 2026 at 05:47:57PM +0530, Sarthak Sharma wrote:
>>>> +/*
>>>> + * An unmapped gap in the range makes either hint fail with ENOMEM, after
>>>> + * advising the mapped pages on both sides of the gap. Only MADV_PAGEOUT 
>>>> has
>>>> + * an effect on those pages that the test can observe.
>>>> + */
>>>> +TEST_F(madvise, unmapped_gap_fails_after_advising)
>>>> +{
>>>> +  char *mapping, *control;
>>>> +  bool swapped = false;
>>>> +  int retry;
>>>> +
>>>> +  pin_to_current_cpu(_metadata);
>>>> +
>>>> +  /* Make sure MADV_PAGEOUT can swap at all before relying on it. */
>>>> +  control = mmap(NULL, page_size, PROT_READ | PROT_WRITE,
>>>> +                 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>>>> +  ASSERT_NE(control, MAP_FAILED);
>>>> +  control[0] = 1;
>>>> +  if (!pageout_until_swapped(_metadata, control, page_size,
>>>> +                             self->pagemap_fd))
>>>> +          SKIP(return, "MADV_PAGEOUT did not swap the page");
>>>
>>> This test is checking for both MADV_COLD and MADV_PAGEOUT. So if we skip
>>> here because we couldn't pageout, then we don't test for MADV_COLD
>>> behaviour at all. Do we want it this way, or should the tests for both
>>> of these be separate?
>>>
>>
>> If swap is off, the behavior of COLD and PAGEOUT look pretty much the
>> same, and we can't actually test them meaningfully.
>>
>> We check that madvise(COLD) returns -1, but that's also largely
>> meaningless if this initial pageout_until_swapped() call fails.
>>
>> At least that's my thought.  If you think I should split it, I can.
>>
> 
> on second look, i will just move the cold checks above the rest, since
> they're mostly checking failure paths.  those are mostly unchanging
> regardless of swap status.
> 
> so basically no need to split, just a mild reorder.

Yes that would cover MADV_COLD testing even when we can't swap.

Just thinking out here. Say if MADV_COLD fails, do we lose out on
MADV_PAGEOUT coverage in that case? Or is it meaningless to test for
pageout if MADV_COLD fails?

Also, say MADV_COLD passes, but we can't swap, then the test will report
a SKIP. We know that if it reaches a skip, then MADV_COLD must have
passed, but the ksft counters won't report that. So I would still prefer
separate tests from a test reporting POV, but I don't insist strongly,
it's upto you :)

> 
> ~Gregory


Reply via email to