From patchwork Fri Aug 7 09:12:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11705205 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86AB7722 for ; Fri, 7 Aug 2020 09:13:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5824521744 for ; Fri, 7 Aug 2020 09:13:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5824521744 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EBEE88D0099; Fri, 7 Aug 2020 05:13:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DD7E98D0097; Fri, 7 Aug 2020 05:13:29 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B823C8D0097; Fri, 7 Aug 2020 05:13:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id 9EBB08D0099 for ; Fri, 7 Aug 2020 05:13:29 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 67853A8EB for ; Fri, 7 Aug 2020 09:13:29 +0000 (UTC) X-FDA: 77123209338.08.angle67_5c0eae926fbf Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 391671819E766 for ; Fri, 7 Aug 2020 09:13:29 +0000 (UTC) X-Spam-Summary: 1,0,0,9066fe7de4890daa,d41d8cd98f00b204,richard.weiyang@linux.alibaba.com,,RULES_HIT:41:355:379:541:960:965:966:973:988:989:1260:1261:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2914:3138:3139:3140:3141:3142:3352:3865:3867:3868:3872:3874:4321:4385:4390:4395:5007:6261:8603:8957:9707:10004:11026:11232:11658:11914:12043:12297:12438:12555:12895:13069:13146:13230:13255:13311:13357:13894:14181:14384:14394:14721:21080:21627:21740:21990:22048:30054:30065:30070,0,RBL:115.124.30.44:@linux.alibaba.com:.lbl8.mailshell.net-64.201.201.201 62.20.2.100;04yrzeka5wh1z3nid7t65eda9smcqyp4hhd4b14tek6douxuoa3js7wzyngqneu.5ikj4o5bout6mn4h7x7khajiiefo6wcb83emg19a4uu1z7makz5p863uqxsnomx.e-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: angle67_5c0eae926fbf X-Filterd-Recvd-Size: 2610 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Fri, 7 Aug 2020 09:13:26 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01422;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0U5.RnvZ_1596791601; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U5.RnvZ_1596791601) by smtp.aliyun-inc.com(127.0.0.1); Fri, 07 Aug 2020 17:13:21 +0800 From: Wei Yang To: mike.kravetz@oracle.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 10/10] mm/hugetlb: not necessary to abuse temporary page to workaround the nasty free_huge_page Date: Fri, 7 Aug 2020 17:12:51 +0800 Message-Id: <20200807091251.12129-11-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20200807091251.12129-1-richard.weiyang@linux.alibaba.com> References: <20200807091251.12129-1-richard.weiyang@linux.alibaba.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 391671819E766 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.002315, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Let's always increase surplus_huge_pages and so that free_huge_page could decrease it at free time. Signed-off-by: Wei Yang Signed-off-by: Mike Kravetz --- mm/hugetlb.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 1f2010c9dd8d..a0eb81e0e4c5 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1913,21 +1913,19 @@ static struct page *alloc_surplus_huge_page(struct hstate *h, gfp_t gfp_mask, return NULL; spin_lock(&hugetlb_lock); + + h->surplus_huge_pages++; + h->surplus_huge_pages_node[page_to_nid(page)]++; + /* * We could have raced with the pool size change. * Double check that and simply deallocate the new page - * if we would end up overcommiting the surpluses. Abuse - * temporary page to workaround the nasty free_huge_page - * codeflow + * if we would end up overcommiting the surpluses. */ - if (h->surplus_huge_pages >= h->nr_overcommit_huge_pages) { - SetPageHugeTemporary(page); + if (h->surplus_huge_pages > h->nr_overcommit_huge_pages) { spin_unlock(&hugetlb_lock); put_page(page); return NULL; - } else { - h->surplus_huge_pages++; - h->surplus_huge_pages_node[page_to_nid(page)]++; } out_unlock: