From: Liu Xiang
mainline inclusion
from mainline-v5.11-rc1
commit 0a4f3d1bb91cac4efdd780373638b6a1a4c24c51
category: bugfix
issue: #I3ZXZF
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
-----------------------------------------------
On 64-bit machine, delta variable in hugetlb_acct_memory() may be larger
than 0xffffffff, but gather_surplus_pages() can only use the low 32-bit
value now. So we need to fix type of delta parameter and related local
variables in gather_surplus_pages().
Link: https://lkml.kernel.org/r/1605793733-3573-1-git-send-email-liu.xiang@zlingsm...
Reported-by: Ma Chenggong
Signed-off-by: Liu Xiang
Signed-off-by: Pan Jiagen
Reviewed-by: Mike Kravetz
Cc: Liu Xiang
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
Signed-off-by: Tong Tiangen
Reviewed-by: Chen Wandun
Signed-off-by: Chen Jun
Signed-off-by: Yu Changchun
---
mm/hugetlb.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index fa6b0ac6c280..0dcc5488ed67 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2004,13 +2004,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;
--
2.22.0