Subject: Re: Question on follow_page_mask

From: Anshuman Khandual <[email-masked]>
Date: Wed, 24 Feb 2016 16:52:30 +0530

On 02/23/2016 07:33 PM, Kirill A. Shutemov wrote:
> On Tue, Feb 23, 2016 at 06:45:05PM +0530, Anshuman Khandual wrote:
>> Not able to understand the first code block of follow_page_mask
>> function. follow_huge_addr function is expected to find the page
>> struct for the given address if it turns out to be a HugeTLB page
>> but then when it finds the page we bug on if it had been called
>> with FOLL_GET flag.
>>
>> 	page = follow_huge_addr(mm, address, flags & FOLL_WRITE);
>> 	if (!IS_ERR(page)) {
>> 		BUG_ON(flags & FOLL_GET);
>> 		return page;
>> 	}
>>
>> do_move_page_to_node_array calls follow_page with FOLL_GET which
>> in turn calls follow_page_mask with FOLL_GET. On POWER, the
>> function follow_huge_addr is defined and does not return -EINVAL
>> like the generic one. It returns the page struct if its a HugeTLB
>> page. Just curious to know what is the purpose behind the BUG_ON.
> 
> I would guess requesting pin on non-reclaimable page is considered
> useless, meaning suspicius behavior. BUG_ON() is overkill, I think.
> WARN_ON_ONCE() would make it.

pin on non-reclaimable page ? I thought the page reference is obtained
for page migration purpose only. I may be missing something here.

> 
> Not that this follow_huge_addr() on Power is not reachable via
> do_move_page_to_node_array(), because the vma is !vma_is_migratable().

Was experimenting with that enabled via ARCH_ENABLE_HUGEPAGE_MIGRATION.