Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp181391iog; Fri, 24 Jun 2022 01:47:26 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sba78azNwygmdLxLEdvc4zwHwNtpt9op5wKNBeDQdfqHGRGu91Lu1vOZ9/Y4D8OzIeHYlE X-Received: by 2002:a17:906:9750:b0:722:e84a:b6f2 with SMTP id o16-20020a170906975000b00722e84ab6f2mr12316777ejy.430.1656060446548; Fri, 24 Jun 2022 01:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656060446; cv=none; d=google.com; s=arc-20160816; b=wrGBweL1E6yc/HLn7yZ4IUHYtZQoNF1+0xItTxAzjrXuMpn113Zx8PjwBwqATO9Zkp 4scv2buGkRyFzBhMEMXmqqdJtmyYZGDxwpXWo5N94aBn3aCSa8eN4XYG6LiVWVyXAkyE ROS3owG2KDjxuUaSnaTeMUz360xyBt6PTYpBf86ct+kdjYgU2ETCZaZ8Nk4ZJL8L5+1C mDuJFb6dDxVZlkMTEy9TblV90XA4cL8fPL2TIzZMYLQksOonAbW/04j6+5AAXLnoujCj DVpOEoa3SjNWQsLpacxrYQhY0ZK/9gkkFl/TOpOSfovgJTDOJFb8N08LyZRg8A2BGUrd zaxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=s/aQkZT/+2YcvxV9aXxlZHqNRowREfHb6F3Nptk8s7o=; b=xg+VclHWF+NKIGcwTh0NTn2lRCVaaeITY9uGrgPl7m3w64YTyyvg40clv2GgvbUeLw SLYHxP22+fBOop5wrHxMeJiz0thUhwkEbI7AagPn/qnbuI6maSIGnJLCjUgSROaaJJyf XYorRjy4ReLAYDtBNlaYnCEW1G6D8mifvX8xQL3CC9VZTqPt9qXknaDpJsDEQ/RdJIIX e6zdwHx6Khh11o4spStUzcjV9ZBFGFg8UQLkNn7eN1P3X151KyZPKx0C9PAbTekbmNg0 EXqsQoh9Xk8xb1gLayK/TZQwuk+B2yjsyybmwTRGGPdoK+ASfJcB0l36lVGW9ZNAUzP7 N0Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=WhFGELdR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds15-20020a170907724f00b006e86aac6b67si2141140ejc.351.2022.06.24.01.47.02; Fri, 24 Jun 2022 01:47:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=WhFGELdR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230519AbiFXID6 (ORCPT + 99 others); Fri, 24 Jun 2022 04:03:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbiFXIDu (ORCPT ); Fri, 24 Jun 2022 04:03:50 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22FB26B8FC for ; Fri, 24 Jun 2022 01:03:47 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id o18so1474495plg.2 for ; Fri, 24 Jun 2022 01:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=s/aQkZT/+2YcvxV9aXxlZHqNRowREfHb6F3Nptk8s7o=; b=WhFGELdR/RtberGg47WTsERtwgZ9s5MslETlO9JE75M3s1+glUPLMpUnejl3c5px2D 5QyuxWW2zAm2YD3ZkpOsjjoxZebMTOGuO8jIDzsg5rfrM+iLKHY70KgWdB2rLoxawTtq ue+RchUgEmZJ3S5t7mrddkmjodTw30lN2kFhtfiMz8qXceCH8ah+QWuxnhv3gIsiXfC4 AAStOBtmWtU5nXN/gJPLdsCDRCb3tZtLgmcRD9SYetXjd+bf43lHYxjKS0IfZ12BSxGq Tm26xqgFKQBo5/jvvomJM3l11g7UMmFQhxKnDJnj9nqcFS738XZcvT9EyyN7kN6es61x 28hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=s/aQkZT/+2YcvxV9aXxlZHqNRowREfHb6F3Nptk8s7o=; b=5sK0bPglaT/06qT4bq4MZ5hjMNxITnVhYQm3IW1O5K63YIT1XtPdi0syuPymbmquzJ Arv5rDnZfzqnmN8RnbOBKURh+yjaVdeVvTxm7FgWtj17oVC6bM85/s7Cv1NnQpNlpYSG 4kadcddTtntbrYgsVV0dKAAelvuTsjnbNFfIxF9cER/2hVhUvjrOpRFSZnORfMBE8Sg6 ZG7xc6avlss5cxMtkhWO9SC9teVlKnOt/8s46bz59YJ5IhF3pVfQc/HH2EcYg4BOfXmL w9RFpiL4m4BkMq6gsxaHXJobNP1xV9Dp37xb1DmCYfXjLL5kzAVhiJaln5Al3QG6NhhE tD3g== X-Gm-Message-State: AJIora/tLU+gj/TZUenLN2ff/8wGrsUsOdCOl+gBTfaz9pSV7OSaEExP c4LJcKz2pQIjv3AM+AtQ3oeRFQ== X-Received: by 2002:a17:90b:224a:b0:1ec:d128:a82d with SMTP id hk10-20020a17090b224a00b001ecd128a82dmr2643657pjb.3.1656057826594; Fri, 24 Jun 2022 01:03:46 -0700 (PDT) Received: from localhost ([139.177.225.231]) by smtp.gmail.com with ESMTPSA id z29-20020a63191d000000b0040c9774b332sm927606pgl.48.2022.06.24.01.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 01:03:46 -0700 (PDT) Date: Fri, 24 Jun 2022 16:03:42 +0800 From: Muchun Song To: Miaohe Lin Cc: Naoya Horiguchi , Andrew Morton , David Hildenbrand , Mike Kravetz , Liu Shixin , Yang Shi , Oscar Salvador , Naoya Horiguchi , linux-kernel@vger.kernel.org, Linux-MM Subject: Re: [PATCH v2 1/9] mm/hugetlb: remove checking hstate_is_gigantic() in return_unused_surplus_pages() Message-ID: References: <20220623235153.2623702-1-naoya.horiguchi@linux.dev> <20220623235153.2623702-2-naoya.horiguchi@linux.dev> <0b69e3ef-0123-4575-b68d-4d9b2067aa0e@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0b69e3ef-0123-4575-b68d-4d9b2067aa0e@huawei.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 24, 2022 at 10:25:48AM +0800, Miaohe Lin wrote: > On 2022/6/24 7:51, Naoya Horiguchi wrote: > > From: Naoya Horiguchi > > > > I found a weird state of 1GB hugepage pool, caused by the following > > procedure: > > > > - run a process reserving all free 1GB hugepages, > > - shrink free 1GB hugepage pool to zero (i.e. writing 0 to > > /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages), then > > - kill the reserving process. > > > > , then all the hugepages are free *and* surplus at the same time. > > > > $ cat /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages > > 3 > > $ cat /sys/kernel/mm/hugepages/hugepages-1048576kB/free_hugepages > > 3 > > $ cat /sys/kernel/mm/hugepages/hugepages-1048576kB/resv_hugepages > > 0 > > $ cat /sys/kernel/mm/hugepages/hugepages-1048576kB/surplus_hugepages > > 3 > > > > This state is resolved by reserving and allocating the pages then > > freeing them again, so this seems not to result in serious problem. > > But it's a little surprizing (shrinking pool suddenly fails). > > > > This behavior is caused by hstate_is_gigantic() check in > > return_unused_surplus_pages(). This was introduced so long ago in 2008 > > by commit aa888a74977a ("hugetlb: support larger than MAX_ORDER"), and > > it seems to me that this check is no longer unnecessary. Let's remove it. > > s/unnecessary/necessary/ > > > > > Signed-off-by: Naoya Horiguchi > > --- > > mm/hugetlb.c | 4 ---- > > 1 file changed, 4 deletions(-) > > > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > index a57e1be41401..c538278170a2 100644 > > --- a/mm/hugetlb.c > > +++ b/mm/hugetlb.c > > @@ -2432,10 +2432,6 @@ static void return_unused_surplus_pages(struct hstate *h, > > /* Uncommit the reservation */ > > h->resv_huge_pages -= unused_resv_pages; > > > > - /* Cannot return gigantic pages currently */ > > - if (hstate_is_gigantic(h)) > > - goto out; > > - > > IIUC it might be better to do the below check: > /* > * Cannot return gigantic pages currently if runtime gigantic page > * allocation is not supported. > */ > if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) > goto out; > The change looks good to me. However, the comments above is unnecessary since gigantic_page_runtime_supported() is straightforward. Thanks. > But I might be miss something. > > Thanks. > > > /* > > * Part (or even all) of the reservation could have been backed > > * by pre-allocated pages. Only free surplus pages. > > > >