Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp169061iog; Fri, 17 Jun 2022 00:59:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uob+MuiJjM7onpy8Zc40vDSHy4sk4MZnMtMHZOCHwNQrFZAeOT2FY+zF4kGaFkfsBbfY6T X-Received: by 2002:a05:6402:26c1:b0:42e:203d:ee8c with SMTP id x1-20020a05640226c100b0042e203dee8cmr10667316edd.227.1655452751346; Fri, 17 Jun 2022 00:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655452751; cv=none; d=google.com; s=arc-20160816; b=vP3UxIuJbdQWbg4iRV5jQdq9uwrEciAxz8TF3Tn4MIabruC2pQkITEpEBdB6zFzvXA SnCNJQKxWzol4Yxp2ztzbJGYQ85hj5e7aQVnDPG39PoHnQNgMD9D+qXNbpyor2nKSbIN 0TxfRmZ56LP1PPTqPINTcadKfMTT+W6+c/eTiIOKQIRQjKdfsg+BGjzQZivW+slq+Lfl +fOdKK5Ohsqu5Ky8qDOmSevVlWVWnQEKQ0cqzCuks5aqiZ5tQnyWTFjstq1sHhincHQh vcR5ygGfl3pYm28wrQqDnEKB8BFuKOrv+MQ1oP489LPzWyCU5uxutannNkhSIn/1PabM UgvA== 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=g0u/GOzU5BM3qUn8umbjZw50kUmeU2XoJmxQaCg7nLU=; b=brE5Ev84w/T00MuHeeRXSdb2fIp4Mjj1uytbP0RVcAYLy6+q+eo+IBuuZAXqcvFqZF 5Z2Tt+86yOoxFnvcqb0J6isf1myi/Rmq+z9Yoapgvwr4ogFZ6XRRUhP+znKae3N6/9TK Ufm6oddjr9ZeD+s+YO7wnzS7vTpoAdbEQYwFD7UjT9d6Tfkj584qGqdUDxiVf5Z/sUx2 a1Tb7H93h1JLzreK0VokTslMJu2dcHv2+5lyOQUDxA8cDyzd+l4v+Y7b5QCPWbR/ZAxt M/967w0JXJPQBG83A3tAQJuH9UonJnRoNrbh7CGjaLYhKE98nFrmA7yQHSffvnfky367 FTvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=KwEEf3ud; 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 s8-20020a1709060c0800b00712128834c2si42351ejf.408.2022.06.17.00.58.45; Fri, 17 Jun 2022 00:59:11 -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=KwEEf3ud; 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 S1380657AbiFQHlx (ORCPT + 99 others); Fri, 17 Jun 2022 03:41:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380606AbiFQHlw (ORCPT ); Fri, 17 Jun 2022 03:41:52 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B491674D6 for ; Fri, 17 Jun 2022 00:41:50 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id f8so3218418plo.9 for ; Fri, 17 Jun 2022 00:41:50 -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=g0u/GOzU5BM3qUn8umbjZw50kUmeU2XoJmxQaCg7nLU=; b=KwEEf3udRnhhhDaQvmPI4JQPBSKliMmEhHeWpFqF+awD1U+SpUdFKnoXhXIU0vCJnt cSO1fGjsbT8bL2/SuRIzpO0q7GSAChivkye70mWhRdybV6ZxEaahzURxiIzpNUxhsRcB PHShwCufryY6y448ayQRRiU7kMdIGkpJC4yYYw5sPBEVzDohg8mX4LJFYWeWPJj6epW1 jTaTXxYyyb8M02WEthSWFheYMj1sx0emm+UqaMqabvxY3jOsL7uai9EhSszMQnTUdgnf Fe/1uN1gMFmwKVfrT5NPByXUwWu6+oXoaWHPSa0p47as0EgQbX9saNdqTi/RWoUxuoxV IimQ== 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=g0u/GOzU5BM3qUn8umbjZw50kUmeU2XoJmxQaCg7nLU=; b=Nm6afadpTqEpbGd6eeNkFGeeGYhRHkqsQrP5FoyO0Wc1D7FlDZh1YlEmf/BATbkuA8 XpNxc0ZJUxgkT9MuGBbJKcAEjGvHCAcAdx2Gt/8+iJb2lio6qL5RirZluXA/uBoiCQOp XtS1LwgotshP9kjwn4n+m8Mx6orsCN9YR2aupG0uMRWesMd8NUY7CPEv9VVbEHuUqp06 nfJHt+onCCVUYtfMwWVkutcR9yYGHKj8MXpNGsHjUxvK0Exdcu1+vzL8ymV7L9LZip+p 0cShxLBRk2DEPAAPr9Zjz1SApgUGcfNEqSTNZUSd16ZGZ0VdOLZju35iUMvK3krAUQRl N7Bg== X-Gm-Message-State: AJIora+l6g5VlVajE/+SWfx/N1c/9P5e1G/15uj6RjL1o/RzOb8i4sJZ bqUpAYLrZ+dptgOeuAuEt0JMH0doJgFvdn4fbhw= X-Received: by 2002:a17:903:2308:b0:16a:666:8ec2 with SMTP id d8-20020a170903230800b0016a06668ec2mr1292738plh.20.1655451710002; Fri, 17 Jun 2022 00:41:50 -0700 (PDT) Received: from localhost ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id j2-20020a62c502000000b0050dc762819bsm2960111pfg.117.2022.06.17.00.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 00:41:49 -0700 (PDT) Date: Fri, 17 Jun 2022 15:41:45 +0800 From: Muchun Song To: Mike Kravetz Cc: Oscar Salvador , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: hugetlb: remove minimum_order variable Message-ID: References: <20220616033846.96937-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Jun 16, 2022 at 11:03:34AM -0700, Mike Kravetz wrote: > On 06/16/22 11:38, Muchun Song wrote: > > The following commit: > > > > commit 641844f5616d ("mm/hugetlb: introduce minimum hugepage order") > > > > fixed a static checker warning and introduced a global variable minimum_order > > to fix the warning. However, the local variable in dissolve_free_huge_pages() > > can be initialized to huge_page_order(&default_hstate) to fix the warning. > > So remove minimum_order to simplify the code. > > > > Signed-off-by: Muchun Song > > --- > > mm/hugetlb.c | 18 +++++++----------- > > 1 file changed, 7 insertions(+), 11 deletions(-) > > > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > index 8ea4e51d8186..405d1c7441c9 100644 > > --- a/mm/hugetlb.c > > +++ b/mm/hugetlb.c > > @@ -66,12 +66,6 @@ static bool hugetlb_cma_page(struct page *page, unsigned int order) > > #endif > > static unsigned long hugetlb_cma_size __initdata; > > > > -/* > > - * Minimum page order among possible hugepage sizes, set to a proper value > > - * at boot time. > > - */ > > -static unsigned int minimum_order __read_mostly = UINT_MAX; > > - > > __initdata LIST_HEAD(huge_boot_pages); > > > > /* for command line parsing */ > > @@ -2161,11 +2155,17 @@ int dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn) > > unsigned long pfn; > > struct page *page; > > int rc = 0; > > + unsigned int order; > > + struct hstate *h; > > > > if (!hugepages_supported()) > > return rc; > > > > - for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << minimum_order) { > > + order = huge_page_order(&default_hstate); > > + for_each_hstate(h) > > + order = min(order, huge_page_order(h)); > > Since we will be traversing the array of hstates, I wonder if we should > optimize this further? We could: > - Pass the node into dissolve_free_huge_pages > - When traversing the hstate array, check free_huge_pages_node[node] in > each hstate. > - If no free huge pages, no need to do the pfn scan. > > Yes, the above is racy. However, the code is already racy as hugetlb > page state can change while performing this scan. We only hold the hugetlb > lock when checking an individual hugetlb page. The change above may > make the code a bit more racy. > Agree. > If we think that is too racy, they we could at least check > nr_huge_pages_node[node]. If there are no hugetlb pages on the node > there is no need to scan. And, I think we have isolated this pfn range > so no new hugetlb pages can be created. > > Not sure if the above optimizations are worth the effort. IIUC, the > pfn range is at most a memory block size which is not huge. > Right. It is not huge. I have no strong opinion. dissolve_free_huge_pages() is only called in memory offline path and it is not a hot path. If we think the optimization is necessary, I think it should be a separate patch. Thanks.