| Submitter | Becky Bruce |
|---|---|
| Date | June 28, 2011, 7:54 p.m. |
| Message ID | <13092910103675-git-send-email-beckyb@kernel.crashing.org> |
| Download | mbox | patch |
| Permalink | /patch/102480/ |
| State | Superseded |
| Headers | show |
Comments
On Tue, 2011-06-28 at 14:54 -0500, Becky Bruce wrote: > struct page *alloc_huge_page_node(struct hstate *h, int nid); > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 6402458..2db81ea 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1105,8 +1105,14 @@ static void __init > gather_bootmem_prealloc(void) > struct huge_bootmem_page *m; > > list_for_each_entry(m, &huge_boot_pages, list) { > - struct page *page = virt_to_page(m); > struct hstate *h = m->hstate; > +#ifdef CONFIG_HIGHMEM > + struct page *page = pfn_to_page(m->phys >> > PAGE_SHIFT); > + free_bootmem_late((unsigned long)m, > + sizeof(struct huge_bootmem_page)); > +#else > + struct page *page = virt_to_page(m); > +#endif > __ClearPageReserved(page); Why do you add free_bootmem_late() in the highmem case and not the normal case ? Cheers, Ben.
On Jun 28, 2011, at 4:39 PM, Benjamin Herrenschmidt wrote: > On Tue, 2011-06-28 at 14:54 -0500, Becky Bruce wrote: >> struct page *alloc_huge_page_node(struct hstate *h, int nid); >> diff --git a/mm/hugetlb.c b/mm/hugetlb.c >> index 6402458..2db81ea 100644 >> --- a/mm/hugetlb.c >> +++ b/mm/hugetlb.c >> @@ -1105,8 +1105,14 @@ static void __init >> gather_bootmem_prealloc(void) >> struct huge_bootmem_page *m; >> >> list_for_each_entry(m, &huge_boot_pages, list) { >> - struct page *page = virt_to_page(m); >> struct hstate *h = m->hstate; >> +#ifdef CONFIG_HIGHMEM >> + struct page *page = pfn_to_page(m->phys >> >> PAGE_SHIFT); >> + free_bootmem_late((unsigned long)m, >> + sizeof(struct huge_bootmem_page)); >> +#else >> + struct page *page = virt_to_page(m); >> +#endif >> __ClearPageReserved(page); > > Why do you add free_bootmem_late() in the highmem case and not the > normal case ? Because there was no bootmem allocation in the normal case - the non-highmem version stores data structure in the huge page itself. This is perfectly fine as long as you have a mapping. Since this isn't true for HIGHMEM pages, I allocate bootmem to store the early data structure that stores information about the hugepage (this happens in arch-specific code in alloc_bootmem_huge_page). -Becky
On Thu, Jun 30, 2011 at 1:50 PM, Becky Bruce <beckyb@kernel.crashing.org> wrote: > Because there was no bootmem allocation in the normal case - the non-highmem > version stores data structure in the huge page itself. This is perfectly fine as long > as you have a mapping. Since this isn't true for HIGHMEM pages, I allocate > bootmem to store the early data structure that stores information about the > hugepage (this happens in arch-specific code in alloc_bootmem_huge_page). I would put this text in a comment in the code.
Patch
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 59225ef..19644e0 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -231,6 +231,9 @@ struct hstate { struct huge_bootmem_page { struct list_head list; struct hstate *hstate; +#ifdef CONFIG_HIGHMEM + phys_addr_t phys; +#endif }; struct page *alloc_huge_page_node(struct hstate *h, int nid); diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 6402458..2db81ea 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1105,8 +1105,14 @@ static void __init gather_bootmem_prealloc(void) struct huge_bootmem_page *m; list_for_each_entry(m, &huge_boot_pages, list) { - struct page *page = virt_to_page(m); struct hstate *h = m->hstate; +#ifdef CONFIG_HIGHMEM + struct page *page = pfn_to_page(m->phys >> PAGE_SHIFT); + free_bootmem_late((unsigned long)m, + sizeof(struct huge_bootmem_page)); +#else + struct page *page = virt_to_page(m); +#endif __ClearPageReserved(page); WARN_ON(page_count(page) != 1); prep_compound_huge_page(page, h->order);