From: Miaohe Lin <linmiaohe@huawei.com>
To: Jiaqi Yan <jiaqiyan@google.com>
Cc: <jane.chu@oracle.com>, <rdunlap@infradead.org>,
<ioworker0@gmail.com>, <muchun.song@linux.dev>,
<akpm@linux-foundation.org>, <shuah@kernel.org>, <corbet@lwn.net>,
<osalvador@suse.de>, <rientjes@google.com>, <duenwen@google.com>,
<fvdl@google.com>, <linux-mm@kvack.org>,
<linux-kselftest@vger.kernel.org>, <linux-doc@vger.kernel.org>,
Naoya Horiguchi <nao.horiguchi@gmail.com>
Subject: Re: [PATCH v6 3/4] selftest/mm: test enable_soft_offline behaviors
Date: Fri, 28 Jun 2024 11:29:03 +0800 [thread overview]
Message-ID: <0a28831c-b28e-6db5-0ef3-70940e75d4d2@huawei.com> (raw)
In-Reply-To: <20240626050818.2277273-4-jiaqiyan@google.com>
On 2024/6/26 13:08, 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.
Thanks for update.
>
> 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 | 228 ++++++++++++++++++
> tools/testing/selftests/mm/run_vmtests.sh | 4 +
> 4 files changed, 234 insertions(+)
> create mode 100644 tools/testing/selftests/mm/hugetlb-soft-offline.c
...
> +static void test_soft_offline_common(int enable_soft_offline)
> +{
> + int fd;
> + int expect_errno = enable_soft_offline ? 0 : EOPNOTSUPP;
> + struct statfs file_stat;
> + unsigned long hugepagesize_kb = 0;
> + unsigned long nr_hugepages_before = 0;
> + unsigned long nr_hugepages_after = 0;
> + int ret;
> +
> + ksft_print_msg("Test soft-offline when enabled_soft_offline=%d\n",
> + enable_soft_offline);
> +
> + fd = create_hugetlbfs_file(&file_stat);
> + if (fd < 0)
> + ksft_exit_fail_msg("Failed to create hugetlbfs file\n");
> +
> + hugepagesize_kb = file_stat.f_bsize / 1024;
> + ksft_print_msg("Hugepagesize is %ldkB\n", hugepagesize_kb);
> +
> + if (set_enable_soft_offline(enable_soft_offline)) {
Nit: should this be written as if (set_enable_soft_offline(enable_soft_offline) != 0) to keep consistent with below code?
> + close(fd);
> + ksft_exit_fail_msg("Failed to set enable_soft_offline\n");
> + }
> +
> + if (read_nr_hugepages(hugepagesize_kb, &nr_hugepages_before) != 0) {
> + close(fd);
> + ksft_exit_fail_msg("Failed to read nr_hugepages\n");
> + }
> +
> + ksft_print_msg("Before MADV_SOFT_OFFLINE nr_hugepages=%ld\n",
> + nr_hugepages_before);
> +
> + ret = do_soft_offline(fd, 2 * file_stat.f_bsize, expect_errno);
> +
> + if (read_nr_hugepages(hugepagesize_kb, &nr_hugepages_after) != 0) {
> + close(fd);
> + ksft_exit_fail_msg("Failed to read nr_hugepages\n");
> + }
> +
...
> diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
> index 3157204b9047..781117fac1ba 100755
> --- a/tools/testing/selftests/mm/run_vmtests.sh
> +++ b/tools/testing/selftests/mm/run_vmtests.sh
> @@ -331,6 +331,10 @@ CATEGORY="hugetlb" run_test ./thuge-gen
> CATEGORY="hugetlb" run_test ./charge_reserved_hugetlb.sh -cgroup-v2
> CATEGORY="hugetlb" run_test ./hugetlb_reparenting_test.sh -cgroup-v2
> if $RUN_DESTRUCTIVE; then
> +nr_hugepages_tmp=$(cat /proc/sys/vm/nr_hugepages)
> +echo 8 > /proc/sys/vm/nr_hugepages
> +CATEGORY="hugetlb" run_test ./hugetlb-soft-offline
> +echo "$nr_hugepages_tmp" > /proc/sys/vm/nr_hugepages
Should we save and restore the value of /proc/sys/vm/enable_soft_offline too?
With above fixed, this patch looks good to me.
Acked-by: Miaohe Lin <linmiaohe@huawei.com>
Thanks.
.
next prev parent reply other threads:[~2024-06-28 3:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 5:08 [PATCH v6 0/4] Userspace controls soft-offline pages Jiaqi Yan
2024-06-26 5:08 ` [PATCH v6 1/4] mm/memory-failure: refactor log format in soft offline code Jiaqi Yan
2024-06-26 5:08 ` [PATCH v6 2/4] mm/memory-failure: userspace controls soft-offlining pages Jiaqi Yan
2024-06-28 3:27 ` David Rientjes
2024-06-28 17:05 ` Jiaqi Yan
2024-06-26 5:08 ` [PATCH v6 3/4] selftest/mm: test enable_soft_offline behaviors Jiaqi Yan
2024-06-28 3:29 ` Miaohe Lin [this message]
2024-06-28 17:25 ` Jiaqi Yan
2024-06-26 5:08 ` [PATCH v6 4/4] docs: mm: add enable_soft_offline sysctl Jiaqi Yan
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=0a28831c-b28e-6db5-0ef3-70940e75d4d2@huawei.com \
--to=linmiaohe@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=duenwen@google.com \
--cc=fvdl@google.com \
--cc=ioworker0@gmail.com \
--cc=jane.chu@oracle.com \
--cc=jiaqiyan@google.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=rdunlap@infradead.org \
--cc=rientjes@google.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).