[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YC+ZBIwXKEZCy1Bk@dhcp22.suse.cz>
Date: Fri, 19 Feb 2021 11:55:00 +0100
From: Michal Hocko <mhocko@...e.com>
To: Oscar Salvador <osalvador@...e.de>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Mike Kravetz <mike.kravetz@...cle.com>,
David Hildenbrand <david@...hat.com>,
Muchun Song <songmuchun@...edance.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] mm: Make alloc_contig_range handle free hugetlb pages
On Fri 19-02-21 11:40:30, Oscar Salvador wrote:
> On Fri, Feb 19, 2021 at 10:56:42AM +0100, Michal Hocko wrote:
> > OK, this should work but I am really wondering whether it wouldn't be
> > just simpler to replace the old page by a new one in the free list
> > directly. Or is there any reason we have to go through the generic
> > helpers path? I mean something like this
> >
> > 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);
> > goto unlock;
> > }
> > list_del(&old_page->lru);
> > __update_and_free_page(old_page);
> > __enqueue_huge_page(new_page);
> > unlock:
> > spin_unlock(hugetlb_lock);
> >
> > This will require to split update_and_free_page and enqueue_huge_page to
> > counters independent parts but that shouldn't be a big deal. But it will
> > also protect from any races. Not an act of beauty but seems less hackish
> > to me.
>
> On a closer look, do we really need to decouple update_and_free_page and
> enqueue_huge_page? These two functions do not handle the lock, but rather
> the functions that call them (as would be in our case).
> Only update_and_free_page drops the lock during the freeing of a gigantic page
> and then it takes it again, as the caller is who took the lock.
>
> am I missing anything obvious here?
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.
--
Michal Hocko
SUSE Labs
Powered by blists - more mailing lists