* Re: [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages
@ 2024-07-31 23:07 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2024-07-31 23:07 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "low confidence bisect report"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20240730125346.1580150-6-usamaarif642@gmail.com>
References: <20240730125346.1580150-6-usamaarif642@gmail.com>
TO: Usama Arif <usamaarif642@gmail.com>
TO: akpm@linux-foundation.org
TO: linux-mm@kvack.org
CC: hannes@cmpxchg.org
CC: riel@surriel.com
CC: shakeel.butt@linux.dev
CC: roman.gushchin@linux.dev
CC: yuzhao@google.com
CC: david@redhat.com
CC: baohua@kernel.org
CC: ryan.roberts@arm.com
CC: rppt@kernel.org
CC: willy@infradead.org
CC: cerasuolodomenico@gmail.com
CC: corbet@lwn.net
CC: linux-kernel@vger.kernel.org
CC: linux-doc@vger.kernel.org
CC: kernel-team@meta.com
CC: Alexander Zhu <alexlzhu@fb.com>
CC: Usama Arif <usamaarif642@gmail.com>
Hi Usama,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-everything]
url: https://github.com/intel-lab-lkp/linux/commits/Usama-Arif/Revert-memcg-remove-mem_cgroup_uncharge_list/20240730-223949
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20240730125346.1580150-6-usamaarif642%40gmail.com
patch subject: [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages
:::::: branch date: 32 hours ago
:::::: commit date: 32 hours ago
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240801/202408010618.lgnamdZd-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202408010618.lgnamdZd-lkp@intel.com/
All warnings (new ones prefixed by >>):
vm_util.c: In function 'rss_anon':
>> vm_util.c:188:41: warning: format '%ld' expects argument of type 'long int *', but argument 3 has type 'uint64_t *' {aka 'long long unsigned int *'} [-Wformat=]
188 | if (sscanf(buffer, "RssAnon:%10ld kB", &rss_anon) != 1)
| ~~~~^ ~~~~~~~~~
| | |
| | uint64_t * {aka long long unsigned int *}
| long int *
| %10lld
vim +188 tools/testing/selftests/mm/vm_util.c
642bc52aed9c99 tools/testing/selftests/vm/vm_util.c Muhammad Usama Anjum 2022-04-28 174
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 175 uint64_t rss_anon(void)
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 176 {
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 177 uint64_t rss_anon = 0;
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 178 FILE *fp;
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 179 char buffer[MAX_LINE_LENGTH];
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 180
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 181 fp = fopen(STATUS_FILE_PATH, "r");
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 182 if (!fp)
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 183 ksft_exit_fail_msg("%s: Failed to open file %s\n", __func__, STATUS_FILE_PATH);
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 184
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 185 if (!check_for_pattern(fp, "RssAnon:", buffer, sizeof(buffer)))
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 186 goto err_out;
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 187
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 @188 if (sscanf(buffer, "RssAnon:%10ld kB", &rss_anon) != 1)
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 189 ksft_exit_fail_msg("Reading status error\n");
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 190
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 191 err_out:
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 192 fclose(fp);
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 193 return rss_anon;
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 194 }
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 195
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages
@ 2024-08-02 4:17 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2024-08-02 4:17 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "low confidence bisect report"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20240730125346.1580150-6-usamaarif642@gmail.com>
References: <20240730125346.1580150-6-usamaarif642@gmail.com>
TO: Usama Arif <usamaarif642@gmail.com>
TO: akpm@linux-foundation.org
TO: linux-mm@kvack.org
CC: hannes@cmpxchg.org
CC: riel@surriel.com
CC: shakeel.butt@linux.dev
CC: roman.gushchin@linux.dev
CC: yuzhao@google.com
CC: david@redhat.com
CC: baohua@kernel.org
CC: ryan.roberts@arm.com
CC: rppt@kernel.org
CC: willy@infradead.org
CC: cerasuolodomenico@gmail.com
CC: corbet@lwn.net
CC: linux-kernel@vger.kernel.org
CC: linux-doc@vger.kernel.org
CC: kernel-team@meta.com
CC: Alexander Zhu <alexlzhu@fb.com>
CC: Usama Arif <usamaarif642@gmail.com>
Hi Usama,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-everything]
url: https://github.com/intel-lab-lkp/linux/commits/Usama-Arif/Revert-memcg-remove-mem_cgroup_uncharge_list/20240730-223949
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20240730125346.1580150-6-usamaarif642%40gmail.com
patch subject: [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240802/202408021131.OcDZmjjR-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202408021131.OcDZmjjR-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> vm_util.c:188:41: warning: format specifies type 'long *' but the argument has type 'uint64_t *' (aka 'unsigned long long *') [-Wformat]
188 | if (sscanf(buffer, "RssAnon:%10ld kB", &rss_anon) != 1)
| ~~~~~ ^~~~~~~~~
| %10lld
1 warning generated.
vim +188 tools/testing/selftests/mm/vm_util.c
642bc52aed9c99 tools/testing/selftests/vm/vm_util.c Muhammad Usama Anjum 2022-04-28 174
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 175 uint64_t rss_anon(void)
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 176 {
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 177 uint64_t rss_anon = 0;
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 178 FILE *fp;
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 179 char buffer[MAX_LINE_LENGTH];
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 180
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 181 fp = fopen(STATUS_FILE_PATH, "r");
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 182 if (!fp)
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 183 ksft_exit_fail_msg("%s: Failed to open file %s\n", __func__, STATUS_FILE_PATH);
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 184
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 185 if (!check_for_pattern(fp, "RssAnon:", buffer, sizeof(buffer)))
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 186 goto err_out;
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 187
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 @188 if (sscanf(buffer, "RssAnon:%10ld kB", &rss_anon) != 1)
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 189 ksft_exit_fail_msg("Reading status error\n");
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 190
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 191 err_out:
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 192 fclose(fp);
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 193 return rss_anon;
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 194 }
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 195
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 0/6] mm: split underutilized THPs
@ 2024-07-30 12:45 Usama Arif
2024-07-30 12:46 ` [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages Usama Arif
0 siblings, 1 reply; 6+ messages in thread
From: Usama Arif @ 2024-07-30 12:45 UTC (permalink / raw)
To: akpm, linux-mm
Cc: hannes, riel, shakeel.butt, roman.gushchin, yuzhao, david, baohua,
ryan.roberts, rppt, willy, cerasuolodomenico, corbet,
linux-kernel, linux-doc, kernel-team, Usama Arif
The current upstream default policy for THP is always. However, Meta
uses madvise in production as the current THP=always policy vastly
overprovisions THPs in sparsely accessed memory areas, resulting in
excessive memory pressure and premature OOM killing.
Using madvise + relying on khugepaged has certain drawbacks over
THP=always. Using madvise hints mean THPs aren't "transparent" and
require userspace changes. Waiting for khugepaged to scan memory and
collapse pages into THP can be slow and unpredictable in terms of performance
(i.e. you dont know when the collapse will happen), while production
environments require predictable performance. If there is enough memory
available, its better for both performance and predictability to have
a THP from fault time, i.e. THP=always rather than wait for khugepaged
to collapse it, and deal with sparsely populated THPs when the system is
running out of memory.
This patch-series is an attempt to mitigate the issue of running out of
memory when THP is always enabled. During runtime whenever a THP is being
faulted in or collapsed by khugepaged, the THP is added to a list.
Whenever memory reclaim happens, the kernel runs the deferred_split
shrinker which goes through the list and checks if the THP was underutilized,
i.e. how many of the base 4K pages of the entire THP were zero-filled.
If this number goes above a certain threshold, the shrinker will attempt
to split that THP. Then at remap time, the pages that were zero-filled are
not remapped, hence saving memory. This method avoids the downside of
wasting memory in areas where THP is sparsely filled when THP is always
enabled, while still providing the upside THPs like reduced TLB misses without
having to use madvise.
Meta production workloads that were CPU bound (>99% CPU utilzation) were
tested with THP shrinker. The results after 2 hours are as follows:
| THP=madvise | THP=always | THP=always
| | | + shrinker series
| | | + max_ptes_none=409
-----------------------------------------------------------------------------
Performance improvement | - | +1.8% | +1.7%
(over THP=madvise) | | |
-----------------------------------------------------------------------------
Memory usage | 54.6G | 58.8G (+7.7%) | 55.9G (+2.4%)
-----------------------------------------------------------------------------
max_ptes_none=409 means that any THP that has more than 409 out of 512
(80%) zero filled filled pages will be split.
To test out the patches, the below commands without the shrinker will
invoke OOM killer immediately and kill stress, but will not fail with
the shrinker:
echo 450 > /sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none
mkdir /sys/fs/cgroup/test
echo $$ > /sys/fs/cgroup/test/cgroup.procs
echo 20M > /sys/fs/cgroup/test/memory.max
echo 0 > /sys/fs/cgroup/test/memory.swap.max
# allocate twice memory.max for each stress worker and touch 40/512 of
# each THP, i.e. vm-stride 50K.
# With the shrinker, max_ptes_none of 470 and below won't invoke OOM
# killer.
# Without the shrinker, OOM killer is invoked immediately irrespective
# of max_ptes_none value and kill stress.
stress --vm 1 --vm-bytes 40M --vm-stride 50K
Patches 1-2 add back helper functions that were previously removed
to operate on page lists (needed by patch 3).
Patch 3 is an optimization to free zapped tail pages rather than
waiting for page reclaim or migration.
Patch 4 is a prerequisite for THP shrinker to not remap zero-filled
subpages when splitting THP.
Patches 6 adds support for THP shrinker.
(This patch-series restarts the work on having a THP shrinker in kernel
originally done in
https://lore.kernel.org/all/cover.1667454613.git.alexlzhu@fb.com/.
The THP shrinker in this series is significantly different than the
original one, hence its labelled v1 (although the prerequisite to not
remap clean subpages is the same).)
Alexander Zhu (1):
mm: add selftests to split_huge_page() to verify unmap/zap of zero
pages
Usama Arif (3):
Revert "memcg: remove mem_cgroup_uncharge_list()"
Revert "mm: remove free_unref_page_list()"
mm: split underutilized THPs
Yu Zhao (2):
mm: free zapped tail pages when splitting isolated thp
mm: don't remap unused subpages when splitting isolated thp
Documentation/admin-guide/mm/transhuge.rst | 6 +
include/linux/huge_mm.h | 4 +-
include/linux/khugepaged.h | 1 +
include/linux/memcontrol.h | 12 ++
include/linux/mm_types.h | 2 +
include/linux/rmap.h | 2 +-
include/linux/vm_event_item.h | 1 +
mm/huge_memory.c | 152 +++++++++++++++---
mm/hugetlb.c | 1 +
mm/internal.h | 5 +-
mm/khugepaged.c | 3 +-
mm/memcontrol.c | 22 ++-
mm/migrate.c | 76 +++++++--
mm/migrate_device.c | 4 +-
mm/page_alloc.c | 18 +++
mm/rmap.c | 2 +-
mm/vmscan.c | 3 +-
mm/vmstat.c | 1 +
.../selftests/mm/split_huge_page_test.c | 113 +++++++++++++
tools/testing/selftests/mm/vm_util.c | 22 +++
tools/testing/selftests/mm/vm_util.h | 1 +
21 files changed, 414 insertions(+), 37 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages
2024-07-30 12:45 [PATCH 0/6] mm: split underutilized THPs Usama Arif
@ 2024-07-30 12:46 ` Usama Arif
2024-07-30 18:10 ` Rik van Riel
2024-08-01 4:45 ` kernel test robot
0 siblings, 2 replies; 6+ messages in thread
From: Usama Arif @ 2024-07-30 12:46 UTC (permalink / raw)
To: akpm, linux-mm
Cc: hannes, riel, shakeel.butt, roman.gushchin, yuzhao, david, baohua,
ryan.roberts, rppt, willy, cerasuolodomenico, corbet,
linux-kernel, linux-doc, kernel-team, Alexander Zhu, Usama Arif
From: Alexander Zhu <alexlzhu@fb.com>
Self tests to verify the RssAnon value to make sure zero
pages are not remapped except in the case of userfaultfd.
Also includes a self test for the userfaultfd use case.
Signed-off-by: Alexander Zhu <alexlzhu@fb.com>
Signed-off-by: Usama Arif <usamaarif642@gmail.com>
---
.../selftests/mm/split_huge_page_test.c | 113 ++++++++++++++++++
tools/testing/selftests/mm/vm_util.c | 22 ++++
tools/testing/selftests/mm/vm_util.h | 1 +
3 files changed, 136 insertions(+)
diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
index e5e8dafc9d94..da271ad6ff11 100644
--- a/tools/testing/selftests/mm/split_huge_page_test.c
+++ b/tools/testing/selftests/mm/split_huge_page_test.c
@@ -17,6 +17,8 @@
#include <malloc.h>
#include <stdbool.h>
#include <time.h>
+#include <sys/syscall.h>
+#include <linux/userfaultfd.h>
#include "vm_util.h"
#include "../kselftest.h"
@@ -84,6 +86,115 @@ static void write_debugfs(const char *fmt, ...)
write_file(SPLIT_DEBUGFS, input, ret + 1);
}
+static char *allocate_zero_filled_hugepage(size_t len)
+{
+ char *result;
+ size_t i;
+
+ result = memalign(pmd_pagesize, len);
+ if (!result) {
+ printf("Fail to allocate memory\n");
+ exit(EXIT_FAILURE);
+ }
+
+ madvise(result, len, MADV_HUGEPAGE);
+
+ for (i = 0; i < len; i++)
+ result[i] = (char)0;
+
+ return result;
+}
+
+static void verify_rss_anon_split_huge_page_all_zeroes(char *one_page, int nr_hpages, size_t len)
+{
+ uint64_t rss_anon_before, rss_anon_after;
+ size_t i;
+
+ if (!check_huge_anon(one_page, 4, pmd_pagesize)) {
+ printf("No THP is allocated\n");
+ exit(EXIT_FAILURE);
+ }
+
+ rss_anon_before = rss_anon();
+ if (!rss_anon_before) {
+ printf("No RssAnon is allocated before split\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* split all THPs */
+ write_debugfs(PID_FMT, getpid(), (uint64_t)one_page,
+ (uint64_t)one_page + len, 0);
+
+ for (i = 0; i < len; i++)
+ if (one_page[i] != (char)0) {
+ printf("%ld byte corrupted\n", i);
+ exit(EXIT_FAILURE);
+ }
+
+ if (!check_huge_anon(one_page, 0, pmd_pagesize)) {
+ printf("Still AnonHugePages not split\n");
+ exit(EXIT_FAILURE);
+ }
+
+ rss_anon_after = rss_anon();
+ if (rss_anon_after >= rss_anon_before) {
+ printf("Incorrect RssAnon value. Before: %ld After: %ld\n",
+ rss_anon_before, rss_anon_after);
+ exit(EXIT_FAILURE);
+ }
+}
+
+void split_pmd_zero_pages(void)
+{
+ char *one_page;
+ int nr_hpages = 4;
+ size_t len = nr_hpages * pmd_pagesize;
+
+ one_page = allocate_zero_filled_hugepage(len);
+ verify_rss_anon_split_huge_page_all_zeroes(one_page, nr_hpages, len);
+ printf("Split zero filled huge pages successful\n");
+ free(one_page);
+}
+
+void split_pmd_zero_pages_uffd(void)
+{
+ char *one_page;
+ int nr_hpages = 4;
+ size_t len = nr_hpages * pmd_pagesize;
+ long uffd; /* userfaultfd file descriptor */
+ struct uffdio_api uffdio_api;
+ struct uffdio_register uffdio_register;
+
+ /* Create and enable userfaultfd object. */
+
+ uffd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
+ if (uffd == -1) {
+ perror("userfaultfd");
+ exit(1);
+ }
+
+ uffdio_api.api = UFFD_API;
+ uffdio_api.features = 0;
+ if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1) {
+ perror("ioctl-UFFDIO_API");
+ exit(1);
+ }
+
+ one_page = allocate_zero_filled_hugepage(len);
+
+ uffdio_register.range.start = (unsigned long)one_page;
+ uffdio_register.range.len = len;
+ uffdio_register.mode = UFFDIO_REGISTER_MODE_WP;
+ if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1) {
+ perror("ioctl-UFFDIO_REGISTER");
+ exit(1);
+ }
+
+ verify_rss_anon_split_huge_page_all_zeroes(one_page, nr_hpages, len);
+ printf("Split zero filled huge pages with uffd successful\n");
+ free(one_page);
+}
+
void split_pmd_thp(void)
{
char *one_page;
@@ -431,6 +542,8 @@ int main(int argc, char **argv)
fd_size = 2 * pmd_pagesize;
+ split_pmd_zero_pages();
+ split_pmd_zero_pages_uffd();
split_pmd_thp();
split_pte_mapped_thp();
split_file_backed_thp();
diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c
index 5a62530da3b5..7b7e763ba8e3 100644
--- a/tools/testing/selftests/mm/vm_util.c
+++ b/tools/testing/selftests/mm/vm_util.c
@@ -12,6 +12,7 @@
#define PMD_SIZE_FILE_PATH "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size"
#define SMAP_FILE_PATH "/proc/self/smaps"
+#define STATUS_FILE_PATH "/proc/self/status"
#define MAX_LINE_LENGTH 500
unsigned int __page_size;
@@ -171,6 +172,27 @@ uint64_t read_pmd_pagesize(void)
return strtoul(buf, NULL, 10);
}
+uint64_t rss_anon(void)
+{
+ uint64_t rss_anon = 0;
+ FILE *fp;
+ char buffer[MAX_LINE_LENGTH];
+
+ fp = fopen(STATUS_FILE_PATH, "r");
+ if (!fp)
+ ksft_exit_fail_msg("%s: Failed to open file %s\n", __func__, STATUS_FILE_PATH);
+
+ if (!check_for_pattern(fp, "RssAnon:", buffer, sizeof(buffer)))
+ goto err_out;
+
+ if (sscanf(buffer, "RssAnon:%10ld kB", &rss_anon) != 1)
+ ksft_exit_fail_msg("Reading status error\n");
+
+err_out:
+ fclose(fp);
+ return rss_anon;
+}
+
bool __check_huge(void *addr, char *pattern, int nr_hpages,
uint64_t hpage_size)
{
diff --git a/tools/testing/selftests/mm/vm_util.h b/tools/testing/selftests/mm/vm_util.h
index 9007c420d52c..71b75429f4a5 100644
--- a/tools/testing/selftests/mm/vm_util.h
+++ b/tools/testing/selftests/mm/vm_util.h
@@ -39,6 +39,7 @@ unsigned long pagemap_get_pfn(int fd, char *start);
void clear_softdirty(void);
bool check_for_pattern(FILE *fp, const char *pattern, char *buf, size_t len);
uint64_t read_pmd_pagesize(void);
+uint64_t rss_anon(void);
bool check_huge_anon(void *addr, int nr_hpages, uint64_t hpage_size);
bool check_huge_file(void *addr, int nr_hpages, uint64_t hpage_size);
bool check_huge_shmem(void *addr, int nr_hpages, uint64_t hpage_size);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages
2024-07-30 12:46 ` [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages Usama Arif
@ 2024-07-30 18:10 ` Rik van Riel
2024-08-01 4:45 ` kernel test robot
1 sibling, 0 replies; 6+ messages in thread
From: Rik van Riel @ 2024-07-30 18:10 UTC (permalink / raw)
To: Usama Arif, akpm, linux-mm
Cc: hannes, shakeel.butt, roman.gushchin, yuzhao, david, baohua,
ryan.roberts, rppt, willy, cerasuolodomenico, corbet,
linux-kernel, linux-doc, kernel-team, Alexander Zhu
On Tue, 2024-07-30 at 13:46 +0100, Usama Arif wrote:
> From: Alexander Zhu <alexlzhu@fb.com>
>
> Self tests to verify the RssAnon value to make sure zero
> pages are not remapped except in the case of userfaultfd.
> Also includes a self test for the userfaultfd use case.
>
> Signed-off-by: Alexander Zhu <alexlzhu@fb.com>
> Signed-off-by: Usama Arif <usamaarif642@gmail.com>
Acked-by: Rik van Riel <riel@surriel.com>
--
All Rights Reversed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages
2024-07-30 12:46 ` [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages Usama Arif
2024-07-30 18:10 ` Rik van Riel
@ 2024-08-01 4:45 ` kernel test robot
2024-08-06 22:02 ` Usama Arif
1 sibling, 1 reply; 6+ messages in thread
From: kernel test robot @ 2024-08-01 4:45 UTC (permalink / raw)
To: Usama Arif, akpm, linux-mm
Cc: oe-kbuild-all, hannes, riel, shakeel.butt, roman.gushchin, yuzhao,
david, baohua, ryan.roberts, rppt, willy, cerasuolodomenico,
corbet, linux-kernel, linux-doc, kernel-team, Alexander Zhu,
Usama Arif
Hi Usama,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-everything]
url: https://github.com/intel-lab-lkp/linux/commits/Usama-Arif/Revert-memcg-remove-mem_cgroup_uncharge_list/20240730-223949
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20240730125346.1580150-6-usamaarif642%40gmail.com
patch subject: [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages
:::::: branch date: 32 hours ago
:::::: commit date: 32 hours ago
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240801/202408010618.lgnamdZd-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202408010618.lgnamdZd-lkp@intel.com/
All warnings (new ones prefixed by >>):
vm_util.c: In function 'rss_anon':
>> vm_util.c:188:41: warning: format '%ld' expects argument of type 'long int *', but argument 3 has type 'uint64_t *' {aka 'long long unsigned int *'} [-Wformat=]
188 | if (sscanf(buffer, "RssAnon:%10ld kB", &rss_anon) != 1)
| ~~~~^ ~~~~~~~~~
| | |
| | uint64_t * {aka long long unsigned int *}
| long int *
| %10lld
vim +188 tools/testing/selftests/mm/vm_util.c
642bc52aed9c99 tools/testing/selftests/vm/vm_util.c Muhammad Usama Anjum 2022-04-28 174
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 175 uint64_t rss_anon(void)
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 176 {
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 177 uint64_t rss_anon = 0;
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 178 FILE *fp;
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 179 char buffer[MAX_LINE_LENGTH];
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 180
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 181 fp = fopen(STATUS_FILE_PATH, "r");
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 182 if (!fp)
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 183 ksft_exit_fail_msg("%s: Failed to open file %s\n", __func__, STATUS_FILE_PATH);
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 184
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 185 if (!check_for_pattern(fp, "RssAnon:", buffer, sizeof(buffer)))
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 186 goto err_out;
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 187
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 @188 if (sscanf(buffer, "RssAnon:%10ld kB", &rss_anon) != 1)
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 189 ksft_exit_fail_msg("Reading status error\n");
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 190
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 191 err_out:
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 192 fclose(fp);
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 193 return rss_anon;
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 194 }
15bd39f288be91 tools/testing/selftests/mm/vm_util.c Alexander Zhu 2024-07-30 195
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages
2024-08-01 4:45 ` kernel test robot
@ 2024-08-06 22:02 ` Usama Arif
0 siblings, 0 replies; 6+ messages in thread
From: Usama Arif @ 2024-08-06 22:02 UTC (permalink / raw)
To: kernel test robot, akpm, linux-mm
Cc: oe-kbuild-all, hannes, shakeel.butt, roman.gushchin, yuzhao,
david, baohua, ryan.roberts, rppt, willy, cerasuolodomenico,
corbet, linux-kernel, linux-doc, kernel-team, Alexander Zhu, riel
On 01/08/2024 05:45, kernel test robot wrote:
> Hi Usama,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on akpm-mm/mm-everything]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Usama-Arif/Revert-memcg-remove-mem_cgroup_uncharge_list/20240730-223949
> base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> patch link: https://lore.kernel.org/r/20240730125346.1580150-6-usamaarif642%40gmail.com
> patch subject: [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages
> :::::: branch date: 32 hours ago
> :::::: commit date: 32 hours ago
> compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240801/202408010618.lgnamdZd-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/r/202408010618.lgnamdZd-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
> vm_util.c: In function 'rss_anon':
>>> vm_util.c:188:41: warning: format '%ld' expects argument of type 'long int *', but argument 3 has type 'uint64_t *' {aka 'long long unsigned int *'} [-Wformat=]
> 188 | if (sscanf(buffer, "RssAnon:%10ld kB", &rss_anon) != 1)
> | ~~~~^ ~~~~~~~~~
> | | |
> | | uint64_t * {aka long long unsigned int *}
> | long int *
> | %10lld
>
>
Interesting affect of different compilers!
If I compile with the above suggestion on my machine, i.e. convert ld to lld, I get a warning on my machine that uint64_t is long unsigned int (and not long long unsigned int as above):
vm_util.c: In function ‘rss_anon’:
vm_util.c:188:42: warning: format ‘%lld’ expects argument of type ‘long long int *’, but argument 3 has type ‘uint64_t *’ {aka ‘long unsigned int *’} [-Wformat=]
188 | if (sscanf(buffer, "RssAnon:%10lld kB", &rss_anon) != 1)
| ~~~~~^ ~~~~~~~~~
| | |
| | uint64_t * {aka long unsigned int *}
| long long int *
| %10ld
I will just do below which should work hopefully with all compilers:
diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c
index 7b7e763ba8e3..bd147bdb1bb2 100644
--- a/tools/testing/selftests/mm/vm_util.c
+++ b/tools/testing/selftests/mm/vm_util.c
@@ -172,9 +172,9 @@ uint64_t read_pmd_pagesize(void)
return strtoul(buf, NULL, 10);
}
-uint64_t rss_anon(void)
+long unsigned rss_anon(void)
{
- uint64_t rss_anon = 0;
+ long unsigned rss_anon = 0;
FILE *fp;
char buffer[MAX_LINE_LENGTH];
@@ -185,7 +185,7 @@ uint64_t rss_anon(void)
if (!check_for_pattern(fp, "RssAnon:", buffer, sizeof(buffer)))
goto err_out;
- if (sscanf(buffer, "RssAnon:%10ld kB", &rss_anon) != 1)
+ if (sscanf(buffer, "RssAnon:%10lu kB", &rss_anon) != 1)
ksft_exit_fail_msg("Reading status error\n");
err_out:
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-08-06 22:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-31 23:07 [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2024-08-02 4:17 kernel test robot
2024-07-30 12:45 [PATCH 0/6] mm: split underutilized THPs Usama Arif
2024-07-30 12:46 ` [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages Usama Arif
2024-07-30 18:10 ` Rik van Riel
2024-08-01 4:45 ` kernel test robot
2024-08-06 22:02 ` Usama Arif
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.