From: anthony.yznaga@oracle.com
To: "David Hildenbrand (Arm)" <david@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Cc: akpm@linux-foundation.org, ljs@kernel.org,
Liam.Howlett@oracle.com, vbabka@kernel.org, rppt@kernel.org,
surenb@google.com, mhocko@suse.com, jannh@google.com,
pfalcato@suse.de, Jason@zx2c4.com, shuah@kernel.org
Subject: Re: [PATCH 2/2] selftests/mm: verify droppable mappings cannot be locked
Date: Thu, 2 Apr 2026 16:16:12 -0700 [thread overview]
Message-ID: <f5d0a290-73ec-4ff3-b196-d58e76dca6b7@oracle.com> (raw)
In-Reply-To: <4f6d4ee8-9f2b-4da8-9456-f47cccfe4367@kernel.org>
On 4/2/26 12:28 AM, David Hildenbrand (Arm) wrote:
>> +
>> +/*
>> + * Droppable memory should not be lockable.
>> + */
>> +static void test_mlock_droppable(void)
>> +{
>> + char *map;
>> + unsigned long page_size = getpagesize();
>> +
>> + /*
>> + * Ensure MCL_FUTURE is not set.
>> + */
>> + if (mlockall(MCL_CURRENT))
>> + ksft_exit_fail_msg("mlockall(MCL_CURRENT): %s\n", strerror(errno));
> Why do we need the prior mlockall()? If that is really required, the
> comment should be clearer why the munlockall() is insufficient.
The mlockall() is not needed. Will remove.
>
> Also, why can't we fail only the test?
The tests can be failed without the exit. I'll update them.
Thanks,
Anthony
>
>> + if (munlockall())
>> + ksft_exit_fail_msg("munlockall() %s\n", strerror(errno));
> Why can't we fail only the test?
>
>> +
>> + map = mmap(NULL, 2 * page_size, PROT_READ | PROT_WRITE,
>> + MAP_ANONYMOUS | MAP_DROPPABLE, -1, 0);
>> + if (map == MAP_FAILED) {
>> + if (errno == EOPNOTSUPP) {
>> + ksft_test_result_skip("%s: MAP_DROPPABLE not supported\n", __func__);
>> + return;
>> + }
>> + ksft_exit_fail_msg("mmap error: %s\n", strerror(errno));
> same.
>
>> + }
>> +
>> + if (mlock2_(map, 2 * page_size, 0)) {
>> + munmap(map, 2 * page_size);
> Not required when exiting either way?
>
>> + ksft_exit_fail_msg("mlock2(0): %s\n", strerror(errno));
>> + }
>> +
>> + ksft_test_result(!unlock_lock_check(map, false), "%s: droppable memory not locked\n",
>> + __func__);
>> +
>> + munmap(map, 2 * page_size);
>> +}
>> +
>> +static void test_mlockall_future_droppable(void)
>> +{
>> + char *map;
>> + unsigned long page_size = getpagesize();
>> +
>> + if (mlockall(MCL_CURRENT | MCL_FUTURE))
>> + ksft_exit_fail_msg("mlockall(MCL_CURRENT | MCL_FUTURE): %s\n", strerror(errno));
> Similar comments as for the other path regarding ksft_exit_fail_msg() etc.
>
>> +
>> + map = mmap(NULL, 2 * page_size, PROT_READ | PROT_WRITE,
>> + MAP_ANONYMOUS | MAP_DROPPABLE, -1, 0);
>> +
>> + if (map == MAP_FAILED) {
>> + if (errno == EOPNOTSUPP) {
>> + ksft_test_result_skip("%s: MAP_DROPPABLE not supported\n", __func__);
>> + return;
>> + }
>> + ksft_exit_fail_msg("mmap error: %s\n", strerror(errno));
>> + }
>> +
>> + ksft_test_result(!unlock_lock_check(map, false), "%s: droppable memory not locked\n",
>> + __func__);
>> +
>> + if (munlockall()) {
>> + munmap(map, 2 * page_size);
>> + ksft_exit_fail_msg("munlockall() %s\n", strerror(errno));
>> + }
>> +
>> munmap(map, 2 * page_size);
>> }
prev parent reply other threads:[~2026-04-02 23:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 0:34 [PATCH 0/2] fix MAP_DROPPABLE not supported errno Anthony Yznaga
2026-04-02 0:34 ` [PATCH 1/2] mm: fix mmap errno value when MAP_DROPPABLE is not supported Anthony Yznaga
2026-04-02 0:44 ` Andrew Morton
2026-04-02 7:17 ` David Hildenbrand (Arm)
2026-04-02 23:13 ` anthony.yznaga
2026-04-02 0:34 ` [PATCH 2/2] selftests/mm: verify droppable mappings cannot be locked Anthony Yznaga
2026-04-02 7:28 ` David Hildenbrand (Arm)
2026-04-02 23:16 ` anthony.yznaga [this message]
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=f5d0a290-73ec-4ff3-b196-d58e76dca6b7@oracle.com \
--to=anthony.yznaga@oracle.com \
--cc=Jason@zx2c4.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=jannh@google.com \
--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=pfalcato@suse.de \
--cc=rppt@kernel.org \
--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