Skip to contentSkip to conversation

mm: hugetlb: fix type of delta parameter and related local variables in gather_surplus_pages()

PATCH Applied Liu Xiang 2 participants 2 messages Nov 19, 2020

Subsystems (2)
lore
Share & tools
lore

Liu Xiang

author
#0 lore raw

PATCH v2 1/1 mm: hugetlb: fix type of delta parameter and related local variables in gather_surplus_pages()

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().

---
Changes in v2:
as suggested by Mike, apply the same fix to the related local variables in gather_surplus_pages().
---

---
 mm/hugetlb.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
mm/hugetlb.c +4 -3
index 37f15c3..3797401 100644
@@ -1943,13 +1943,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;
Signature · 1 line
1.9.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Liu Xiang

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().

Quoted 8 lines

---
Changes in v2:
as suggested by Mike, apply the same fix to the related local variables in gather_surplus_pages().
---

---
 mm/hugetlb.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Thank you,

Signature · 1 line
Mike Kravetz