Re: [PATCH v2 13/20] mm, hugetlb: mm, hugetlb: unify chg andavoid_reserve to use_reserve

From: Joonsoo Kim
Date: Tue Aug 27 2013 - 03:57:32 EST


On Mon, Aug 26, 2013 at 06:39:35PM +0530, Aneesh Kumar K.V wrote:
> Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> writes:
>
> > Currently, we have two variable to represent whether we can use reserved
> > page or not, chg and avoid_reserve, respectively. With aggregating these,
> > we can have more clean code. This makes no functinoal difference.
> >
> > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
> >
> > diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> > index 22ceb04..8dff972 100644
> > --- a/mm/hugetlb.c
> > +++ b/mm/hugetlb.c
> > @@ -531,8 +531,7 @@ static struct page *dequeue_huge_page_node(struct hstate *h, int nid)
> >
> > static struct page *dequeue_huge_page_vma(struct hstate *h,
> > struct vm_area_struct *vma,
> > - unsigned long address, int avoid_reserve,
> > - long chg)
> > + unsigned long address, bool use_reserve)
> > {
> > struct page *page = NULL;
> > struct mempolicy *mpol;
> > @@ -546,12 +545,10 @@ static struct page *dequeue_huge_page_vma(struct hstate *h,
> > * A child process with MAP_PRIVATE mappings created by their parent
> > * have no page reserves. This check ensures that reservations are
> > * not "stolen". The child may still get SIGKILLed
> > + * Or, when parent process do COW, we cannot use reserved page.
> > + * In this case, ensure enough pages are in the pool.
> > */
> > - if (chg && h->free_huge_pages - h->resv_huge_pages == 0)
> > - return NULL;
>
> This hunk would be much easier if you were changing.
>
> if (!vma_has_reserves(vma) &&
> h->free_huge_pages - h->resv_huge_pages == 0)
> goto err;
>
> ie, !vma_has_reserves(vma) == !use_reserve.
>
> So may be a patch rearragment would help ?. But neverthless.

I think that current form is better since use_reserve is not same as
vma_has_reserves(). I changed the call site of vma_has_reserves() to chg in
previous patch. In this patch, use_reserve in alloc_huge_page is made
by chg and avoid_reserve and is passed to dequeue_huge_page_vma(). So changing
in dequeue_huge_page_vma() is trivial.

>
> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@xxxxxxxxxxxxxxxxxx>

Thanks!

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/