All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Pratyush Yadav <pratyush@kernel.org>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>,
	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 4/6] selftests/liveupdate: add test for zero-size memfd preservation
Date: Wed, 18 Mar 2026 09:35:08 +0200	[thread overview]
Message-ID: <abpVrFwp9h6lqfhm@kernel.org> (raw)
In-Reply-To: <20260309115441.266805-5-pratyush@kernel.org>

On Mon, Mar 09, 2026 at 11:54:37AM +0000, Pratyush Yadav wrote:
> From: "Pratyush Yadav (Google)" <pratyush@kernel.org>
> 
> A zero-size memfd is a special case of memfd preservation. It takes a
> different path from normal both during preservation and during restore.
> In the serialization structure, the number of folios if zero and the

                                                       ^ typo: is

> vmalloc array with folios is empty. The restore logic should check for
> this and make sure to not touch the invalid array.
> 
> Add a test to make sure this path works as expected. In stage 1, the
> test creates and preserves a memfd without any data. In stage 2, the
> test retrieves the memfd and makes sure it is still without data.
> 
> Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org>
> ---
>  .../testing/selftests/liveupdate/luo_memfd.c  | 47 +++++++++++++++++++
>  1 file changed, 47 insertions(+)
> 
> diff --git a/tools/testing/selftests/liveupdate/luo_memfd.c b/tools/testing/selftests/liveupdate/luo_memfd.c
> index 52b5f6b16e19..56106cd09978 100644
> --- a/tools/testing/selftests/liveupdate/luo_memfd.c
> +++ b/tools/testing/selftests/liveupdate/luo_memfd.c
> @@ -36,6 +36,9 @@
>  #define MEMFD_DATA_BUFFER_SIZE SZ_1M
>  #define RANDOM_DATA_FILE "luo_random_data.bin"
>  
> +#define ZERO_SESSION_NAME "zero_session"
> +#define ZERO_MEMFD_TOKEN 1
> +
>  #define LIVEUPDATE_DEV "/dev/liveupdate"
>  static int luo_fd = -1, stage;
>  
> @@ -89,6 +92,50 @@ TEST(memfd_data)
>  	}
>  }
>  
> +/*
> + * Test that a zero-sized memfd is preserved across live update.
> + */
> +TEST(zero_memfd)
> +{
> +	int zero_fd, session;
> +	struct liveupdate_session_preserve_fd preserve_arg = { .size = sizeof(preserve_arg) };
> +	struct liveupdate_session_retrieve_fd retrieve_arg = { .size = sizeof(retrieve_arg) };
> +
> +	switch (stage) {
> +	case 1:

Helper functions?  And in other tests that do save and restore too?

Otherwise

Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>


> +		session = luo_create_session(luo_fd, ZERO_SESSION_NAME);
> +		ASSERT_GE(session, 0);
> +

-- 
Sincerely yours,
Mike.

  reply	other threads:[~2026-03-18  7:35 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
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 [this message]
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=abpVrFwp9h6lqfhm@kernel.org \
    --to=rppt@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=pratyush@kernel.org \
    --cc=shuah@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 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.