* [PATCH v4 0/3] mm: Coccinelle-driven cleanups across memory management code
@ 2025-11-28 7:01 Sahil Chandna
2025-11-28 7:01 ` [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary calculation Sahil Chandna
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Sahil Chandna @ 2025-11-28 7:01 UTC (permalink / raw)
To: akpm, david, lorenzo.stoakes, mhocko, vbabka, rppt, surenb,
hannes, shakeel.butt, zhengqi.arch, Liam.Howlett, weixugc,
axelrasmussen, yuanchu, yosry.ahmed, nphamcs, chengming.zhou,
linux-mm, linux-kernel
Cc: david, Sahil Chandna
This patch series contains three minor cleanups identified by
Coccinelle scripts under scripts/coccinelle/misc/:
* Use ALIGN() to compute the next hugepage boundary instead of the
open-coded expression and use min() macro to improve readability.
* Use the %pe printk format specifier for PTR_ERR() reporting
in vmscan.c and zswap.c
Found using:
make coccicheck MODE=report M=mm/
change since v3:
- Update the commit message to highlight change in computation of
boundary using ALIGN().
changes since v1 and v2:
- Patch 1/3: update return value as per review comments.
- patch 2/3 and 3/3: Add Acked-by and Reviewed-by tags.
link to v1: https://lore.kernel.org/all/cover.1763227530.git.chandna.sahil@gmail.com/
link to v2: https://lore.kernel.org/all/cover.1763796152.git.chandna.sahil@gmail.com/
link to v3: https://lore.kernel.org/all/cover.1764177933.git.chandna.sahil@gmail.com/
Sahil Chandna (3):
mm: pagewalk: simplify hugepage boundary calculation
mm/vmscan: use %pe to print error pointers
mm/zswap: use %pe to print error pointers
mm/pagewalk.c | 3 +--
mm/vmscan.c | 4 ++--
mm/zswap.c | 4 ++--
3 files changed, 5 insertions(+), 6 deletions(-)
--
2.50.1
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary calculation 2025-11-28 7:01 [PATCH v4 0/3] mm: Coccinelle-driven cleanups across memory management code Sahil Chandna @ 2025-11-28 7:01 ` Sahil Chandna 2025-12-24 7:50 ` Baolin Wang 2025-11-28 7:01 ` [PATCH v4 2/3] mm/vmscan: use %pe to print error pointers Sahil Chandna 2025-11-28 7:01 ` [PATCH v4 3/3] mm/zswap: " Sahil Chandna 2 siblings, 1 reply; 11+ messages in thread From: Sahil Chandna @ 2025-11-28 7:01 UTC (permalink / raw) To: akpm, david, lorenzo.stoakes, mhocko, vbabka, rppt, surenb, hannes, shakeel.butt, zhengqi.arch, Liam.Howlett, weixugc, axelrasmussen, yuanchu, yosry.ahmed, nphamcs, chengming.zhou, linux-mm, linux-kernel Cc: david, Sahil Chandna, Matthew Wilcox, David Laight Replace hugepage boundary computation with ALIGN() helper instead of an open coded expression. This helps to improves code readability. This was flagged by Coccinelle (misc/minmax.cocci) as an opportunity to use min(), after which the boundary computation was updated following review suggestions. Found by: make coccicheck MODE=report M=mm/ No functional change intended. Acked-by: David Hildenbrand (Red Hat) <david@kernel.org> Suggested-by: David Hildenbrand (Red Hat) <david@kernel.org> Suggested-by: Matthew Wilcox <willy@infradead.org> Suggested-by: David Laight <david.laight.linux@gmail.com> Signed-off-by: Sahil Chandna <chandna.sahil@gmail.com> --- mm/pagewalk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/pagewalk.c b/mm/pagewalk.c index 9f91cf85a5be..9fd59d517f37 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c @@ -312,8 +312,7 @@ static int walk_pgd_range(unsigned long addr, unsigned long end, static unsigned long hugetlb_entry_end(struct hstate *h, unsigned long addr, unsigned long end) { - unsigned long boundary = (addr & huge_page_mask(h)) + huge_page_size(h); - return boundary < end ? boundary : end; + return min(ALIGN(addr, huge_page_size(h)), end); } static int walk_hugetlb_range(unsigned long addr, unsigned long end, -- 2.50.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary calculation 2025-11-28 7:01 ` [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary calculation Sahil Chandna @ 2025-12-24 7:50 ` Baolin Wang 2025-12-24 9:23 ` [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary Lance Yang 0 siblings, 1 reply; 11+ messages in thread From: Baolin Wang @ 2025-12-24 7:50 UTC (permalink / raw) To: Sahil Chandna, akpm, david, lorenzo.stoakes, mhocko, vbabka, rppt, surenb, hannes, shakeel.butt, zhengqi.arch, Liam.Howlett, weixugc, axelrasmussen, yuanchu, yosry.ahmed, nphamcs, chengming.zhou, linux-mm, linux-kernel Cc: david, Matthew Wilcox, David Laight Hi Andrew, On 2025/11/28 15:01, Sahil Chandna wrote: > Replace hugepage boundary computation with ALIGN() helper instead of > an open coded expression. This helps to improves code readability. > > This was flagged by Coccinelle (misc/minmax.cocci) as an opportunity > to use min(), after which the boundary computation was updated following > review suggestions. > > Found by: make coccicheck MODE=report M=mm/ > No functional change intended. > > Acked-by: David Hildenbrand (Red Hat) <david@kernel.org> > Suggested-by: David Hildenbrand (Red Hat) <david@kernel.org> > Suggested-by: Matthew Wilcox <willy@infradead.org> > Suggested-by: David Laight <david.laight.linux@gmail.com> > Signed-off-by: Sahil Chandna <chandna.sahil@gmail.com> > --- > mm/pagewalk.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/mm/pagewalk.c b/mm/pagewalk.c > index 9f91cf85a5be..9fd59d517f37 100644 > --- a/mm/pagewalk.c > +++ b/mm/pagewalk.c > @@ -312,8 +312,7 @@ static int walk_pgd_range(unsigned long addr, unsigned long end, > static unsigned long hugetlb_entry_end(struct hstate *h, unsigned long addr, > unsigned long end) > { > - unsigned long boundary = (addr & huge_page_mask(h)) + huge_page_size(h); > - return boundary < end ? boundary : end; > + return min(ALIGN(addr, huge_page_size(h)), end); > } Please drop this patch from the mm-new branch, as it causes 'run_vmtests.sh' to hang. Specifically, it leads to the system hanging when executing hugepage-vmemmap test, because the program falls into an infinite loop in walk_hugetlb_range() and cannot break out. This patch does introduce functional changes and makes an incorrect assumption that the 'end' must be aligned to the hugepage size. However, this is not necessarily the case. For example, see how pagemap_read() calculates the 'end': " end = start_vaddr + ((count / PM_ENTRY_BYTES) << PAGE_SHIFT); " Revert this patch, mm selftests work well. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary 2025-12-24 7:50 ` Baolin Wang @ 2025-12-24 9:23 ` Lance Yang 2025-12-24 12:46 ` Sahil Chandna 2025-12-24 14:08 ` David Laight 0 siblings, 2 replies; 11+ messages in thread From: Lance Yang @ 2025-12-24 9:23 UTC (permalink / raw) To: baolin.wang Cc: Liam.Howlett, akpm, axelrasmussen, chandna.sahil, chengming.zhou, david.laight.linux, david, david, hannes, linux-kernel, linux-mm, lorenzo.stoakes, mhocko, nphamcs, rppt, shakeel.butt, surenb, vbabka, weixugc, willy, yosry.ahmed, yuanchu, zhengqi.arch, Lance Yang From: Lance Yang <lance.yang@linux.dev> On Wed, 24 Dec 2025 15:50:34 +0800, Baolin Wang wrote: > Hi Andrew, > > On 2025/11/28 15:01, Sahil Chandna wrote: > > Replace hugepage boundary computation with ALIGN() helper instead of > > an open coded expression. This helps to improves code readability. > > > > This was flagged by Coccinelle (misc/minmax.cocci) as an opportunity > > to use min(), after which the boundary computation was updated following > > review suggestions. > > > > Found by: make coccicheck MODE=report M=mm/ > > No functional change intended. > > > > Acked-by: David Hildenbrand (Red Hat) <david@kernel.org> > > Suggested-by: David Hildenbrand (Red Hat) <david@kernel.org> > > Suggested-by: Matthew Wilcox <willy@infradead.org> > > Suggested-by: David Laight <david.laight.linux@gmail.com> > > Signed-off-by: Sahil Chandna <chandna.sahil@gmail.com> > > --- > > mm/pagewalk.c | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/mm/pagewalk.c b/mm/pagewalk.c > > index 9f91cf85a5be..9fd59d517f37 100644 > > --- a/mm/pagewalk.c > > +++ b/mm/pagewalk.c > > @@ -312,8 +312,7 @@ static int walk_pgd_range(unsigned long addr, unsigned long end, > > static unsigned long hugetlb_entry_end(struct hstate *h, unsigned long addr, > > unsigned long end) > > { > > - unsigned long boundary = (addr & huge_page_mask(h)) + huge_page_size(h); > > - return boundary < end ? boundary : end; > > + return min(ALIGN(addr, huge_page_size(h)), end); > > } > > Please drop this patch from the mm-new branch, as it causes > 'run_vmtests.sh' to hang. Specifically, it leads to the system hanging > when executing hugepage-vmemmap test, because the program falls into an > infinite loop in walk_hugetlb_range() and cannot break out. Good catch! The problem is that ALIGN() returns addr itself when already aligned, causing the infinite loop ... > > This patch does introduce functional changes and makes an incorrect > assumption that the 'end' must be aligned to the hugepage size. However, Yep. This patch is not equivalent to the original code when addr is already aligned :) > this is not necessarily the case. For example, see how pagemap_read() > calculates the 'end': > > " > end = start_vaddr + ((count / PM_ENTRY_BYTES) << PAGE_SHIFT); > " > > Revert this patch, mm selftests work well. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary 2025-12-24 9:23 ` [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary Lance Yang @ 2025-12-24 12:46 ` Sahil Chandna 2025-12-24 14:08 ` David Laight 1 sibling, 0 replies; 11+ messages in thread From: Sahil Chandna @ 2025-12-24 12:46 UTC (permalink / raw) To: akpm, Lance Yang, baolin.wang Cc: Liam.Howlett, akpm, axelrasmussen, chengming.zhou, david.laight.linux, david, david, hannes, linux-kernel, linux-mm, lorenzo.stoakes, mhocko, nphamcs, rppt, shakeel.butt, surenb, vbabka, weixugc, willy, yosry.ahmed, yuanchu, zhengqi.arch On Wed, Dec 24, 2025 at 05:23:32PM +0800, Lance Yang wrote: >From: Lance Yang <lance.yang@linux.dev> > > >On Wed, 24 Dec 2025 15:50:34 +0800, Baolin Wang wrote: >> Hi Andrew, >> >> On 2025/11/28 15:01, Sahil Chandna wrote: >> > Replace hugepage boundary computation with ALIGN() helper instead of >> > an open coded expression. This helps to improves code readability. >> > >> > This was flagged by Coccinelle (misc/minmax.cocci) as an opportunity >> > to use min(), after which the boundary computation was updated following >> > review suggestions. >> > >> > Found by: make coccicheck MODE=report M=mm/ >> > No functional change intended. >> > >> > Acked-by: David Hildenbrand (Red Hat) <david@kernel.org> >> > Suggested-by: David Hildenbrand (Red Hat) <david@kernel.org> >> > Suggested-by: Matthew Wilcox <willy@infradead.org> >> > Suggested-by: David Laight <david.laight.linux@gmail.com> >> > Signed-off-by: Sahil Chandna <chandna.sahil@gmail.com> >> > --- >> > mm/pagewalk.c | 3 +-- >> > 1 file changed, 1 insertion(+), 2 deletions(-) >> > >> > diff --git a/mm/pagewalk.c b/mm/pagewalk.c >> > index 9f91cf85a5be..9fd59d517f37 100644 >> > --- a/mm/pagewalk.c >> > +++ b/mm/pagewalk.c >> > @@ -312,8 +312,7 @@ static int walk_pgd_range(unsigned long addr, unsigned long end, >> > static unsigned long hugetlb_entry_end(struct hstate *h, unsigned long addr, >> > unsigned long end) >> > { >> > - unsigned long boundary = (addr & huge_page_mask(h)) + huge_page_size(h); >> > - return boundary < end ? boundary : end; >> > + return min(ALIGN(addr, huge_page_size(h)), end); >> > } >> >> Please drop this patch from the mm-new branch, as it causes >> 'run_vmtests.sh' to hang. Specifically, it leads to the system hanging >> when executing hugepage-vmemmap test, because the program falls into an >> infinite loop in walk_hugetlb_range() and cannot break out. > >Good catch! The problem is that ALIGN() returns addr itself when already >aligned, causing the infinite loop ... > >> >> This patch does introduce functional changes and makes an incorrect >> assumption that the 'end' must be aligned to the hugepage size. However, > >Yep. This patch is not equivalent to the original code when addr is >already aligned :) > >> this is not necessarily the case. For example, see how pagemap_read() >> calculates the 'end': >> >> " >> end = start_vaddr + ((count / PM_ENTRY_BYTES) << PAGE_SHIFT); >> " >> >> Revert this patch, mm selftests work well. Hi Baolin, Lance, Andrew, Thanks for catching this, I understand why ALIGN() caused an infinite loop. Please drop this patch, or shall I submit the revert ? Apologies for this, I am setting up environment for running the selftest and will send out corrected patch once it successfully pass mm selftests. Regards, Sahil ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary 2025-12-24 9:23 ` [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary Lance Yang 2025-12-24 12:46 ` Sahil Chandna @ 2025-12-24 14:08 ` David Laight 2025-12-24 18:06 ` Matthew Wilcox 1 sibling, 1 reply; 11+ messages in thread From: David Laight @ 2025-12-24 14:08 UTC (permalink / raw) To: Lance Yang Cc: baolin.wang, Liam.Howlett, akpm, axelrasmussen, chandna.sahil, chengming.zhou, david, david, hannes, linux-kernel, linux-mm, lorenzo.stoakes, mhocko, nphamcs, rppt, shakeel.butt, surenb, vbabka, weixugc, willy, yosry.ahmed, yuanchu, zhengqi.arch, Lance Yang On Wed, 24 Dec 2025 17:23:32 +0800 Lance Yang <ioworker0@gmail.com> wrote: > From: Lance Yang <lance.yang@linux.dev> > > > On Wed, 24 Dec 2025 15:50:34 +0800, Baolin Wang wrote: > > Hi Andrew, > > > > On 2025/11/28 15:01, Sahil Chandna wrote: > > > Replace hugepage boundary computation with ALIGN() helper instead of > > > an open coded expression. This helps to improves code readability. > > > > > > This was flagged by Coccinelle (misc/minmax.cocci) as an opportunity > > > to use min(), after which the boundary computation was updated following > > > review suggestions. > > > > > > Found by: make coccicheck MODE=report M=mm/ > > > No functional change intended. > > > > > > Acked-by: David Hildenbrand (Red Hat) <david@kernel.org> > > > Suggested-by: David Hildenbrand (Red Hat) <david@kernel.org> > > > Suggested-by: Matthew Wilcox <willy@infradead.org> > > > Suggested-by: David Laight <david.laight.linux@gmail.com> > > > Signed-off-by: Sahil Chandna <chandna.sahil@gmail.com> > > > --- > > > mm/pagewalk.c | 3 +-- > > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > > > diff --git a/mm/pagewalk.c b/mm/pagewalk.c > > > index 9f91cf85a5be..9fd59d517f37 100644 > > > --- a/mm/pagewalk.c > > > +++ b/mm/pagewalk.c > > > @@ -312,8 +312,7 @@ static int walk_pgd_range(unsigned long addr, unsigned long end, > > > static unsigned long hugetlb_entry_end(struct hstate *h, unsigned long addr, > > > unsigned long end) > > > { > > > - unsigned long boundary = (addr & huge_page_mask(h)) + huge_page_size(h); > > > - return boundary < end ? boundary : end; > > > + return min(ALIGN(addr, huge_page_size(h)), end); > > > } > > > > Please drop this patch from the mm-new branch, as it causes > > 'run_vmtests.sh' to hang. Specifically, it leads to the system hanging > > when executing hugepage-vmemmap test, because the program falls into an > > infinite loop in walk_hugetlb_range() and cannot break out. > > Good catch! The problem is that ALIGN() returns addr itself when already > aligned, causing the infinite loop ... Using ALIGN(addr + 1, huge_page_size(h)) would work. Although it could be (addr + 1) & ~huge_page_mask(h) which is probably the easiest to understand. Some of the 'helper' macros don't really make the code easier to read. (And that includes a lot of uses of min().) David > > > > > This patch does introduce functional changes and makes an incorrect > > assumption that the 'end' must be aligned to the hugepage size. However, > > Yep. This patch is not equivalent to the original code when addr is > already aligned :) > > > this is not necessarily the case. For example, see how pagemap_read() > > calculates the 'end': > > > > " > > end = start_vaddr + ((count / PM_ENTRY_BYTES) << PAGE_SHIFT); > > " > > > > Revert this patch, mm selftests work well. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary 2025-12-24 14:08 ` David Laight @ 2025-12-24 18:06 ` Matthew Wilcox 2025-12-25 9:32 ` David Hildenbrand (Red Hat) 0 siblings, 1 reply; 11+ messages in thread From: Matthew Wilcox @ 2025-12-24 18:06 UTC (permalink / raw) To: David Laight Cc: Lance Yang, baolin.wang, Liam.Howlett, akpm, axelrasmussen, chandna.sahil, chengming.zhou, david, david, hannes, linux-kernel, linux-mm, lorenzo.stoakes, mhocko, nphamcs, rppt, shakeel.butt, surenb, vbabka, weixugc, yosry.ahmed, yuanchu, zhengqi.arch, Lance Yang On Wed, Dec 24, 2025 at 02:08:29PM +0000, David Laight wrote: > > > > +++ b/mm/pagewalk.c > > > > @@ -312,8 +312,7 @@ static int walk_pgd_range(unsigned long addr, unsigned long end, > > > > static unsigned long hugetlb_entry_end(struct hstate *h, unsigned long addr, > > > > unsigned long end) > > > > { > > > > - unsigned long boundary = (addr & huge_page_mask(h)) + huge_page_size(h); > > > > - return boundary < end ? boundary : end; > > > > + return min(ALIGN(addr, huge_page_size(h)), end); > > > > } > > > > > > Please drop this patch from the mm-new branch, as it causes > > > 'run_vmtests.sh' to hang. Specifically, it leads to the system hanging > > > when executing hugepage-vmemmap test, because the program falls into an > > > infinite loop in walk_hugetlb_range() and cannot break out. > > > > Good catch! The problem is that ALIGN() returns addr itself when already > > aligned, causing the infinite loop ... > > Using ALIGN(addr + 1, huge_page_size(h)) would work. > Although it could be (addr + 1) & ~huge_page_mask(h) which is probably > the easiest to understand. > Some of the 'helper' macros don't really make the code easier to read. > (And that includes a lot of uses of min().) Or we could go back to my original suggestion. https://lore.kernel.org/linux-mm/aRyOWrARRlUCeEz6@casper.infradead.org/ which was in v2: https://lore.kernel.org/linux-mm/f802959f58865371ba1b10081bced98e3784c5e4.1763796152.git.chandna.sahil@gmail.com/ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary 2025-12-24 18:06 ` Matthew Wilcox @ 2025-12-25 9:32 ` David Hildenbrand (Red Hat) 2025-12-25 10:01 ` David Laight 0 siblings, 1 reply; 11+ messages in thread From: David Hildenbrand (Red Hat) @ 2025-12-25 9:32 UTC (permalink / raw) To: Matthew Wilcox, David Laight Cc: Lance Yang, baolin.wang, Liam.Howlett, akpm, axelrasmussen, chandna.sahil, chengming.zhou, hannes, linux-kernel, linux-mm, lorenzo.stoakes, mhocko, nphamcs, rppt, shakeel.butt, surenb, vbabka, weixugc, yosry.ahmed, yuanchu, zhengqi.arch, Lance Yang On 12/24/25 19:06, Matthew Wilcox wrote: > On Wed, Dec 24, 2025 at 02:08:29PM +0000, David Laight wrote: >>>>> +++ b/mm/pagewalk.c >>>>> @@ -312,8 +312,7 @@ static int walk_pgd_range(unsigned long addr, unsigned long end, >>>>> static unsigned long hugetlb_entry_end(struct hstate *h, unsigned long addr, >>>>> unsigned long end) >>>>> { >>>>> - unsigned long boundary = (addr & huge_page_mask(h)) + huge_page_size(h); >>>>> - return boundary < end ? boundary : end; >>>>> + return min(ALIGN(addr, huge_page_size(h)), end); >>>>> } >>>> >>>> Please drop this patch from the mm-new branch, as it causes >>>> 'run_vmtests.sh' to hang. Specifically, it leads to the system hanging >>>> when executing hugepage-vmemmap test, because the program falls into an >>>> infinite loop in walk_hugetlb_range() and cannot break out. >>> >>> Good catch! The problem is that ALIGN() returns addr itself when already >>> aligned, causing the infinite loop ... >> >> Using ALIGN(addr + 1, huge_page_size(h)) would work. >> Although it could be (addr + 1) & ~huge_page_mask(h) which is probably >> the easiest to understand. >> Some of the 'helper' macros don't really make the code easier to read. >> (And that includes a lot of uses of min().) > > Or we could go back to my original suggestion. > > https://lore.kernel.org/linux-mm/aRyOWrARRlUCeEz6@casper.infradead.org/ > > which was in v2: > > https://lore.kernel.org/linux-mm/f802959f58865371ba1b10081bced98e3784c5e4.1763796152.git.chandna.sahil@gmail.com/ I'm starting to wonder whether we should just leave that code alone :) -- Cheers David ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary 2025-12-25 9:32 ` David Hildenbrand (Red Hat) @ 2025-12-25 10:01 ` David Laight 0 siblings, 0 replies; 11+ messages in thread From: David Laight @ 2025-12-25 10:01 UTC (permalink / raw) To: David Hildenbrand (Red Hat) Cc: Matthew Wilcox, Lance Yang, baolin.wang, Liam.Howlett, akpm, axelrasmussen, chandna.sahil, chengming.zhou, hannes, linux-kernel, linux-mm, lorenzo.stoakes, mhocko, nphamcs, rppt, shakeel.butt, surenb, vbabka, weixugc, yosry.ahmed, yuanchu, zhengqi.arch, Lance Yang On Thu, 25 Dec 2025 10:32:46 +0100 "David Hildenbrand (Red Hat)" <david@kernel.org> wrote: > On 12/24/25 19:06, Matthew Wilcox wrote: > > On Wed, Dec 24, 2025 at 02:08:29PM +0000, David Laight wrote: > >>>>> +++ b/mm/pagewalk.c > >>>>> @@ -312,8 +312,7 @@ static int walk_pgd_range(unsigned long addr, unsigned long end, > >>>>> static unsigned long hugetlb_entry_end(struct hstate *h, unsigned long addr, > >>>>> unsigned long end) > >>>>> { > >>>>> - unsigned long boundary = (addr & huge_page_mask(h)) + huge_page_size(h); > >>>>> - return boundary < end ? boundary : end; > >>>>> + return min(ALIGN(addr, huge_page_size(h)), end); > >>>>> } > >>>> > >>>> Please drop this patch from the mm-new branch, as it causes > >>>> 'run_vmtests.sh' to hang. Specifically, it leads to the system hanging > >>>> when executing hugepage-vmemmap test, because the program falls into an > >>>> infinite loop in walk_hugetlb_range() and cannot break out. > >>> > >>> Good catch! The problem is that ALIGN() returns addr itself when already > >>> aligned, causing the infinite loop ... > >> > >> Using ALIGN(addr + 1, huge_page_size(h)) would work. > >> Although it could be (addr + 1) & ~huge_page_mask(h) which is probably > >> the easiest to understand. > >> Some of the 'helper' macros don't really make the code easier to read. > >> (And that includes a lot of uses of min().) > > > > Or we could go back to my original suggestion. > > > > https://lore.kernel.org/linux-mm/aRyOWrARRlUCeEz6@casper.infradead.org/ > > > > which was in v2: > > > > https://lore.kernel.org/linux-mm/f802959f58865371ba1b10081bced98e3784c5e4.1763796152.git.chandna.sahil@gmail.com/ > > I'm starting to wonder whether we should just leave that code alone :) > Maybe 'we' should stop checkpatch (etc) suggesting min() in trivial cases. It doesn't really make the code better. David ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v4 2/3] mm/vmscan: use %pe to print error pointers 2025-11-28 7:01 [PATCH v4 0/3] mm: Coccinelle-driven cleanups across memory management code Sahil Chandna 2025-11-28 7:01 ` [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary calculation Sahil Chandna @ 2025-11-28 7:01 ` Sahil Chandna 2025-11-28 7:01 ` [PATCH v4 3/3] mm/zswap: " Sahil Chandna 2 siblings, 0 replies; 11+ messages in thread From: Sahil Chandna @ 2025-11-28 7:01 UTC (permalink / raw) To: akpm, david, lorenzo.stoakes, mhocko, vbabka, rppt, surenb, hannes, shakeel.butt, zhengqi.arch, Liam.Howlett, weixugc, axelrasmussen, yuanchu, yosry.ahmed, nphamcs, chengming.zhou, linux-mm, linux-kernel Cc: david, Sahil Chandna, SeongJae Park Use the %pe printk format specifier to report error pointers directly instead of printing PTR_ERR() as a long value. This improves clarity, produces more readable error messages. This instance was flagged by the Coccinelle script (misc/ptr_err_to_pe.cocci) as an opportunity to adopt %pe. Found by: make coccicheck MODE=report M=mm/ No functional change intended Acked-by: David Hildenbrand (Red Hat) <david@kernel.org> Reviewed-by: SeongJae Park <sj@kernel.org> Signed-off-by: Sahil Chandna <chandna.sahil@gmail.com> --- changes since v2: - Add Acked-by tag link to v2: https://lore.kernel.org/all/64e15c6b2ce86d7824f54e9e001b6f5b44af48b8.1763796152.git.chandna.sahil@gmail.com/ link to v3: https://lore.kernel.org/all/db049e564cafcb0913bee930d6a577ea43044f5b.1764177933.git.chandna.sahil@gmail.com/ --- mm/vmscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index b2fc8b626d3d..29ed0b304b5c 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -7500,8 +7500,8 @@ void __meminit kswapd_run(int nid) pgdat->kswapd = kthread_create_on_node(kswapd, pgdat, nid, "kswapd%d", nid); if (IS_ERR(pgdat->kswapd)) { /* failure at boot is fatal */ - pr_err("Failed to start kswapd on node %d,ret=%ld\n", - nid, PTR_ERR(pgdat->kswapd)); + pr_err("Failed to start kswapd on node %d, ret=%pe\n", + nid, pgdat->kswapd); BUG_ON(system_state < SYSTEM_RUNNING); pgdat->kswapd = NULL; } else { -- 2.50.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v4 3/3] mm/zswap: use %pe to print error pointers 2025-11-28 7:01 [PATCH v4 0/3] mm: Coccinelle-driven cleanups across memory management code Sahil Chandna 2025-11-28 7:01 ` [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary calculation Sahil Chandna 2025-11-28 7:01 ` [PATCH v4 2/3] mm/vmscan: use %pe to print error pointers Sahil Chandna @ 2025-11-28 7:01 ` Sahil Chandna 2 siblings, 0 replies; 11+ messages in thread From: Sahil Chandna @ 2025-11-28 7:01 UTC (permalink / raw) To: akpm, david, lorenzo.stoakes, mhocko, vbabka, rppt, surenb, hannes, shakeel.butt, zhengqi.arch, Liam.Howlett, weixugc, axelrasmussen, yuanchu, yosry.ahmed, nphamcs, chengming.zhou, linux-mm, linux-kernel Cc: david, Sahil Chandna, SeongJae Park Use the %pe printk format specifier to report error pointers directly instead of printing PTR_ERR() as a long value. This improves clarity, produces more readable error messages. This instance was flagged by the Coccinelle script (misc/ptr_err_to_pe.cocci) as an opportunity to adopt %pe. Found by: make coccicheck MODE=report M=mm/ No functional change intended. Acked-by: Yosry Ahmed <yosry.ahmed@linux.dev> Acked-by: Nhat Pham <nphamcs@gmail.com> Acked-by: David Hildenbrand (Red Hat) <david@kernel.org> Reviewed-by: SeongJae Park <sj@kernel.org> Signed-off-by: Sahil Chandna <chandna.sahil@gmail.com> --- Changes since v2: - Add Acked-by tag. link to v2: https://lore.kernel.org/all/0c00ceedce6e0d9aed35cee5faf15fd9126a1f70.1763796152.git.chandna.sahil@gmail.com/ link to v3: https://lore.kernel.org/all/57b7205813aa87c8f5c8bf765e5a8d88daeba68f.1764177933.git.chandna.sahil@gmail.com/ --- mm/zswap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index c1af782e54ec..c35604db32ad 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -749,8 +749,8 @@ static int zswap_cpu_comp_prepare(unsigned int cpu, struct hlist_node *node) acomp = crypto_alloc_acomp_node(pool->tfm_name, 0, 0, cpu_to_node(cpu)); if (IS_ERR(acomp)) { - pr_err("could not alloc crypto acomp %s : %ld\n", - pool->tfm_name, PTR_ERR(acomp)); + pr_err("could not alloc crypto acomp %s : %pe\n", + pool->tfm_name, acomp); ret = PTR_ERR(acomp); goto fail; } -- 2.50.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-12-25 11:48 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-11-28 7:01 [PATCH v4 0/3] mm: Coccinelle-driven cleanups across memory management code Sahil Chandna 2025-11-28 7:01 ` [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary calculation Sahil Chandna 2025-12-24 7:50 ` Baolin Wang 2025-12-24 9:23 ` [PATCH v4 1/3] mm: pagewalk: simplify hugepage boundary Lance Yang 2025-12-24 12:46 ` Sahil Chandna 2025-12-24 14:08 ` David Laight 2025-12-24 18:06 ` Matthew Wilcox 2025-12-25 9:32 ` David Hildenbrand (Red Hat) 2025-12-25 10:01 ` David Laight 2025-11-28 7:01 ` [PATCH v4 2/3] mm/vmscan: use %pe to print error pointers Sahil Chandna 2025-11-28 7:01 ` [PATCH v4 3/3] mm/zswap: " Sahil Chandna
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox