aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2012-07-31 19:42:00 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-31 21:42:40 -0400
commit972dc4de13f667a7df27ee32573b2e6fc6cc8434 (patch)
tree0d3ea1381b81700d17307fc6996a67bbabb7fac2 /mm
parent76dcee75c1aff61259f5ed55e2bcfab60cc4bd5f (diff)
hugetlb: add an inline helper for finding hstate index
Add an inline helper and use it in the code. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Acked-by: David Rientjes <rientjes@google.com> Acked-by: Michal Hocko <mhocko@suse.cz> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Hillf Danton <dhillf@gmail.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/hugetlb.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 34a7e2375478..b1e0ed1ea912 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1646,7 +1646,7 @@ static int hugetlb_sysfs_add_hstate(struct hstate *h, struct kobject *parent,
1646 struct attribute_group *hstate_attr_group) 1646 struct attribute_group *hstate_attr_group)
1647{ 1647{
1648 int retval; 1648 int retval;
1649 int hi = h - hstates; 1649 int hi = hstate_index(h);
1650 1650
1651 hstate_kobjs[hi] = kobject_create_and_add(h->name, parent); 1651 hstate_kobjs[hi] = kobject_create_and_add(h->name, parent);
1652 if (!hstate_kobjs[hi]) 1652 if (!hstate_kobjs[hi])
@@ -1741,11 +1741,13 @@ void hugetlb_unregister_node(struct node *node)
1741 if (!nhs->hugepages_kobj) 1741 if (!nhs->hugepages_kobj)
1742 return; /* no hstate attributes */ 1742 return; /* no hstate attributes */
1743 1743
1744 for_each_hstate(h) 1744 for_each_hstate(h) {
1745 if (nhs->hstate_kobjs[h - hstates]) { 1745 int idx = hstate_index(h);
1746 kobject_put(nhs->hstate_kobjs[h - hstates]); 1746 if (nhs->hstate_kobjs[idx]) {
1747 nhs->hstate_kobjs[h - hstates] = NULL; 1747 kobject_put(nhs->hstate_kobjs[idx]);
1748 nhs->hstate_kobjs[idx] = NULL;
1748 } 1749 }
1750 }
1749 1751
1750 kobject_put(nhs->hugepages_kobj); 1752 kobject_put(nhs->hugepages_kobj);
1751 nhs->hugepages_kobj = NULL; 1753 nhs->hugepages_kobj = NULL;
@@ -1848,7 +1850,7 @@ static void __exit hugetlb_exit(void)
1848 hugetlb_unregister_all_nodes(); 1850 hugetlb_unregister_all_nodes();
1849 1851
1850 for_each_hstate(h) { 1852 for_each_hstate(h) {
1851 kobject_put(hstate_kobjs[h - hstates]); 1853 kobject_put(hstate_kobjs[hstate_index(h)]);
1852 } 1854 }
1853 1855
1854 kobject_put(hugepages_kobj); 1856 kobject_put(hugepages_kobj);
@@ -1869,7 +1871,7 @@ static int __init hugetlb_init(void)
1869 if (!size_to_hstate(default_hstate_size)) 1871 if (!size_to_hstate(default_hstate_size))
1870 hugetlb_add_hstate(HUGETLB_PAGE_ORDER); 1872 hugetlb_add_hstate(HUGETLB_PAGE_ORDER);
1871 } 1873 }
1872 default_hstate_idx = size_to_hstate(default_hstate_size) - hstates; 1874 default_hstate_idx = hstate_index(size_to_hstate(default_hstate_size));
1873 if (default_hstate_max_huge_pages) 1875 if (default_hstate_max_huge_pages)
1874 default_hstate.max_huge_pages = default_hstate_max_huge_pages; 1876 default_hstate.max_huge_pages = default_hstate_max_huge_pages;
1875 1877
@@ -2687,7 +2689,7 @@ retry:
2687 */ 2689 */
2688 if (unlikely(PageHWPoison(page))) { 2690 if (unlikely(PageHWPoison(page))) {
2689 ret = VM_FAULT_HWPOISON | 2691 ret = VM_FAULT_HWPOISON |
2690 VM_FAULT_SET_HINDEX(h - hstates); 2692 VM_FAULT_SET_HINDEX(hstate_index(h));
2691 goto backout_unlocked; 2693 goto backout_unlocked;
2692 } 2694 }
2693 } 2695 }
@@ -2760,7 +2762,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
2760 return 0; 2762 return 0;
2761 } else if (unlikely(is_hugetlb_entry_hwpoisoned(entry))) 2763 } else if (unlikely(is_hugetlb_entry_hwpoisoned(entry)))
2762 return VM_FAULT_HWPOISON_LARGE | 2764 return VM_FAULT_HWPOISON_LARGE |
2763 VM_FAULT_SET_HINDEX(h - hstates); 2765 VM_FAULT_SET_HINDEX(hstate_index(h));
2764 } 2766 }
2765 2767
2766 ptep = huge_pte_alloc(mm, address, huge_page_size(h)); 2768 ptep = huge_pte_alloc(mm, address, huge_page_size(h));