From patchwork Thu Nov 19 13:48:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Xiang X-Patchwork-Id: 11917485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DBF0C6369E for ; Thu, 19 Nov 2020 13:49:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 44DC022264 for ; Thu, 19 Nov 2020 13:49:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44DC022264 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=zlingsmart.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 434546B005D; Thu, 19 Nov 2020 08:49:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E4DB6B0068; Thu, 19 Nov 2020 08:49:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 285106B006C; Thu, 19 Nov 2020 08:49:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id EE32F6B005D for ; Thu, 19 Nov 2020 08:49:13 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 907A8181AEF1F for ; Thu, 19 Nov 2020 13:49:13 +0000 (UTC) X-FDA: 77501299386.08.egg77_1000c5227343 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 6E6BF1819E76F for ; Thu, 19 Nov 2020 13:49:13 +0000 (UTC) X-HE-Tag: egg77_1000c5227343 X-Filterd-Recvd-Size: 2559 Received: from out28-98.mail.aliyun.com (out28-98.mail.aliyun.com [115.124.28.98]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Thu, 19 Nov 2020 13:49:11 +0000 (UTC) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.1020446|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_regular_dialog|0.0602599-0.000565229-0.939175;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047188;MF=liu.xiang@zlingsmart.com;NM=1;PH=DS;RN=7;RT=7;SR=0;TI=SMTPD_---.IyqT2MD_1605793739; Received: from localhost(mailfrom:liu.xiang@zlingsmart.com fp:SMTPD_---.IyqT2MD_1605793739) by smtp.aliyun-inc.com(10.194.97.171); Thu, 19 Nov 2020 21:48:59 +0800 From: Liu Xiang To: linux-mm@kvack.org Cc: mike.kravetz@oracle.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, liuxiang_1999@126.com, Liu Xiang , Pan Jiagen Subject: [PATCH v2] mm: hugetlb: fix type of delta parameter and related local variables in gather_surplus_pages() Date: Thu, 19 Nov 2020 21:48:53 +0800 Message-Id: <1605793733-3573-1-git-send-email-liu.xiang@zlingsmart.com> X-Mailer: git-send-email 1.9.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000625, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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(). Reported-by: Ma Chenggong Signed-off-by: Liu Xiang Signed-off-by: Pan Jiagen Reviewed-by: Mike Kravetz --- 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(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 37f15c3..3797401 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -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;