lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YC5jFrwegRVkMkBQ@dhcp22.suse.cz>
Date:   Thu, 18 Feb 2021 13:52:38 +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 Thu 18-02-21 11:09:17, Oscar Salvador wrote:
> On Wed, Feb 17, 2021 at 04:00:11PM +0100, Michal Hocko wrote:
> > Is this really necessary? dissolve_free_huge_page will take care of this
> > and the race windown you are covering is really tiny.
> 
> Probably not, I was trying to shrink to race window as much as possible
> but the call to dissolve_free_huge_page might be enough.
> 
> > > +	nid = page_to_nid(page);
> > > +	spin_unlock(&hugetlb_lock);
> > > +
> > > +	/*
> > > +	 * Before dissolving the page, we need to allocate a new one,
> > > +	 * so the pool remains stable.
> > > +	 */
> > > +	new_page = alloc_fresh_huge_page(h, gfp_mask, nid, nmask, NULL);
> > 
> > wrt. fallback to other zones, I haven't realized that the primary
> > usecase is a form of memory offlining (from virt-mem). I am not yet sure
> > what the proper behavior is in that case but if breaking hugetlb pools,
> > similar to the normal hotplug operation, is viable then this needs a
> > special mode. We do not want a random alloc_contig_range user to do the
> > same. So for starter I would go with __GFP_THISNODE here.
> 
> Ok, makes sense.
> __GFP_THISNODE will not allow fallback to other node's zones.
> Since we only allow the nid the page belongs to, nodemask should be
> NULL, right?

I would have to double check because hugetlb has a slightly different
expectations from nodemask than the page allocator. The later translates
that to all possible nodes but hugetlb API tries to dereference nodes.
Maybe THIS node special cases it somewhere.

> > > +	if (!h)
> > > +		/*
> > > +		 * The page might have been dissolved from under our feet.
> > > +		 * If that is the case, return success as if we dissolved it
> > > +		 * ourselves.
> > > +		 */
> > > +		return true;
> > 
> > nit I would put the comment above the conditin for both cases. It reads
> > more easily that way. At least without { }.
> 
> Yes, makes sense.
> 
> > Other than that I haven't noticed any surprises.
> 
> I did. The 'put_page' call should be placed above, right after getting
> the page. Otherwise, refcount == 1 and we will fail to dissolve the
> new page if we need to (in case old page fails to be dissolved).
> I already fixed that locally.

I am not sure I follow. newly allocated pages is unreferenced
unconditionally and the old page is not referenced by this path.

-- 
Michal Hocko
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ