<div dir="ltr"><div>As per the documentation(<a href="https://elixir.bootlin.com/linux/latest/source/include/linux/gfp.h#L292">https://elixir.bootlin.com/linux/latest/source/include/linux/gfp.h#L292</a>), which says: <br></div><div><span style="color:rgb(85,119,153);font-family:"Ubuntu Mono",monospace;font-size:0.9em">#define </span><a href="https://elixir.bootlin.com/linux/latest/C/ident/GFP_KERNEL" style="font-family:"Ubuntu Mono",monospace;font-size:0.9em;box-sizing:inherit;background-color:rgb(244,246,255);color:inherit;text-decoration-line:none;font-weight:700;border-radius:0.2em">GFP_KERNEL</a><span style="color:rgb(85,119,153);font-family:"Ubuntu Mono",monospace;font-size:0.9em">      (</span><a href="https://elixir.bootlin.com/linux/latest/C/ident/__GFP_RECLAIM" style="font-family:"Ubuntu Mono",monospace;font-size:0.9em;box-sizing:inherit;background-color:rgb(244,246,255);color:inherit;text-decoration-line:none;font-weight:700;border-radius:0.2em">__GFP_RECLAIM</a><span style="color:rgb(85,119,153);font-family:"Ubuntu Mono",monospace;font-size:0.9em"> | </span><a href="https://elixir.bootlin.com/linux/latest/C/ident/__GFP_IO" style="font-family:"Ubuntu Mono",monospace;font-size:0.9em;box-sizing:inherit;background-color:rgb(244,246,255);color:inherit;text-decoration-line:none;font-weight:700;border-radius:0.2em">__GFP_IO</a><span style="color:rgb(85,119,153);font-family:"Ubuntu Mono",monospace;font-size:0.9em"> | </span><a href="https://elixir.bootlin.com/linux/latest/C/ident/__GFP_FS" style="font-family:"Ubuntu Mono",monospace;font-size:0.9em;box-sizing:inherit;background-color:rgb(244,246,255);color:inherit;text-decoration-line:none;font-weight:700;border-radius:0.2em">__GFP_FS</a><span style="color:rgb(85,119,153);font-family:"Ubuntu Mono",monospace;font-size:0.9em">).</span></div><div>It does not explicitly bind the option of <i>GFP_KERNEL </i>to any of the physical address zone modifiers(i.e. __GFP_DMA,__GFP_HIGHMEM,__GFP_DMA32,__GFP_MOVABLE,GFP_ZONEMASK) indeed.<br></div><span style="color:rgb(85,119,153);font-family:"Ubuntu Mono",monospace;font-size:0.9em">     </span><div><br></div><div>And there are free blocks in "Node 0 DMA" indeed. For your convenience, the most related log is seen below:</div><div><i>[22041.387948] Node 0 DMA: 3*4kB (U) 3*8kB (U) 1*16kB (U) 1*32kB (U) 3*64kB (U) 0*128kB 1*256kB (U) 0*512kB 1*1024kB (U) 1*2048kB (M) 3*4096kB (M) = 15892kB<br>[22041.387990] Node 0 DMA32: 14912*4kB (UME) 13850*8kB (UME) 9325*16kB (UME) 5961*32kB (UME) 3622*64kB (UME) 2359*128kB (UME) 1128*256kB (UME) 524*512kB (M) 194*1024kB (UM) 0*2048kB 0*4096kB = 1799872kB<br>[22041.388033] Node 0 Normal: 1643*4kB (UME) 71*8kB (UME) 47*16kB (UM) 35*32kB (M) 38*64kB (M) 1*128kB (M) 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 11572kB  </i><br></div><div><br></div><div>Here is the implementation of the function <i>kzalloc(</i>refer to <a href="https://elixir.bootlin.com/linux/latest/source/include/linux/slab.h#L667">https://elixir.bootlin.com/linux/latest/source/include/linux/slab.h#L667</a><i>)</i>:</div><div><pre class="gmail-cye-lm-tag" style="box-sizing:inherit;font-family:"Ubuntu Mono",monospace;font-size:0.9em;line-height:1.2;padding:1em 0px 4em 1em;color:rgb(0,0,0);margin-top:0px;margin-bottom:0px;min-height:100%;word-break:normal"><span class="gmail-cm gmail-cye-lm-tag" style="box-sizing:inherit;color:slategray;font-style:italic">/**</span>
<span class="gmail-cm gmail-cye-lm-tag" style="box-sizing:inherit;color:slategray;font-style:italic"> * kzalloc - allocate memory. The memory is set to zero.</span>
<span class="gmail-cm gmail-cye-lm-tag" style="box-sizing:inherit;color:slategray;font-style:italic"> * @size: how many bytes of memory are required.</span>
<span class="gmail-cm gmail-cye-lm-tag" style="box-sizing:inherit;color:slategray;font-style:italic"> * @flags: the type of memory to allocate (see kmalloc).</span>
<span class="gmail-cm gmail-cye-lm-tag" style="box-sizing:inherit;color:slategray;font-style:italic"> */</span>
<span class="gmail-k gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(0,136,0)">static</span> <span class="gmail-kr gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(0,136,0)">inline</span> <span class="gmail-kt gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(51,51,153)">void</span> <span class="gmail-o gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(102,102,102)">*</span><span class="gmail-nf gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(0,102,187)"><a href="https://elixir.bootlin.com/linux/latest/C/ident/kzalloc" style="box-sizing:inherit;background-color:rgb(244,246,255);color:inherit;text-decoration-line:none;font-weight:700;border-radius:0.2em">kzalloc</a></span><span class="gmail-p gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(102,102,102)">(</span><span class="gmail-n gmail-cye-lm-tag" style="box-sizing:inherit"><a href="https://elixir.bootlin.com/linux/latest/C/ident/size_t" style="box-sizing:inherit;background-color:rgb(244,246,255);color:inherit;text-decoration-line:none;font-weight:700;border-radius:0.2em">size_t</a></span> <span class="gmail-n gmail-cye-lm-tag" style="box-sizing:inherit">size</span><span class="gmail-p gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(102,102,102)">,</span> <span class="gmail-n gmail-cye-lm-tag" style="box-sizing:inherit"><a href="https://elixir.bootlin.com/linux/latest/C/ident/gfp_t" style="box-sizing:inherit;background-color:rgb(244,246,255);color:inherit;text-decoration-line:none;font-weight:700;border-radius:0.2em">gfp_t</a></span> <span class="gmail-n gmail-cye-lm-tag" style="box-sizing:inherit">flags</span><span class="gmail-p gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(102,102,102)">)</span>
<span class="gmail-p gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(102,102,102)">{</span>
        <span class="gmail-k gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(0,136,0)">return</span> <span class="gmail-n gmail-cye-lm-tag" style="box-sizing:inherit"><a href="https://elixir.bootlin.com/linux/latest/C/ident/kmalloc" style="box-sizing:inherit;background-color:rgb(244,246,255);color:inherit;text-decoration-line:none;font-weight:700;border-radius:0.2em">kmalloc</a></span><span class="gmail-p gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(102,102,102)">(</span><span class="gmail-n gmail-cye-lm-tag" style="box-sizing:inherit">size</span><span class="gmail-p gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(102,102,102)">,</span> <span class="gmail-n gmail-cye-lm-tag" style="box-sizing:inherit">flags</span> <span class="gmail-o gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(102,102,102)">|</span> <span class="gmail-n gmail-cye-lm-tag" style="box-sizing:inherit"><a href="https://elixir.bootlin.com/linux/latest/C/ident/__GFP_ZERO" style="box-sizing:inherit;background-color:rgb(244,246,255);color:inherit;text-decoration-line:none;font-weight:700;border-radius:0.2em">__GFP_ZERO</a></span><span class="gmail-p gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(102,102,102)">);</span>
<span class="gmail-p gmail-cye-lm-tag" style="box-sizing:inherit;color:rgb(102,102,102)">}</span></pre></div><div>So I wonder why the kernel did not use the memory block contained by "Node 0 DMA" while the argument of kzalloc() is "GFP_KERNEL".</div><div>I heard a saying is that the Linux kernel "will" search the "normal zone" first, then the "DMA32 zone", and "DMA zone" while there is no "physical address zone modifier" is explicitly declared. </div><div>I have googled it for a long time. But I still could understand why this occurs. I would be grateful to have some help with it.</div><div><br></div><div><br></div><div><b>Here is the whole log:</b></div><div>[22041.387673] HelloWorldExamp: page allocation failure: order:9, mode:0x60c0c0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null)<br>[22041.387678] HelloWorldExamp cpuset=/ mems_allowed=0<br>[22041.387690] CPU: 3 PID: 27737 Comm: HelloWorldExamp Not tainted 4.19.84-bros #5<br>[22041.387693] Hardware name: Advantech UNO-2372G-J021AE/UNO-2372G-J021AE, BIOS 5.6.5 09/04/2019<br>[22041.387695] I-pipe domain: Linux<br>[22041.387697] Call Trace:<br>[22041.387711]  dump_stack+0x9e/0xc8<br>[22041.387718]  warn_alloc+0x100/0x190<br>[22041.387725]  __alloc_pages_slowpath+0xb93/0xbd0<br>[22041.387732]  __alloc_pages_nodemask+0x26d/0x2b0<br>[22041.387739]  alloc_pages_current+0x6a/0xe0<br>[22041.387744]  kmalloc_order+0x18/0x40<br>[22041.387748]  kmalloc_order_trace+0x24/0xb0<br>[22041.387754]  __kmalloc+0x20e/0x230<br>[22041.387759]  ? __vmalloc_node_range+0x171/0x250<br>[22041.387765]  xnheap_init+0x87/0x200<br>[22041.387770]  ? remove_process+0xc0/0xc0<br>[22041.387775]  cobalt_umm_init+0x61/0xb0<br>[22041.387779]  cobalt_process_attach+0x64/0x4c0<br>[22041.387784]  ? snprintf+0x45/0x70<br>[22041.387790]  ? security_capable+0x46/0x60<br>[22041.387794]  bind_personality+0x5a/0x120<br>[22041.387798]  cobalt_bind_core+0x27/0x60<br>[22041.387803]  CoBaLt_bind+0x18a/0x1d0<br>[22041.387812]  ? handle_head_syscall+0x3f0/0x3f0<br>[22041.387816]  ipipe_syscall_hook+0x119/0x340<br>[22041.387822]  __ipipe_notify_syscall+0xd3/0x190<br>[22041.387827]  ? __x64_sys_rt_sigaction+0x7b/0xd0<br>[22041.387832]  ipipe_handle_syscall+0x3e/0xc0<br>[22041.387837]  do_syscall_64+0x3b/0x250<br>[22041.387842]  entry_SYSCALL_64_after_hwframe+0x44/0xa9<br>[22041.387847] RIP: 0033:0x7ff3d074e481<br>[22041.387852] Code: 89 c6 48 8b 05 10 6b 21 00 c7 04 24 00 00 00 a4 8b 38 85 ff 75 43 bb 00 00 00 10 c7 44 24 04 11 00 00 00 48 89 e7 89 d8 0f 05 <bf> 04 00 00 00 48 89 c3 e8 e2 e0 ff ff 8d 53 26 83 fa 26 0f 87 46<br>[22041.387855] RSP: 002b:00007ffc62caf210 EFLAGS: 00000246 ORIG_RAX: 0000000010000000<br>[22041.387860] RAX: ffffffffffffffda RBX: 0000000010000000 RCX: 00007ff3d074e481<br>[22041.387863] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00007ffc62caf210<br>[22041.387865] RBP: 00007ff3d20a3780 R08: 00007ffc62caf160 R09: 0000000000000000<br>[22041.387868] R10: 0000000000000008 R11: 0000000000000246 R12: 00007ff3d0965b00<br>[22041.387870] R13: 0000000001104320 R14: 00007ff3d0965d40 R15: 0000000001104050<br>[22041.387876] Mem-Info:<br>[22041.387885] active_anon:56054 inactive_anon:109301 isolated_anon:0<br>                active_file:110190 inactive_file:91980 isolated_file:0<br>                unevictable:9375 dirty:1 writeback:0 unstable:0<br>                slab_reclaimable:22463 slab_unreclaimable:19122<br>                mapped:101678 shmem:25642 pagetables:7663 bounce:0<br>                free:456443 free_pcp:0 free_cma:0<br>[22041.387891] Node 0 active_anon:224216kB inactive_anon:437204kB active_file:440760kB inactive_file:367920kB unevictable:37500kB isolated(anon):0kB isolated(file):0kB mapped:406712kB dirty:4kB writeback:0kB shmem:102568kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no<br>[22041.387893] Node 0 DMA free:15892kB min:32kB low:44kB high:56kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:15992kB managed:15892kB mlocked:0kB kernel_stack:0kB pagetables:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB<br>[22041.387901] lowmem_reserve[]: 0 2804 3762 3762<br>[22041.387912] Node 0 DMA32 free:1798624kB min:5836kB low:8704kB high:11572kB active_anon:188040kB inactive_anon:219400kB active_file:184156kB inactive_file:346776kB unevictable:24900kB writepending:0kB present:3017476kB managed:2927216kB mlocked:24900kB kernel_stack:1712kB pagetables:7564kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB<br>[22041.387920] lowmem_reserve[]: 0 0 958 958<br>[22041.387930] Node 0 Normal free:11256kB min:1992kB low:2972kB high:3952kB active_anon:36084kB inactive_anon:218100kB active_file:257220kB inactive_file:21148kB unevictable:12600kB writepending:4kB present:1048576kB managed:981268kB mlocked:12600kB kernel_stack:5280kB pagetables:23088kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB<br>[22041.387938] lowmem_reserve[]: 0 0 0 0<br>[22041.387948] Node 0 DMA: 3*4kB (U) 3*8kB (U) 1*16kB (U) 1*32kB (U) 3*64kB (U) 0*128kB 1*256kB (U) 0*512kB 1*1024kB (U) 1*2048kB (M) 3*4096kB (M) = 15892kB<br>[22041.387990] Node 0 DMA32: 14912*4kB (UME) 13850*8kB (UME) 9325*16kB (UME) 5961*32kB (UME) 3622*64kB (UME) 2359*128kB (UME) 1128*256kB (UME) 524*512kB (M) 194*1024kB (UM) 0*2048kB 0*4096kB = 1799872kB<br>[22041.388033] Node 0 Normal: 1643*4kB (UME) 71*8kB (UME) 47*16kB (UM) 35*32kB (M) 38*64kB (M) 1*128kB (M) 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 11572kB<br>[22041.388071] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB<br>[22041.388073] 232507 total pagecache pages<br>[22041.388077] 7 pages in swap cache<br>[22041.388079] Swap cache stats: add 1015, delete 1008, find 0/1<br>[22041.388081] Free swap  = 995068kB<br>[22041.388083] Total swap = 999420kB<br>[22041.388086] 1020511 pages RAM<br>[22041.388088] 0 pages HighMem/MovableOnly<br>[22041.388090] 39417 pages reserved<br>[22041.388092] 0 pages hwpoisoned<br></div></div>