linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yongting Lin <linyongting@bytedance.com>
To: anthony.yznaga@oracle.com, khalid@kernel.org, shuah@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	libo.gcs85@bytedance.com,
	Yongting Lin <linyongting@bytedance.com>
Subject: [PATCH V2 8/8] mshare: selftests: Add test case to demostrate that mshare partly supports THP
Date: Fri, 19 Sep 2025 21:06:20 +0800	[thread overview]
Message-ID: <20250919130620.56518-8-linyongting@bytedance.com> (raw)
In-Reply-To: <20250919130620.56518-1-linyongting@bytedance.com>

Currently, mshare doesn't support madvise(MADV_HUGEPAGE) to make pages
become THP page.

Thus we need to set /sys/kernel/mm/transparent_hugepage/shmem_enabled
to 'always', enabling mshare to acquire THP pages in a best effort way.

This case is quit simple that set up a mshare memory with 2MB size,
than use memset to fill the physical memory and verify whether THP
was allocated by reading memory.stat.

Signed-off-by: Yongting Lin <linyongting@bytedance.com>
---
 tools/testing/selftests/mshare/memory.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tools/testing/selftests/mshare/memory.c b/tools/testing/selftests/mshare/memory.c
index 4bb0d22b9c03..5132210b1465 100644
--- a/tools/testing/selftests/mshare/memory.c
+++ b/tools/testing/selftests/mshare/memory.c
@@ -68,4 +68,22 @@ TEST_F(memory, swap)
 	ASSERT_GT(swap_size, MB(2) * 9 / 10);
 }
 
+TEST_F(memory, thp)
+{
+	/* fill physical memory */
+	memset(self->addr, 0x01, MB(2));
+
+	size_t huge = read_huge_from_cgroup(self->cgroup);
+
+	/*
+	 * mshare only allocate in the best effort way, and
+	 * don't support madvise(MADV_HUGEPAGE) to change pages
+	 * into THP or khuged to replace pages with THP.
+	 */
+	ksft_print_msg("Tip: Please enable transparent hugepages for shmem before running this test.\n"
+			"For example: echo always > /sys/kernel/mm/transparent_hugepage/shmem_enabled\n");
+
+	ASSERT_GE(huge, MB(2));
+}
+
 TEST_HARNESS_MAIN
-- 
2.20.1



      parent reply	other threads:[~2025-09-19 13:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-19 13:06 [PATCH V2 0/8] Add selftests for mshare Yongting Lin
2025-09-19 13:06 ` [PATCH V2 1/8] mshare: Add selftests Yongting Lin
2025-09-19 13:06 ` [PATCH V2 2/8] mshare: selftests: Adding config fragments Yongting Lin
2025-09-19 13:06 ` [PATCH V2 4/8] mshare: selftests: Add test case shared memory Yongting Lin
2025-09-19 13:06 ` [PATCH V2 5/8] mshare: selftests: Add test case ioctl unmap Yongting Lin
2025-09-19 13:06 ` [PATCH V2 6/8] mshare: selftests: Add some helper functions for configuring and retrieving cgroup Yongting Lin
2025-09-19 13:06 ` [PATCH V2 7/8] mshare: selftests: Add test case to demostrate the swapping of mshare memory Yongting Lin
2025-09-19 13:06 ` Yongting Lin [this message]

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=20250919130620.56518-8-linyongting@bytedance.com \
    --to=linyongting@bytedance.com \
    --cc=akpm@linux-foundation.org \
    --cc=anthony.yznaga@oracle.com \
    --cc=khalid@kernel.org \
    --cc=libo.gcs85@bytedance.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox