ltp.lists.linux.it archive mirror
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] hugemmap32: release mem caches and prepare for hugepage
@ 2023-05-29  6:11 Li Wang
  2023-05-29  6:11 ` [LTP] [PATCH 2/2] hugetlb: compacting memory to reduce fragmental pages Li Wang
  2023-06-21  2:52 ` [LTP] [PATCH 1/2] hugemmap32: release mem caches and prepare for hugepage Li Wang
  0 siblings, 2 replies; 4+ messages in thread
From: Li Wang @ 2023-05-29  6:11 UTC (permalink / raw)
  To: ltp

As Martin pointed that mem caches count as available, we'd better
release them for huge page use.

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c
index 36a426a09..76b790a95 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c
@@ -64,6 +64,7 @@ static void setup(void)
 
 	SAFE_CLOSEDIR(dir);
 
+	SAFE_FILE_PRINTF("/proc/sys/vm/drop_caches", "3");
 	if (tst_available_mem() < (long long)hpage_size) {
 		g_hpage_path[0] = '\0';
 		tst_brk(TCONF, "No enough memory for gigantic hugepage reservation");
-- 
2.40.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP] [PATCH 2/2] hugetlb: compacting memory to reduce fragmental pages
  2023-05-29  6:11 [LTP] [PATCH 1/2] hugemmap32: release mem caches and prepare for hugepage Li Wang
@ 2023-05-29  6:11 ` Li Wang
  2023-06-21  2:52 ` [LTP] [PATCH 1/2] hugemmap32: release mem caches and prepare for hugepage Li Wang
  1 sibling, 0 replies; 4+ messages in thread
From: Li Wang @ 2023-05-29  6:11 UTC (permalink / raw)
  To: ltp

Kernel memory compaction is a process that helps to reduce fragmentation
and optimize memory allocation by compacting memory pages.

  `echo 1 > /proc/sys/vm/compact_memory`

When 1 is written to the file, all zones are compacted such that free
memory is available in contiguous blocks where possible.

This can be important for example in the allocation of huge pages although
processes will also directly compact memory as required.

As this introduced since v2.6.35, we could safely use it via
SAFE_FILE_PRINT() in LTP lib:

  commit 76ab0f530e4a01d4dc20cdc1d5e87753c579dc18
  Author: Mel Gorman <mel@csn.ul.ie>
  Date:   Mon May 24 14:32:28 2010 -0700

      mm: compaction: add /proc trigger for memory compaction

Signed-off-by: Li Wang <liwang@redhat.com>
---
 lib/tst_hugepage.c                                 | 1 +
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/lib/tst_hugepage.c b/lib/tst_hugepage.c
index 728a8c3ec..d2e70a955 100644
--- a/lib/tst_hugepage.c
+++ b/lib/tst_hugepage.c
@@ -47,6 +47,7 @@ unsigned long tst_reserve_hugepages(struct tst_hugepage *hp)
 	}
 
 	SAFE_FILE_PRINTF("/proc/sys/vm/drop_caches", "3");
+	SAFE_FILE_PRINTF("/proc/sys/vm/compact_memory", "1");
 	if (hp->policy == TST_NEEDS) {
 		tst_hugepages += SAFE_READ_MEMINFO("HugePages_Total:");
 		goto set_hugepages;
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c
index 76b790a95..d27e5b8b2 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c
@@ -65,6 +65,8 @@ static void setup(void)
 	SAFE_CLOSEDIR(dir);
 
 	SAFE_FILE_PRINTF("/proc/sys/vm/drop_caches", "3");
+	SAFE_FILE_PRINTF("/proc/sys/vm/compact_memory", "1");
+
 	if (tst_available_mem() < (long long)hpage_size) {
 		g_hpage_path[0] = '\0';
 		tst_brk(TCONF, "No enough memory for gigantic hugepage reservation");
-- 
2.40.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH 1/2] hugemmap32: release mem caches and prepare for hugepage
  2023-05-29  6:11 [LTP] [PATCH 1/2] hugemmap32: release mem caches and prepare for hugepage Li Wang
  2023-05-29  6:11 ` [LTP] [PATCH 2/2] hugetlb: compacting memory to reduce fragmental pages Li Wang
@ 2023-06-21  2:52 ` Li Wang
  2023-06-22  8:56   ` Li Wang
  1 sibling, 1 reply; 4+ messages in thread
From: Li Wang @ 2023-06-21  2:52 UTC (permalink / raw)
  To: ltp

ping~

If nobody objects to these two simple improvements,
I would push both the next day.

On Mon, May 29, 2023 at 2:11 PM Li Wang <liwang@redhat.com> wrote:

> As Martin pointed that mem caches count as available, we'd better
> release them for huge page use.
>
> Signed-off-by: Li Wang <liwang@redhat.com>
> ---
>  testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c
> b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c
> index 36a426a09..76b790a95 100644
> --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap32.c
> @@ -64,6 +64,7 @@ static void setup(void)
>
>         SAFE_CLOSEDIR(dir);
>
> +       SAFE_FILE_PRINTF("/proc/sys/vm/drop_caches", "3");
>         if (tst_available_mem() < (long long)hpage_size) {
>                 g_hpage_path[0] = '\0';
>                 tst_brk(TCONF, "No enough memory for gigantic hugepage
> reservation");
> --
> 2.40.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>

-- 
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH 1/2] hugemmap32: release mem caches and prepare for hugepage
  2023-06-21  2:52 ` [LTP] [PATCH 1/2] hugemmap32: release mem caches and prepare for hugepage Li Wang
@ 2023-06-22  8:56   ` Li Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Li Wang @ 2023-06-22  8:56 UTC (permalink / raw)
  To: ltp

On Wed, Jun 21, 2023 at 10:52 AM Li Wang <liwang@redhat.com> wrote:

> ping~
>
> If nobody objects to these two simple improvements,
> I would push both the next day.
>

Both pushed, thanks!

-- 
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-22  8:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-29  6:11 [LTP] [PATCH 1/2] hugemmap32: release mem caches and prepare for hugepage Li Wang
2023-05-29  6:11 ` [LTP] [PATCH 2/2] hugetlb: compacting memory to reduce fragmental pages Li Wang
2023-06-21  2:52 ` [LTP] [PATCH 1/2] hugemmap32: release mem caches and prepare for hugepage Li Wang
2023-06-22  8:56   ` Li Wang

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).