Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2070126pxa; Fri, 7 Aug 2020 02:15:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTFOXPExDoy1PZK3Rj3bVJrbLE9pEKWy1/0NfEuGjF8u6PYxRUgnBIVtuhHYhhlygN7Bmd X-Received: by 2002:a17:906:2b57:: with SMTP id b23mr8228068ejg.26.1596791712738; Fri, 07 Aug 2020 02:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596791712; cv=none; d=google.com; s=arc-20160816; b=sKloTrqL5bqZtI8isR+M2AvQe0bmIMwjlDYx7Ar9mOlsX6kkCmjKadIieICA6XvJ0J FNeAkXzLcy9eqC8L9+QtQWP36k0G2UKondoMzNeZutbHvNthWbQi1ofQmwi+Fa5wYmqj lPum4KTF6UUKOFFpq62VxmRdcUU5Yr6W5SQIJtBXqeSSd2qsK8EzSkobb4a8j7xnwdJC UQG/9aRWN4jkf1r1ToWszbbR13AKtdaZ3NK+3TXaNlw1MJ1o87Q9+Rdiz8F0C54UdIFr xnOXEM+aYc0IDD1fK3zePZvPXmtWn+/RPqlInK4tUqmk9OzcZa1Ay/a9DDBsBZuuocgd wtUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=qz6oJQyxzqXRc2mfixtbvbMVkPERmFEiC2UEUvsGyzg=; b=gk4kwC4NsYqULuIlUg8mBOBl8AxpZXEZMQnrKAfd/BAWJod3SpcrtHbE75kJEwv9Ad CxTFj9Wj6JtxhUTWIEMFW02hraGIRXmStUqn1V7QhSkjlZ2mF7NFjpBvkj2yuH9GLx8o Hikbxzd2pfRFJ01xrxubSlOpzIcAzk0/rBESUinpsxfJwhgdaq4OC3WLzp9P9ygMwi7S 2IG+ao5JYiJhYguhT/UzfRUx9PZn8uPuSgQvqJQlAMyCA6zIHMRdsr7chpuQRm4kT6ek h7ba0I6Ay5Ao6cVnQPmLfP6rabOEsRcEZEaVTnG898BEZW2uoy624My/gn/cHn5Ois4l 0WJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si4953430ejo.528.2020.08.07.02.14.49; Fri, 07 Aug 2020 02:15:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728027AbgHGJNe (ORCPT + 99 others); Fri, 7 Aug 2020 05:13:34 -0400 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:44961 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727054AbgHGJNd (ORCPT ); Fri, 7 Aug 2020 05:13:33 -0400 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let's always increase surplus_huge_pages and so that free_huge_page could decrease it at free time. Signed-off-by: Wei Yang --- 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: -- 2.20.1 (Apple Git-117)