* [PATCH 0/3] tools/mm/page-types: Fix misc bugs
@ 2026-05-13 2:21 Ye Liu
2026-05-13 2:21 ` [PATCH 1/3] tools/mm/page-types: Fix typo in madvise() error message Ye Liu
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Ye Liu @ 2026-05-13 2:21 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ye Liu, linux-mm, linux-kernel
From: Ye Liu <liuye@kylinos.cn>
This series fixes three issues in tools/mm/page-types.c:
1. Fix two typos in madvise() error messages ("madvice" -> "madvise")
2. Fix operator precedence bug in the sigbus handler where the ternary
operator binds looser than addition, producing incorrect offset
calculation when sigbus_addr is non-NULL
3. Fix --kpageflags option declaration in getopt_long: has_arg should
be 1 (required_argument) since the option requires a file path
Ye Liu (3):
tools/mm/page-types: Fix typo in madvise() error message
tools/mm/page-types: Fix ternary operator precedence in sigbus handler
tools/mm/page-types: Fix kpageflags option argument in getopt_long
tools/mm/page-types.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] tools/mm/page-types: Fix typo in madvise() error message
2026-05-13 2:21 [PATCH 0/3] tools/mm/page-types: Fix misc bugs Ye Liu
@ 2026-05-13 2:21 ` Ye Liu
2026-05-13 10:18 ` David Hildenbrand (Arm)
2026-05-13 2:21 ` [PATCH 2/3] tools/mm/page-types: Fix ternary operator precedence in sigbus handler Ye Liu
2026-05-13 2:21 ` [PATCH 3/3] tools/mm/page-types: Fix kpageflags option argument in getopt_long Ye Liu
2 siblings, 1 reply; 7+ messages in thread
From: Ye Liu @ 2026-05-13 2:21 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ye Liu, linux-mm, linux-kernel
From: Ye Liu <liuye@kylinos.cn>
Two error messages incorrectly spelled the madvise() function name as
"madvice". Fix the typo in both occurrences.
Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
tools/mm/page-types.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c
index d7e5e8902af8..6594245217a8 100644
--- a/tools/mm/page-types.c
+++ b/tools/mm/page-types.c
@@ -997,7 +997,7 @@ static void walk_file_range(const char *name, int fd,
/* turn off readahead */
if (madvise(ptr, len, MADV_RANDOM))
- fatal("madvice failed: %s", name);
+ fatal("madvise failed: %s", name);
if (sigsetjmp(sigbus_jmp, 1)) {
end = off + sigbus_addr ? sigbus_addr - ptr : 0;
@@ -1015,7 +1015,7 @@ static void walk_file_range(const char *name, int fd,
/* turn off harvesting reference bits */
if (madvise(ptr, len, MADV_SEQUENTIAL))
- fatal("madvice failed: %s", name);
+ fatal("madvise failed: %s", name);
if (pagemap_read(buf, (unsigned long)ptr / page_size,
nr_pages) != nr_pages)
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] tools/mm/page-types: Fix ternary operator precedence in sigbus handler
2026-05-13 2:21 [PATCH 0/3] tools/mm/page-types: Fix misc bugs Ye Liu
2026-05-13 2:21 ` [PATCH 1/3] tools/mm/page-types: Fix typo in madvise() error message Ye Liu
@ 2026-05-13 2:21 ` Ye Liu
2026-05-13 10:24 ` David Hildenbrand (Arm)
2026-05-13 2:21 ` [PATCH 3/3] tools/mm/page-types: Fix kpageflags option argument in getopt_long Ye Liu
2 siblings, 1 reply; 7+ messages in thread
From: Ye Liu @ 2026-05-13 2:21 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ye Liu, linux-mm, linux-kernel
From: Ye Liu <liuye@kylinos.cn>
The ternary operator (?:) has lower precedence than addition (+), so
the expression `off + sigbus_addr ? sigbus_addr - ptr : 0` was parsed
as `(off + sigbus_addr) ? (sigbus_addr - ptr) : 0` rather than the
intended `off + (sigbus_addr ? sigbus_addr - ptr : 0)`. Add explicit
parentheses to ensure the correct evaluation order.
Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
tools/mm/page-types.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c
index 6594245217a8..66f429f2b698 100644
--- a/tools/mm/page-types.c
+++ b/tools/mm/page-types.c
@@ -1000,7 +1000,7 @@ static void walk_file_range(const char *name, int fd,
fatal("madvise failed: %s", name);
if (sigsetjmp(sigbus_jmp, 1)) {
- end = off + sigbus_addr ? sigbus_addr - ptr : 0;
+ end = off + (sigbus_addr ? sigbus_addr - ptr : 0);
fprintf(stderr, "got sigbus at offset %lld: %s\n",
(long long)end, name);
goto got_sigbus;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] tools/mm/page-types: Fix kpageflags option argument in getopt_long
2026-05-13 2:21 [PATCH 0/3] tools/mm/page-types: Fix misc bugs Ye Liu
2026-05-13 2:21 ` [PATCH 1/3] tools/mm/page-types: Fix typo in madvise() error message Ye Liu
2026-05-13 2:21 ` [PATCH 2/3] tools/mm/page-types: Fix ternary operator precedence in sigbus handler Ye Liu
@ 2026-05-13 2:21 ` Ye Liu
2026-05-13 10:27 ` David Hildenbrand (Arm)
2 siblings, 1 reply; 7+ messages in thread
From: Ye Liu @ 2026-05-13 2:21 UTC (permalink / raw)
To: Andrew Morton; +Cc: Ye Liu, linux-mm, linux-kernel
From: Ye Liu <liuye@kylinos.cn>
The --kpageflags option requires an argument to specify the kpageflags
file path, but has_arg was set to 0 (no_argument) in the long options
table. Change it to 1 (required_argument) so getopt_long correctly
parses the argument.
Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
tools/mm/page-types.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c
index 66f429f2b698..7fc5a8be5997 100644
--- a/tools/mm/page-types.c
+++ b/tools/mm/page-types.c
@@ -1261,7 +1261,7 @@ static const struct option opts[] = {
{ "no-summary", 0, NULL, 'N' },
{ "hwpoison" , 0, NULL, 'X' },
{ "unpoison" , 0, NULL, 'x' },
- { "kpageflags", 0, NULL, 'F' },
+ { "kpageflags", 1, NULL, 'F' },
{ "help" , 0, NULL, 'h' },
{ NULL , 0, NULL, 0 }
};
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] tools/mm/page-types: Fix typo in madvise() error message
2026-05-13 2:21 ` [PATCH 1/3] tools/mm/page-types: Fix typo in madvise() error message Ye Liu
@ 2026-05-13 10:18 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand (Arm) @ 2026-05-13 10:18 UTC (permalink / raw)
To: Ye Liu, Andrew Morton; +Cc: Ye Liu, linux-mm, linux-kernel
On 5/13/26 04:21, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
>
> Two error messages incorrectly spelled the madvise() function name as
> "madvice". Fix the typo in both occurrences.
>
> Signed-off-by: Ye Liu <liuye@kylinos.cn>
> ---
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] tools/mm/page-types: Fix ternary operator precedence in sigbus handler
2026-05-13 2:21 ` [PATCH 2/3] tools/mm/page-types: Fix ternary operator precedence in sigbus handler Ye Liu
@ 2026-05-13 10:24 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand (Arm) @ 2026-05-13 10:24 UTC (permalink / raw)
To: Ye Liu, Andrew Morton; +Cc: Ye Liu, linux-mm, linux-kernel
On 5/13/26 04:21, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
>
> The ternary operator (?:) has lower precedence than addition (+), so
> the expression `off + sigbus_addr ? sigbus_addr - ptr : 0` was parsed
> as `(off + sigbus_addr) ? (sigbus_addr - ptr) : 0` rather than the
> intended `off + (sigbus_addr ? sigbus_addr - ptr : 0)`. Add explicit
> parentheses to ensure the correct evaluation order.
>
> Signed-off-by: Ye Liu <liuye@kylinos.cn>
> ---
> tools/mm/page-types.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c
> index 6594245217a8..66f429f2b698 100644
> --- a/tools/mm/page-types.c
> +++ b/tools/mm/page-types.c
> @@ -1000,7 +1000,7 @@ static void walk_file_range(const char *name, int fd,
> fatal("madvise failed: %s", name);
>
> if (sigsetjmp(sigbus_jmp, 1)) {
> - end = off + sigbus_addr ? sigbus_addr - ptr : 0;
> + end = off + (sigbus_addr ? sigbus_addr - ptr : 0);
> fprintf(stderr, "got sigbus at offset %lld: %s\n",
> (long long)end, name);
> goto got_sigbus;
"sigbus_addr - ptr" will give us the offset into the mmap(). Adding that to off
will give us the offset into the file.
No idea what happens if we don't have sigbus_addr ...
Anyhow, your change looks good, I just have no idea whether updating "end" here
is the right thing to do.
--
Cheers,
David
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] tools/mm/page-types: Fix kpageflags option argument in getopt_long
2026-05-13 2:21 ` [PATCH 3/3] tools/mm/page-types: Fix kpageflags option argument in getopt_long Ye Liu
@ 2026-05-13 10:27 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand (Arm) @ 2026-05-13 10:27 UTC (permalink / raw)
To: Ye Liu, Andrew Morton; +Cc: Ye Liu, linux-mm, linux-kernel
On 5/13/26 04:21, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
>
> The --kpageflags option requires an argument to specify the kpageflags
> file path, but has_arg was set to 0 (no_argument) in the long options
> table. Change it to 1 (required_argument) so getopt_long correctly
> parses the argument.
>
> Signed-off-by: Ye Liu <liuye@kylinos.cn>
> ---
> tools/mm/page-types.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c
> index 66f429f2b698..7fc5a8be5997 100644
> --- a/tools/mm/page-types.c
> +++ b/tools/mm/page-types.c
> @@ -1261,7 +1261,7 @@ static const struct option opts[] = {
> { "no-summary", 0, NULL, 'N' },
> { "hwpoison" , 0, NULL, 'X' },
> { "unpoison" , 0, NULL, 'x' },
> - { "kpageflags", 0, NULL, 'F' },
> + { "kpageflags", 1, NULL, 'F' },
> { "help" , 0, NULL, 'h' },
> { NULL , 0, NULL, 0 }
> };
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-05-13 10:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-13 2:21 [PATCH 0/3] tools/mm/page-types: Fix misc bugs Ye Liu
2026-05-13 2:21 ` [PATCH 1/3] tools/mm/page-types: Fix typo in madvise() error message Ye Liu
2026-05-13 10:18 ` David Hildenbrand (Arm)
2026-05-13 2:21 ` [PATCH 2/3] tools/mm/page-types: Fix ternary operator precedence in sigbus handler Ye Liu
2026-05-13 10:24 ` David Hildenbrand (Arm)
2026-05-13 2:21 ` [PATCH 3/3] tools/mm/page-types: Fix kpageflags option argument in getopt_long Ye Liu
2026-05-13 10:27 ` David Hildenbrand (Arm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox