On Fri, Oct 22, 2021 at 12:05:47PM -0700, Mike Kravetz wrote: > How about if this commit message provides links to previous commits > describing these issues? There are pretty extensive descriptions in > those previous commits, so no need to repeat here IMO. Fine by me. > The patch with an updated commit message is below. > > From 10fcff70c809402901a93ea507d5506c87a8227d Mon Sep 17 00:00:00 2001 > From: Mike Kravetz <mike.kravetz@xxxxxxxxxx> > Date: Fri, 22 Oct 2021 11:50:31 -0700 > Subject: [PATCH v4 4/5] hugetlb: add demote bool to gigantic page routines > > The routines remove_hugetlb_page and destroy_compound_gigantic_page > will remove a gigantic page and make the set of base pages ready to be > returned to a lower level allocator. In the process of doing this, they > make all base pages reference counted. > > The routine prep_compound_gigantic_page creates a gigantic page from a > set of base pages. It assumes that all these base pages are reference > counted. > > During demotion, a gigantic page will be split into huge pages of a > smaller size. This logically involves use of the routines, > remove_hugetlb_page, and destroy_compound_gigantic_page followed by > prep_compound*_page for each smaller huge page. > > When pages are reference counted (ref count >= 0), additional > speculative ref counts could be taken as described in previous > commits [1] and [2]. This could result in errors while demoting > a huge page. Quite a bit of code would need to be created to > handle all possible issues. > > Instead of dealing with the possibility of speculative ref counts, avoid > the possibility by keeping ref counts at zero during the demote process. > Add a boolean 'demote' to the routines remove_hugetlb_page, > destroy_compound_gigantic_page and prep_compound_gigantic_page. If the > boolean is set, the remove and destroy routines will not reference count > pages and the prep routine will not expect reference counted pages. > > '*_for_demote' wrappers of the routines will be added in a subsequent > patch where this functionality is used. > > [1] https://lore.kernel.org/linux-mm/20210622021423.154662-3-mike.kravetz@xxxxxxxxxx/ > [2] https://lore.kernel.org/linux-mm/20210809184832.18342-3-mike.kravetz@xxxxxxxxxx/ > Signed-off-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Reviewed-by: Oscar Salvador <osalvador@xxxxxxx> -- Oscar Salvador SUSE Labs