Re: [PATCH 1/2] mm: Make alloc_contig_range handle free hugetlb pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri 19-02-21 12:17:11, Oscar Salvador wrote:
> On Fri, Feb 19, 2021 at 11:55:00AM +0100, Michal Hocko wrote:
> > It is not the lock that I care about but more about counters. The
> > intention was that there is a single place to handle both enqueing and
> > dequeing. As not all places require counters to be updated. E.g. the
> > migration which just replaces one page by another.
> 
> I see.
> alloc_fresh_huge_page->prep_new_huge_page increments h->nr_huge_pages{_node}
> counters.
> Which means:
> 
> >       new_page = alloc_fresh_huge_page();
> >       if (!new_page)
> >               goto fail;
> >       spin_lock(hugetlb_lock);
> >       if (!PageHuge(old_page)) {
> >               /* freed from under us, nothing to do */ 
> >               __update_and_free_page(new_page);
> 
> Here we need update_and_free_page, otherwise we would be leaving a stale value
> in h->nr_huge_pages{_node}. 
> 
> >               goto unlock;
> >       }
> >       list_del(&old_page->lru);
> >       __update_and_free_page(old_page);
> 
> Same here.
> 
> >       __enqueue_huge_page(new_page);
> 
> This is ok since h->free_huge_pages{_node} do not need to be updated.

Fair enough. I didn't get to think this through obviously, but you
should get the idea ;)
-- 
Michal Hocko
SUSE Labs




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux