Skip to content

selftests/liveupdate: add memfd tests

Pratyush Yadav linux-kselftest linux-mm lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest6 patches 8 repliesIn review
  2. v26 patches 3 repliesSuperseded
  3. v16 patches 10 repliesSuperseded

Changes in v3 from the cover letter

- Retry on EINTR instead of giving up in read_size() and write_size().
- Use O_TRUNC in save_test_data().
- Return the value of write_size() directly in create_random_memfd(). No need to check errno since write_size() already returns -errno.
- Save errno before calling close() in create_random_memfd() to avoid overwriting the value.
- Use memcmp() instead of open-coding the comparison loop.
- Return value of test_harness_run() from main().

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6selftests/liveupdate: add framework for memfd teststools/testing/selftests/liveupdate/Makefile tools/testing/selftests/liveupdate/luo_memfd.c+79 -00 replies
2/6selftests/liveupdate: add helper functions for memfd teststools/testing/selftests/liveupdate/luo_test_utils.c tools/testing/selftests/liveupdate/luo_test_utils.h+200 -14 replies
3/6selftests/liveupdate: add test for memfd content preservationtools/testing/selftests/liveupdate/Makefile tools/testing/selftests/liveupdate/luo_memfd.c+81 -00 replies
4/6selftests/liveupdate: add test for zero-size memfd preservationtools/testing/selftests/liveupdate/luo_memfd.c+57 -00 replies
5/6selftests/liveupdate: add test for operations on a preserved memfdtools/testing/selftests/liveupdate/luo_memfd.c+57 -00 replies
6/6selftests/liveupdate: add fallocate test for memfdtools/testing/selftests/liveupdate/luo_memfd.c+83 -00 replies

Reviews trailers per patch

5 of 6 patches have a Reviewed-by or Acked-by.

PatchMike Rapoport (Microsoft)
1/6R-b
2/6R-b
3/6
4/6R-b
5/6R-b
6/6R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/6] selftests/liveupdate: add memfd tests

From: "Pratyush Yadav (Google)" <[email protected]>

Hi,

This series adds some tests for memfd preservation across a live update. Currently memfd is only tested indirectly via luo_kexec_simple or luo_multi_session. Add a dedicated test suite for it.

Patches 1 and 2 are preparatory, adding base framework and helpers, and the other patches each add a test. Some of the code is taken from the libluo patches [0] I sent a while ago.

[0] https://lore.kernel.org/linux-mm/[email protected]/

Changes in v3:
- Retry on EINTR instead of giving up in read_size() and write_size().
- Use O_TRUNC in save_test_data().
- Return the value of write_size() directly in create_random_memfd(). No need to check errno since write_size() already returns -errno.
- Save errno before calling close() in create_random_memfd() to avoid overwriting the value.
- Use memcmp() instead of open-coding the comparison loop.
- Return value of test_harness_run() from main().

Changes in v2:
- Drop LIVEUPDATE_DEV since it isn't used.
- Split luo_fd and stage declaration on separate lines.
- Split all 2-stage tests into helper function for each test.
- Fix wording and argument order when LUO_DEVICE fails to open.
- Rename verify_fd_content() to verify_fd_content_read().
- Advance buffer pointer in {read,write}_size().
- Add a check to make sure current working directory is not on a tmpfs mount. If so, skip the tests since saved data files will be lost.
- Rename RANDOM_DATA_FILE and RANDOM_DATA_FILE_FALLOCATE to MEMFD_DATA_FS_COPY and FALLOCATE_DATA_FS_COPY respectively. Also update the file names to reflect this naming convention.
- Collect R-bys.

Regards,
Pratyush Yadav

Pratyush Yadav (Google) (6):
selftests/liveupdate: add framework for memfd tests selftests/liveupdate: add helper functions for memfd tests selftests/liveupdate: add test for memfd content preservation selftests/liveupdate: add test for zero-size memfd preservation selftests/liveupdate: add test for operations on a preserved memfd selftests/liveupdate: add fallocate test for memfd

 tools/testing/selftests/liveupdate/Makefile   |   2 +
 .../testing/selftests/liveupdate/luo_memfd.c  | 355 ++++++++++++++++++
 .../selftests/liveupdate/luo_test_utils.c     | 191 +++++++++-
 .../selftests/liveupdate/luo_test_utils.h     |  10 +
 4 files changed, 557 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/liveupdate/luo_memfd.c

base-commit: 98ddd87f9704ef2fc837ec2ca38877c364d8dada

Signature · 1 line
2.53.0.1213.gd9a14994de-goog