Subject: Question on follow_page_mask

From: Anshuman Khandual <[email-masked]>
Date: Tue, 23 Feb 2016 18:45:05 +0530

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.
Thank you.

Regards
Anshuman