Merge tag 'for-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux...
[linux-2.6-microblaze.git] / mm / hugetlb.c
index 37f15c3..cbf32d2 100644 (file)
@@ -1216,6 +1216,7 @@ static void destroy_compound_gigantic_page(struct page *page,
        }
 
        set_compound_order(page, 0);
+       page[1].compound_nr = 0;
        __ClearPageHead(page);
 }
 
@@ -1943,13 +1944,14 @@ struct page *alloc_huge_page_vma(struct hstate *h, struct vm_area_struct *vma,
  * Increase the hugetlb pool such that it can accommodate a reservation
  * of size 'delta'.
  */
-static int gather_surplus_pages(struct hstate *h, int delta)
+static int gather_surplus_pages(struct hstate *h, long delta)
        __must_hold(&hugetlb_lock)
 {
        struct list_head surplus_list;
        struct page *page, *tmp;
-       int ret, i;
-       int needed, allocated;
+       int ret;
+       long i;
+       long needed, allocated;
        bool alloc_ok = true;
 
        needed = (h->resv_huge_pages + delta) - h->free_huge_pages;
@@ -2013,8 +2015,7 @@ retry:
                 * This page is now managed by the hugetlb allocator and has
                 * no users -- drop the buddy allocator's reference.
                 */
-               put_page_testzero(page);
-               VM_BUG_ON_PAGE(page_count(page), page);
+               VM_BUG_ON_PAGE(!put_page_testzero(page), page);
                enqueue_huge_page(h, page);
        }
 free:
@@ -2759,7 +2760,7 @@ static ssize_t nr_hugepages_show_common(struct kobject *kobj,
        else
                nr_huge_pages = h->nr_huge_pages_node[nid];
 
-       return sprintf(buf, "%lu\n", nr_huge_pages);
+       return sysfs_emit(buf, "%lu\n", nr_huge_pages);
 }
 
 static ssize_t __nr_hugepages_store_common(bool obey_mempolicy,
@@ -2832,7 +2833,8 @@ HSTATE_ATTR(nr_hugepages);
  * huge page alloc/free.
  */
 static ssize_t nr_hugepages_mempolicy_show(struct kobject *kobj,
-                                      struct kobj_attribute *attr, char *buf)
+                                          struct kobj_attribute *attr,
+                                          char *buf)
 {
        return nr_hugepages_show_common(kobj, attr, buf);
 }
@@ -2850,7 +2852,7 @@ static ssize_t nr_overcommit_hugepages_show(struct kobject *kobj,
                                        struct kobj_attribute *attr, char *buf)
 {
        struct hstate *h = kobj_to_hstate(kobj, NULL);
-       return sprintf(buf, "%lu\n", h->nr_overcommit_huge_pages);
+       return sysfs_emit(buf, "%lu\n", h->nr_overcommit_huge_pages);
 }
 
 static ssize_t nr_overcommit_hugepages_store(struct kobject *kobj,
@@ -2888,7 +2890,7 @@ static ssize_t free_hugepages_show(struct kobject *kobj,
        else
                free_huge_pages = h->free_huge_pages_node[nid];
 
-       return sprintf(buf, "%lu\n", free_huge_pages);
+       return sysfs_emit(buf, "%lu\n", free_huge_pages);
 }
 HSTATE_ATTR_RO(free_hugepages);
 
@@ -2896,7 +2898,7 @@ static ssize_t resv_hugepages_show(struct kobject *kobj,
                                        struct kobj_attribute *attr, char *buf)
 {
        struct hstate *h = kobj_to_hstate(kobj, NULL);
-       return sprintf(buf, "%lu\n", h->resv_huge_pages);
+       return sysfs_emit(buf, "%lu\n", h->resv_huge_pages);
 }
 HSTATE_ATTR_RO(resv_hugepages);
 
@@ -2913,7 +2915,7 @@ static ssize_t surplus_hugepages_show(struct kobject *kobj,
        else
                surplus_huge_pages = h->surplus_huge_pages_node[nid];
 
-       return sprintf(buf, "%lu\n", surplus_huge_pages);
+       return sysfs_emit(buf, "%lu\n", surplus_huge_pages);
 }
 HSTATE_ATTR_RO(surplus_hugepages);
 
@@ -3197,8 +3199,6 @@ void __init hugetlb_add_hstate(unsigned int order)
        h = &hstates[hugetlb_max_hstate++];
        h->order = order;
        h->mask = ~((1ULL << (order + PAGE_SHIFT)) - 1);
-       h->nr_huge_pages = 0;
-       h->free_huge_pages = 0;
        for (i = 0; i < MAX_NUMNODES; ++i)
                INIT_LIST_HEAD(&h->hugepage_freelists[i]);
        INIT_LIST_HEAD(&h->hugepage_activelist);
@@ -3672,7 +3672,7 @@ const struct vm_operations_struct hugetlb_vm_ops = {
        .fault = hugetlb_vm_op_fault,
        .open = hugetlb_vm_op_open,
        .close = hugetlb_vm_op_close,
-       .split = hugetlb_vm_op_split,
+       .may_split = hugetlb_vm_op_split,
        .pagesize = hugetlb_vm_op_pagesize,
 };
 
@@ -5114,6 +5114,7 @@ int hugetlb_reserve_pages(struct inode *inode,
 
                if (unlikely(add < 0)) {
                        hugetlb_acct_memory(h, -gbl_reserve);
+                       ret = add;
                        goto out_put_pages;
                } else if (unlikely(chg > add)) {
                        /*