On Mon, Jul 20, 2020 at 04:46:03PM -0600, Alex Williamson wrote: > > + /* > > + * We got a hugetlbfs page using vaddr_get_pfn alreadly. > > + * In this case,we do not need to alloc pages and we can finish all > > + * work by a single operation to the head page. > > + */ > > + lock_acct += contiguous_npage; > > + head = compound_head(pfn_to_page(*pfn_base)); > > + atomic_add(contiguous_npage, compound_pincount_ptr(head)); > > + page_ref_add(head, contiguous_npage); > > + mod_node_page_state(page_pgdat(head), NR_FOLL_PIN_ACQUIRED, contiguous_npage); > > + pinned += contiguous_npage; > > + goto out; > > I'm hoping Peter or Andrea understand this, but I think we still have > pfn_base pinned separately and I don't see that we've done an unpin > anywhere, so are we leaking the pin of the first page?? I'm not very familiar with that either, however it seems to me most of above chunk was already done in the gup core. For hugetlbfs, imho it should be where follow_hugetlb_page() calls try_grab_page(). Thanks, -- Peter Xu