Re: [PATCH -next] mm: page_alloc: simplify has_managed_dma()

From: Kefeng Wang
Date: Tue May 30 2023 - 02:40:23 EST

On 2023/5/30 12:18, Baoquan He wrote:
On 05/30/23 at 10:10am, Kefeng Wang wrote:

On 2023/5/29 22:26, Matthew Wilcox wrote:
On Mon, May 29, 2023 at 10:40:22PM +0800, Kefeng Wang wrote:
The ZONE_DMA should only exists on Node 0, only check NODE_DATA(0)
is enough, so simplify has_managed_dma() and make it inline.

That's true on x86, but is it true on all architectures?

There is no document about numa node info for the DMA_ZONE, + Mike

I used 'git grep -w ZONE_DMA arch/'

willy is right. max_zone_pfn can only limit the range of zone, but
can't decide which zone is put on which node. The memory layout is
decided by firmware. I searched commit log to get below commit which
can give a good example.

commit c1d0da83358a2316d9be7f229f26126dbaa07468
Author: Laurent Dufour <ldufour@xxxxxxxxxxxxx>
Date: Fri Sep 25 21:19:28 2020 -0700

mm: replace memmap_context by meminit_context
Patch series "mm: fix memory to node bad links in sysfs", v3.
Sometimes, firmware may expose interleaved memory layout like this:
Early memory node ranges
node 1: [mem 0x0000000000000000-0x000000011fffffff]
node 2: [mem 0x0000000120000000-0x000000014fffffff]
node 1: [mem 0x0000000150000000-0x00000001ffffffff]
node 0: [mem 0x0000000200000000-0x000000048fffffff]
node 2: [mem 0x0000000490000000-0x00000007ffffffff]

Oh, it looks strange, but it do occur if firmware report as this way.

Thanks Willy and Baoquan, please ignore the patch.