Re: [PATCH 8/9] memory-hotplug: enable memory hotplug to handlehugepage

From: Naoya Horiguchi
Date: Wed Feb 27 2013 - 12:17:17 EST


On Wed, Feb 27, 2013 at 02:36:04AM -0500, Chen Gong wrote:
> On Thu, Feb 21, 2013 at 02:41:47PM -0500, Naoya Horiguchi wrote:
...
> > @@ -3158,6 +3182,25 @@ static int is_hugepage_on_freelist(struct page *hpage)
> > return 0;
> > }
> >
> > +/* Returns true for head pages of in-use hugepages, otherwise returns false. */
> > +int is_hugepage_movable(struct page *hpage)
> > +{
> > + struct page *page;
> > + struct page *tmp;
> > + struct hstate *h = page_hstate(hpage);
> > + int ret = 0;
> > +
> > + VM_BUG_ON(!PageHuge(hpage));
> > + if (PageTail(hpage))
> > + return 0;
> > + spin_lock(&hugetlb_lock);
> > + list_for_each_entry_safe(page, tmp, &h->hugepage_activelist, lru)
> > + if (page == hpage)
> > + ret = 1;
>
> I don't understand the logic here. 1) page is not removed why tmp is used?
> 2) why hitting (page ==hpage) but not breaking from the loop?

For question 1), using list_for_each_entry_safe() was a remnant of
try and error and will be fixed. And for question 2), I will add
break in later version.

Thanks,
Naoya

> > + spin_unlock(&hugetlb_lock);
> > + return ret;
> > +}
> > +
> > [...]
--
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/