Re: [PATCH] mm: fix invalid node in alloc_migrate_target()

From: Vlastimil Babka
Date: Tue Mar 29 2016 - 08:21:14 EST

On 03/29/2016 12:37 PM, Xishi Qiu wrote:
On 2016/3/29 17:52, Vlastimil Babka wrote:
The code in this functions seems to come from 099730d67417d ("mm, hugetlb: use memory policy when available") by Dave Hansen (adding to CC), which was indeed merged in 4.4-rc1.

However, alloc_pages_node() is only called in the block guarded by:

if (!IS_ENABLED(CONFIG_NUMA) || !vma) {

The rather weird "!IS_ENABLED(CONFIG_NUMA)" part comes from immediate followup commit e0ec90ee7e6f ("mm, hugetlbfs: optimize when NUMA=n")

So I doubt the code path here can actually happen. But it's fragile and confusing nevertheless.

Hi Vlastimil

__alloc_buddy_huge_page(h, NULL, addr, nid); // so the vma is NULL

Hm that's true, I got lost in the logic, thanks.
But the problem with dequeue_huge_page_node() is also IMHO true, and older, so we should fix 3.12+.