Re: [PATCH 5/6] mm: add selftests to split_huge_page() to verify unmap/zap of zero pages

From: Usama Arif
Date: Tue Aug 06 2024 - 18:05:37 EST




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@xxxxxxxxx/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@xxxxxxxxx>
> | Closes: https://lore.kernel.org/r/202408010618.lgnamdZd-lkp@xxxxxxxxx/
>
> 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: