From: Pratyush Yadav <pratyush@kernel.org>
To: Usama Arif <usama.arif@linux.dev>
Cc: Pratyush Yadav <pratyush@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Mike Rapoport <rppt@kernel.org>, Shuah Khan <shuah@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH 1/6] selftests/liveupdate: add framework for memfd tests
Date: Fri, 13 Mar 2026 10:05:53 +0000 [thread overview]
Message-ID: <2vxzldfwf3i6.fsf@kernel.org> (raw)
In-Reply-To: <20260310110847.3519998-1-usama.arif@linux.dev> (Usama Arif's message of "Tue, 10 Mar 2026 04:08:45 -0700")
On Tue, Mar 10 2026, Usama Arif wrote:
> On Mon, 9 Mar 2026 11:54:34 +0000 Pratyush Yadav <pratyush@kernel.org> wrote:
[...]
>> diff --git a/tools/testing/selftests/liveupdate/luo_memfd.c b/tools/testing/selftests/liveupdate/luo_memfd.c
>> new file mode 100644
>> index 000000000000..b779eee18387
>> --- /dev/null
>> +++ b/tools/testing/selftests/liveupdate/luo_memfd.c
>> @@ -0,0 +1,77 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +
>> +/*
>> + * Copyright (c) 2026, Google LLC.
>> + * Pratyush Yadav (Google) <pratyush@kernel.org>
>> + */
>> +
>> +/*
>> + * Selftests for memfd preservation via LUO.
>> + */
>> +
>> +#include <errno.h>
>> +#include <fcntl.h>
>> +#include <string.h>
>> +#include <sys/ioctl.h>
>> +#include <unistd.h>
>> +
>> +#include <linux/liveupdate.h>
>> +
>> +#include "../kselftest.h"
>> +#include "../kselftest_harness.h"
>> +
>> +#include "luo_test_utils.h"
>> +
>> +#define STATE_SESSION_NAME "luo-state"
>> +#define STATE_MEMFD_TOKEN 1
>> +
>> +#define LIVEUPDATE_DEV "/dev/liveupdate"
>
> Hello!
>
> LIVEUPDATE_DEV doesn't seem to be used anywhere?
Right. This is a leftover from development. Will drop.
>
>> +static int luo_fd = -1, stage;
>> +
>> +int main(int argc, char *argv[])
>> +{
>> + int session, expected_stage = 0;
>> +
>> + /*
>> + * The test takes an optional --stage argument. This lets callers
>> + * provide the expected stage, and if that doesn't match the test errors
>> + * out.
>> + *
>> + * Look for the stage. Since test_harness_run() doesn't recognize it,
>> + * once found, remove it from argv.
>> + */
>> + for (int i = 1; i < argc; i++) {
>> + if (strcmp(argv[i], "--stage") == 0) {
>> + if (i + 1 < argc) {
>> + expected_stage = atoi(argv[i + 1]);
>> + memmove(&argv[i], &argv[i + 2], (argc - i - 1) * sizeof(char *));
>> + argc -= 2;
>> + i--;
>> + } else {
>> + ksft_exit_fail_msg("Option --stage requires an argument\n");
>> + }
>> + }
>> + }
>> +
>> + luo_fd = luo_open_device();
>> + if (luo_fd < 0)
>> + ksft_exit_skip("Failed to open %s (%s). Is the luo module loaded?\n",
>> + strerror(errno), LUO_DEVICE);
>
> Need to reverse strerror(errno) and LUO_DEVICE?
Will fix. Thanks.
>
>> +
>> + session = luo_retrieve_session(luo_fd, STATE_SESSION_NAME);
>> + if (session == -ENOENT)
>> + stage = 1;
>> + else if (session >= 0)
>> + stage = 2;
>> + else
>> + fail_exit("Failed to check for state session");
>> +
>> + if (expected_stage && expected_stage != stage)
>> + ksft_exit_fail_msg("Stage mismatch: expected %d, got %d\n",
>> + expected_stage, stage);
>> +
>> + if (stage == 1)
>> + create_state_file(luo_fd, STATE_SESSION_NAME, STATE_MEMFD_TOKEN, 2);
>> +
>> + test_harness_run(argc, argv);
>> +}
>> --
>> 2.53.0.473.g4a7958ca14-goog
>>
>>
--
Regards,
Pratyush Yadav
next prev parent reply other threads:[~2026-03-13 10:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 11:54 [PATCH 0/6] selftests/liveupdate: add memfd tests Pratyush Yadav
2026-03-09 11:54 ` [PATCH 1/6] selftests/liveupdate: add framework for " Pratyush Yadav
2026-03-10 11:08 ` Usama Arif
2026-03-13 10:05 ` Pratyush Yadav [this message]
2026-03-18 7:15 ` Mike Rapoport
2026-03-09 11:54 ` [PATCH 2/6] selftests/liveupdate: add helper functions " Pratyush Yadav
2026-03-17 11:01 ` Mike Rapoport
2026-03-17 12:21 ` Pratyush Yadav
2026-03-18 7:20 ` Mike Rapoport
2026-03-09 11:54 ` [PATCH 3/6] selftests/liveupdate: add test for memfd content preservation Pratyush Yadav
2026-03-18 7:31 ` Mike Rapoport
2026-03-09 11:54 ` [PATCH 4/6] selftests/liveupdate: add test for zero-size memfd preservation Pratyush Yadav
2026-03-18 7:35 ` Mike Rapoport
2026-03-09 11:54 ` [PATCH 5/6] selftests/liveupdate: add test for operations on a preserved memfd Pratyush Yadav
2026-03-18 7:38 ` Mike Rapoport
2026-03-09 11:54 ` [PATCH 6/6] selftests/liveupdate: add fallocate test for memfd Pratyush Yadav
2026-03-18 7:43 ` Mike Rapoport
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=2vxzldfwf3i6.fsf@kernel.org \
--to=pratyush@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=usama.arif@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.