linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/numa_memblks: Use SZ_1M macro to denote bytes to MB conversion
@ 2025-08-19  8:51 pratyush.brahma
  2025-08-19 14:41 ` Mike Rapoport
  0 siblings, 1 reply; 3+ messages in thread
From: pratyush.brahma @ 2025-08-19  8:51 UTC (permalink / raw)
  To: Andrew Morton, Mike Rapoport; +Cc: linux-mm, linux-kernel, Pratyush Brahma

From: Pratyush Brahma <pratyush.brahma@oss.qualcomm.com>

Replace the manual bitwise conversion of bytes to MB with
SZ_1M macro, a standard macro used within the mm subsystem,
to improve readability.

Signed-off-by: Pratyush Brahma <pratyush.brahma@oss.qualcomm.com>
---
 mm/numa_memblks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c
index 541a99c4071a67e5b0ef66f4136dee268a880003..a47aa262a33366337c38ccc7c7064da818523dd2 100644
--- a/mm/numa_memblks.c
+++ b/mm/numa_memblks.c
@@ -427,9 +427,9 @@ static int __init numa_register_meminfo(struct numa_meminfo *mi)
 		unsigned long pfn_align = node_map_pfn_alignment();
 
 		if (pfn_align && pfn_align < PAGES_PER_SECTION) {
-			unsigned long node_align_mb = PFN_PHYS(pfn_align) >> 20;
+			unsigned long node_align_mb = PFN_PHYS(pfn_align) / SZ_1M;
 
-			unsigned long sect_align_mb = PFN_PHYS(PAGES_PER_SECTION) >> 20;
+			unsigned long sect_align_mb = PFN_PHYS(PAGES_PER_SECTION) / SZ_1M;
 
 			pr_warn("Node alignment %luMB < min %luMB, rejecting NUMA config\n",
 				node_align_mb, sect_align_mb);

---
base-commit: c17b750b3ad9f45f2b6f7e6f7f4679844244f0b9
change-id: 20250819-numa-memblks-refac-7b4b5017b598

Best regards,
-- 
Pratyush Brahma <pratyush.brahma@oss.qualcomm.com>



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

* Re: [PATCH] mm/numa_memblks: Use SZ_1M macro to denote bytes to MB conversion
  2025-08-19  8:51 [PATCH] mm/numa_memblks: Use SZ_1M macro to denote bytes to MB conversion pratyush.brahma
@ 2025-08-19 14:41 ` Mike Rapoport
  2025-08-20  0:39   ` Pratyush Brahma
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Rapoport @ 2025-08-19 14:41 UTC (permalink / raw)
  To: pratyush.brahma; +Cc: Andrew Morton, linux-mm, linux-kernel

On Tue, Aug 19, 2025 at 02:21:44PM +0530, pratyush.brahma@oss.qualcomm.com wrote:
> From: Pratyush Brahma <pratyush.brahma@oss.qualcomm.com>
> 
> Replace the manual bitwise conversion of bytes to MB with
> SZ_1M macro, a standard macro used within the mm subsystem,
> to improve readability.

There are few others:

$ git grep '>> 20' mm/
mm/memblock.c:          mem_size_mb = memblock_phys_mem_size() >> 20;
mm/memblock.c:                 (nr_pages << PAGE_SHIFT) >> 20, mem_size_mb);
mm/numa_emulation.c:           nid, eb->start, eb->end - 1, (eb->end - eb->start) >> 20);
mm/numa_emulation.c:                    size >> 20, min_size >> 20);

It makes sense to replace all of them in one patch.
 
> Signed-off-by: Pratyush Brahma <pratyush.brahma@oss.qualcomm.com>
> ---
>  mm/numa_memblks.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c
> index 541a99c4071a67e5b0ef66f4136dee268a880003..a47aa262a33366337c38ccc7c7064da818523dd2 100644
> --- a/mm/numa_memblks.c
> +++ b/mm/numa_memblks.c
> @@ -427,9 +427,9 @@ static int __init numa_register_meminfo(struct numa_meminfo *mi)
>  		unsigned long pfn_align = node_map_pfn_alignment();
>  
>  		if (pfn_align && pfn_align < PAGES_PER_SECTION) {
> -			unsigned long node_align_mb = PFN_PHYS(pfn_align) >> 20;
> +			unsigned long node_align_mb = PFN_PHYS(pfn_align) / SZ_1M;
>  
> -			unsigned long sect_align_mb = PFN_PHYS(PAGES_PER_SECTION) >> 20;
> +			unsigned long sect_align_mb = PFN_PHYS(PAGES_PER_SECTION) / SZ_1M;
>  
>  			pr_warn("Node alignment %luMB < min %luMB, rejecting NUMA config\n",
>  				node_align_mb, sect_align_mb);
> 
> ---
> base-commit: c17b750b3ad9f45f2b6f7e6f7f4679844244f0b9
> change-id: 20250819-numa-memblks-refac-7b4b5017b598
> 
> Best regards,
> -- 
> Pratyush Brahma <pratyush.brahma@oss.qualcomm.com>
> 

-- 
Sincerely yours,
Mike.


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

* Re: [PATCH] mm/numa_memblks: Use SZ_1M macro to denote bytes to MB conversion
  2025-08-19 14:41 ` Mike Rapoport
@ 2025-08-20  0:39   ` Pratyush Brahma
  0 siblings, 0 replies; 3+ messages in thread
From: Pratyush Brahma @ 2025-08-20  0:39 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: Andrew Morton, linux-mm, linux-kernel

On Tue, Aug 19, 2025 at 8:11 PM Mike Rapoport <rppt@kernel.org> wrote:
>
> On Tue, Aug 19, 2025 at 02:21:44PM +0530, pratyush.brahma@oss.qualcomm.com wrote:
> > From: Pratyush Brahma <pratyush.brahma@oss.qualcomm.com>
> >
> > Replace the manual bitwise conversion of bytes to MB with
> > SZ_1M macro, a standard macro used within the mm subsystem,
> > to improve readability.
>
> There are few others:
>
> $ git grep '>> 20' mm/
> mm/memblock.c:          mem_size_mb = memblock_phys_mem_size() >> 20;
> mm/memblock.c:                 (nr_pages << PAGE_SHIFT) >> 20, mem_size_mb);
> mm/numa_emulation.c:           nid, eb->start, eb->end - 1, (eb->end - eb->start) >> 20);
> mm/numa_emulation.c:                    size >> 20, min_size >> 20);
>
> It makes sense to replace all of them in one patch.
Thanks for checking. Will send an updated patch in the next iteration.
>
> > Signed-off-by: Pratyush Brahma <pratyush.brahma@oss.qualcomm.com>
> > ---
> >  mm/numa_memblks.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c
> > index 541a99c4071a67e5b0ef66f4136dee268a880003..a47aa262a33366337c38ccc7c7064da818523dd2 100644
> > --- a/mm/numa_memblks.c
> > +++ b/mm/numa_memblks.c
> > @@ -427,9 +427,9 @@ static int __init numa_register_meminfo(struct numa_meminfo *mi)
> >               unsigned long pfn_align = node_map_pfn_alignment();
> >
> >               if (pfn_align && pfn_align < PAGES_PER_SECTION) {
> > -                     unsigned long node_align_mb = PFN_PHYS(pfn_align) >> 20;
> > +                     unsigned long node_align_mb = PFN_PHYS(pfn_align) / SZ_1M;
> >
> > -                     unsigned long sect_align_mb = PFN_PHYS(PAGES_PER_SECTION) >> 20;
> > +                     unsigned long sect_align_mb = PFN_PHYS(PAGES_PER_SECTION) / SZ_1M;
> >
> >                       pr_warn("Node alignment %luMB < min %luMB, rejecting NUMA config\n",
> >                               node_align_mb, sect_align_mb);
> >
> > ---
> > base-commit: c17b750b3ad9f45f2b6f7e6f7f4679844244f0b9
> > change-id: 20250819-numa-memblks-refac-7b4b5017b598
> >
> > Best regards,
> > --
> > Pratyush Brahma <pratyush.brahma@oss.qualcomm.com>
> >
>
> --
> Sincerely yours,
> Mike.
Thanks & Regards
Pratyush


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

end of thread, other threads:[~2025-08-20  0:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-19  8:51 [PATCH] mm/numa_memblks: Use SZ_1M macro to denote bytes to MB conversion pratyush.brahma
2025-08-19 14:41 ` Mike Rapoport
2025-08-20  0:39   ` Pratyush Brahma

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