From patchwork Thu Jun 16 03:38:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12883286 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 45E28C433EF for ; Thu, 16 Jun 2022 03:38:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C26CF6B0074; Wed, 15 Jun 2022 23:38:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BD6556B0075; Wed, 15 Jun 2022 23:38:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9EAD6B0078; Wed, 15 Jun 2022 23:38:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9ABF26B0074 for ; Wed, 15 Jun 2022 23:38:58 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7728A35209 for ; Thu, 16 Jun 2022 03:38:58 +0000 (UTC) X-FDA: 79582692756.10.928DFA1 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf12.hostedemail.com (Postfix) with ESMTP id BB80440086 for ; Thu, 16 Jun 2022 03:38:57 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id 187so356700pfu.9 for ; Wed, 15 Jun 2022 20:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aA0bMLWCkX8joHM6kPyEJlVGECicVquhYI8922nCQz4=; b=ErYObbUHDVmgvnYdsWtz3niZfP5DYxbLeCOUtZgeWlKf0L9+ZDj0vFxlsunSw7B0CP EG+l69sWFVL15VSVbXEgMYqXhthBc4nFZmg9Cab3qwnYpBFvObiJTLVLR6ieFcstYNAX 5FTuobf27g+Hy9kMI1iKncJXhpUhipwL2QnA8ekZq3XtMjHXb3ktTsCOiDIVvvHKpk4C Nhq38qJBY+a3p7UQoAniqj/elhforsnXbi3hRqf/XvehRihXA3FaVWkQauau1Lfwg6lU Z52/f18hEm2Jxa5xF5t4lQvA+jD7VV/vDo/0rFH7H5yZUyzw6fzfjD9eXudckKgFxIRe X14Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aA0bMLWCkX8joHM6kPyEJlVGECicVquhYI8922nCQz4=; b=VbUwkK+rJcaTZEr3y9KA6skQYtRK3CFvNzX18Q6Rz+mLBGQGlF/SAnHyGOANfbH0Jf I6A3jjphA/IlGCtwZE5WXWsB2nfHTIW2BAEbbLvio8u5BwPMnJUS/mASoE2Xi2YN3Cw4 f+JkcIvzJANqIxpEGr58w7v47qPgDins9AYwSYLVXijD9PLYPzByhURQKicO3v7WSozG oNgwTz/DKTHztPZ6cTz8zbcNU5ZZtxfA3ePvrZQT4t1u+uaRleRV9B0WUOK4VP4KFf+s TGpKxdcf/CnofN/HSCzZ4nnFfTFP5QAcck43PBAsjvw0So5KL/D/AcsdALjo8aRycLMm FZXw== X-Gm-Message-State: AJIora936SbdLj09cZHymucsMHEclipFwaA3Btt71pnK59t5K+1OtF3Z 9+5hkMctML8kbDLh9VDDlFJuww== X-Google-Smtp-Source: AGRyM1tXAvYaFZ/5GuRhLfbNjT24Z2aXZm5tmRhpuKjL0KuJWz9SCQ8gTxJg7ujAwbdGV2E3KSMLEQ== X-Received: by 2002:a65:5b08:0:b0:401:cf39:c35c with SMTP id y8-20020a655b08000000b00401cf39c35cmr2688285pgq.396.1655350736495; Wed, 15 Jun 2022 20:38:56 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id h189-20020a62dec6000000b0050dc762813csm441308pfg.22.2022.06.15.20.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 20:38:56 -0700 (PDT) From: Muchun Song To: mike.kravetz@oracle.com, songmuchun@bytedance.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: hugetlb: remove minimum_order variable Date: Thu, 16 Jun 2022 11:38:46 +0800 Message-Id: <20220616033846.96937-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655350738; a=rsa-sha256; cv=none; b=wNwcl3LELnAaU9eQD+KFIQXd84FVdGII7CK90ENhpoSluEzf62nhTy4GrqMVYQGnAhIP2b wCqP3bxkUEeEbIcJawTC/Y3go3as467iKR48GlKFxVEghRfME+HhELdkZKhEYOFXfS7bS8 QGop4y3x6BnpIbpfTbd3vbCCzM99w3s= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=ErYObbUH; spf=pass (imf12.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655350738; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=aA0bMLWCkX8joHM6kPyEJlVGECicVquhYI8922nCQz4=; b=UhqHOm3NvOBr8rItYqfCEmWb0PaM8t4gU7YXuhOyebH723w0/aOt8eftK8H9GgYv0GNCvu pHkYj1xdrx5p2bXcYYEcPW2nzmzRQv7QdaTTBeU9yxaykGYg3VgaygDZveHy9gCwfRTJ7K xtBjqwZD0KfA2bxosGEim/E03WaK4o8= X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: BB80440086 X-Stat-Signature: 3npzgqbty7b38e8uomcthnzzf4ppkm9f Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=ErYObbUH; spf=pass (imf12.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1655350737-445847 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: 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 Reviewed-by: Oscar Salvador Reviewed-by: Mike Kravetz --- 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)); + + for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << order) { page = pfn_to_page(pfn); rc = dissolve_free_huge_page(page); if (rc) @@ -3157,9 +3157,6 @@ static void __init hugetlb_init_hstates(void) struct hstate *h, *h2; for_each_hstate(h) { - if (minimum_order > huge_page_order(h)) - minimum_order = huge_page_order(h); - /* oversize hugepages were init'ed in early boot */ if (!hstate_is_gigantic(h)) hugetlb_hstate_alloc_pages(h); @@ -3184,7 +3181,6 @@ static void __init hugetlb_init_hstates(void) h->demote_order = h2->order; } } - VM_BUG_ON(minimum_order == UINT_MAX); } static void __init report_hugepages(void)