From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E9C7C433EF for ; Fri, 17 Jun 2022 07:41:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB8E36B0071; Fri, 17 Jun 2022 03:41:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B681D6B0073; Fri, 17 Jun 2022 03:41:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A08F46B0074; Fri, 17 Jun 2022 03:41:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9012E6B0071 for ; Fri, 17 Jun 2022 03:41:52 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 4648680743 for ; Fri, 17 Jun 2022 07:41:52 +0000 (UTC) X-FDA: 79586933664.25.CB8F4AE Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by imf08.hostedemail.com (Postfix) with ESMTP id 6E82B16008C for ; Fri, 17 Jun 2022 07:41:51 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id w19-20020a17090a8a1300b001ec79064d8dso581043pjn.2 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=BplI/fng/eJ0zNrHJl6UTACnavi20UwMgQSlkfCaMNFa0/OhJS71KCFAT+wIqFZlAn d57il2+7clfiOccb+zeZ0Gt2u6zbbiYVbJeSjWsjwqw6UiiJY1AcvoMDJAwk4VX3zwjo I3oD/BIaGMXMhnxNXsXXynrxerRC/WHMfuDTe4UL0PU60KfbKJOJf+gM77O2TMqfAd1z 3j/68Xey3brCXirZxG2XzDA9JoQARE1K5vsHrQGbu8kmfWFCWJvO560IHfb9NUsCwyX5 4jHgmVaYlBzCGR9BGoWKHH6k89ZJhXIwN017Rx2HadSGZRehQpaHkTtqPSQC+8VvrJ0o jYxA== X-Gm-Message-State: AJIora8AWyVvNj3wrTtnzmPrk8fk66PbHCtgn9uTmc5uz6fZznwrVSL2 QkkfvjjMw9QyCsrsrm7th/8nfA== X-Google-Smtp-Source: AGRyM1tdhHdnc0+kLaMgT+DSUtvNUQ6MYukrPIjnrcDDwpD5alDBnl2zxdr7erzLSb7RAc4DC3BhqQ== 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: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655451712; a=rsa-sha256; cv=none; b=I+no85GnZe1yeI3qmzq3OXIgNARuk6JI5WRArW7kf67i4epdywvTH5JXRsLU05CWPRB/7o u04b2Lfz0tsbqwMQ9CopGJeBW9CCGzUYxk1VHBcHCJd2fOVdoLzasSO6XV8tGDnJY6Uscd SnHZD/b68XLSom0sd9zc9uP7I8nTIL4= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=KwEEf3ud; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf08.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655451711; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=g0u/GOzU5BM3qUn8umbjZw50kUmeU2XoJmxQaCg7nLU=; b=tF9/yU5UfdI0LG1G337s2Rgeps6R1uFbFCj9tnw/RtRu95gdQ4olPq8oSOL+fhjswjj9Lg BeZ9x4h03YcZFL9xNDpKAtw+bEsdpYOgjNTr8AwAayA48cNQSLXrdCfa+C+IljyR+uLsT6 5eIfLrTCrDvO+zlsOHTY73Nqd0M1Q+8= X-Rspamd-Queue-Id: 6E82B16008C X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=KwEEf3ud; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf08.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspamd-Server: rspam06 X-Stat-Signature: f5wmdx1wqngo3dq45f41dbspfksuricu X-HE-Tag: 1655451711-777874 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.