lkml.org 
[lkml]   [2021]   [Feb]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] mm: Make alloc_contig_range handle free hugetlb pages
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.

--
Oscar Salvador
SUSE L3

\
 
 \ /
  Last update: 2021-02-19 12:19    [W:0.052 / U:0.640 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site