linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jiaqi Yan <jiaqiyan@google.com>
To: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: nao.horiguchi@gmail.com, linmiaohe@huawei.com,
	jane.chu@oracle.com,  osalvador@suse.de, muchun.song@linux.dev,
	akpm@linux-foundation.org,  shuah@kernel.org, corbet@lwn.net,
	rientjes@google.com, duenwen@google.com,  fvdl@google.com,
	linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	 linux-doc@vger.kernel.org
Subject: Re: [PATCH v4 3/4] selftest/mm: test enable_soft_offline behaviors
Date: Fri, 21 Jun 2024 07:43:19 -0700	[thread overview]
Message-ID: <CACw3F5229yVkVTjwYCTDF73evvbvEO0=K9wTvFQN+xbNqp0zSQ@mail.gmail.com> (raw)
In-Reply-To: <1591a354-d999-45b4-aff2-357fa7612634@collabora.com>

On Thu, Jun 20, 2024 at 10:08 PM Muhammad Usama Anjum
<usama.anjum@collabora.com> wrote:
>
> On 6/20/24 11:48 PM, Jiaqi Yan wrote:
> > Add regression and new tests when hugepage has correctable memory
> > errors, and how userspace wants to deal with it:
> > * if enable_soft_offline=1, mapped hugepage is soft offlined
> > * if enable_soft_offline=0, mapped hugepage is intact
> >
> > Free hugepages case is not explicitly covered by the tests.
> >
> > Hugepage having corrected memory errors is emulated with
> > MADV_SOFT_OFFLINE.
> >
> > Signed-off-by: Jiaqi Yan <jiaqiyan@google.com>
> > ---
> >  tools/testing/selftests/mm/.gitignore         |   1 +
> >  tools/testing/selftests/mm/Makefile           |   1 +
> >  .../selftests/mm/hugetlb-soft-offline.c       | 229 ++++++++++++++++++
> >  tools/testing/selftests/mm/run_vmtests.sh     |   4 +
> >  4 files changed, 235 insertions(+)
> >  create mode 100644 tools/testing/selftests/mm/hugetlb-soft-offline.c
> >
> > diff --git a/tools/testing/selftests/mm/.gitignore b/tools/testing/selftests/mm/.gitignore
> > index 0b9ab987601c..064e7b125643 100644
> > --- a/tools/testing/selftests/mm/.gitignore
> > +++ b/tools/testing/selftests/mm/.gitignore
> > @@ -6,6 +6,7 @@ hugepage-shm
> >  hugepage-vmemmap
> >  hugetlb-madvise
> >  hugetlb-read-hwpoison
> > +hugetlb-soft-offline
> >  khugepaged
> >  map_hugetlb
> >  map_populate
> > diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
> > index 3b49bc3d0a3b..d166067d75ef 100644
> > --- a/tools/testing/selftests/mm/Makefile
> > +++ b/tools/testing/selftests/mm/Makefile
> > @@ -42,6 +42,7 @@ TEST_GEN_FILES += gup_test
> >  TEST_GEN_FILES += hmm-tests
> >  TEST_GEN_FILES += hugetlb-madvise
> >  TEST_GEN_FILES += hugetlb-read-hwpoison
> > +TEST_GEN_FILES += hugetlb-soft-offline
> >  TEST_GEN_FILES += hugepage-mmap
> >  TEST_GEN_FILES += hugepage-mremap
> >  TEST_GEN_FILES += hugepage-shm
> > diff --git a/tools/testing/selftests/mm/hugetlb-soft-offline.c b/tools/testing/selftests/mm/hugetlb-soft-offline.c
> > new file mode 100644
> > index 000000000000..5701eea4ee48
> > --- /dev/null
> > +++ b/tools/testing/selftests/mm/hugetlb-soft-offline.c
> > @@ -0,0 +1,229 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Test soft offline behavior for HugeTLB pages:
> > + * - if enable_soft_offline = 0, hugepages should stay intact and soft
> > + *   offlining failed with EINVAL.
> > + * - if enable_soft_offline = 1, a hugepage should be dissolved and
> > + *   nr_hugepages/free_hugepages should be reduced by 1.
> > + *
> > + * Before running, make sure more than 2 hugepages of default_hugepagesz
> > + * are allocated. For example, if /proc/meminfo/Hugepagesize is 2048kB:
> > + *   echo 8 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
> > + */
> > +
> > +#define _GNU_SOURCE
> > +#include <errno.h>
> > +#include <stdlib.h>
> > +#include <stdio.h>
> > +#include <string.h>
> > +#include <unistd.h>
> > +
> > +#include <linux/magic.h>
> > +#include <linux/memfd.h>
> > +#include <sys/mman.h>
> > +#include <sys/statfs.h>
> > +#include <sys/types.h>
> > +
> > +#ifndef MADV_SOFT_OFFLINE
> > +#define MADV_SOFT_OFFLINE 101
> > +#endif
> > +
> > +#define PREFIX " ... "
> > +#define EPREFIX " !!! "
> > +
> > +enum test_status {
> > +     TEST_PASS = 0,
> > +     TEST_FAILED = 1,
> > +     // From ${ksft_skip} in run_vmtests.sh.
> > +     TEST_SKIPPED = 4,
> > +};
> Include ../kselftest.h and use macros from there instead of redifining.
> Also try to use helper functions from same header file to mark the test
> pass/fail or exit the test entirely. You can look at soft-dirty.c how that
> is written.

Thanks Muhammad.

For sure, I will wait a couple of days to see if there is more
feedback on v4, then refactor with kselftest.h in v5.

>
> --
> BR,
> Muhammad Usama Anjum


  reply	other threads:[~2024-06-21 14:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-20 18:48 [PATCH v4 0/4] Userspace controls soft-offline pages Jiaqi Yan
2024-06-20 18:48 ` [PATCH v4 1/4] mm/memory-failure: refactor log format in soft offline code Jiaqi Yan
2024-06-24  3:08   ` Miaohe Lin
2024-06-20 18:48 ` [PATCH v4 2/4] mm/memory-failure: userspace controls soft-offlining pages Jiaqi Yan
2024-06-24  3:41   ` Miaohe Lin
2024-06-24 16:18     ` Jiaqi Yan
2024-06-20 18:48 ` [PATCH v4 3/4] selftest/mm: test enable_soft_offline behaviors Jiaqi Yan
2024-06-21  5:08   ` Muhammad Usama Anjum
2024-06-21 14:43     ` Jiaqi Yan [this message]
2024-06-20 18:48 ` [PATCH v4 4/4] docs: mm: add enable_soft_offline sysctl Jiaqi Yan
2024-06-20 22:53 ` [PATCH v4 0/4] Userspace controls soft-offline pages Andi Kleen
2024-06-21 23:53   ` Jiaqi Yan
2024-06-22 16:49     ` Andi Kleen

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='CACw3F5229yVkVTjwYCTDF73evvbvEO0=K9wTvFQN+xbNqp0zSQ@mail.gmail.com' \
    --to=jiaqiyan@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=duenwen@google.com \
    --cc=fvdl@google.com \
    --cc=jane.chu@oracle.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --cc=nao.horiguchi@gmail.com \
    --cc=osalvador@suse.de \
    --cc=rientjes@google.com \
    --cc=shuah@kernel.org \
    --cc=usama.anjum@collabora.com \
    /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