From patchwork Mon Feb 28 07:10:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12762466 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 92C7FC433EF for ; Mon, 28 Feb 2022 07:11:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32A4E8D0005; Mon, 28 Feb 2022 02:11:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D97E8D0001; Mon, 28 Feb 2022 02:11:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A0EB8D0005; Mon, 28 Feb 2022 02:11:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 0B04F8D0001 for ; Mon, 28 Feb 2022 02:11:33 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id BDC598249980 for ; Mon, 28 Feb 2022 07:11:32 +0000 (UTC) X-FDA: 79191318024.19.7FE85CA Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf29.hostedemail.com (Postfix) with ESMTP id 479AD120004 for ; Mon, 28 Feb 2022 07:11:32 +0000 (UTC) Received: by mail-pl1-f173.google.com with SMTP id p17so9912811plo.9 for ; Sun, 27 Feb 2022 23:11:32 -0800 (PST) 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:in-reply-to:references :mime-version:content-transfer-encoding; bh=oqE92Z30jLRB5qj639p7ReXjqJAONBgi3Xr8rqugwWc=; b=e2F/6vYuG7H/7yU5OibJdQw/ZPCcUdpXzvY1YCsl6iX6fv1pAnjbnW2Mjddjky6LK9 uzjUZZZJBhd2peqU+T3t4mdTPJv5YZaODOD3iKFHa6tL7PTAKR8rzj0atcTRNL0EMx/b NbZzF1mPZkhDn9fxn/XJ8FzqQbVEApgBQi+jQ8HqKqg0dmNOFHHpLCLs7R09wtLpqTNm RjIVCwzjknwpWcPrrul95klarohrfak/wSmWb1LisWOtHrPyj/27/KHtUnQhdxvdhF6u +fPqkPBrOhlguOPAehK38KtyA/LpERXHqg7GVrbY6tHr+WXEbixjZ3Hey8zQvbEjkJht DAXg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=oqE92Z30jLRB5qj639p7ReXjqJAONBgi3Xr8rqugwWc=; b=TbFQzuHj3MPz2ThycfS72qSE5/hYNOxDNiAP5fcccGdwDsJq8kcCKbPJSBxUt632y5 Wa3zIcmlJlf8tKP/GAnhNpPMzoQjMrA+TyM3sbsTKFqiWG1NzgQZgOA0gmPy1t7Y7+xO vWzjlcsbfxhH2voRuVZBra0pgRg82lU+M6vG4sQTC8sNl4fWQAx0mJTLKIj1iUQEGSMg /Dc4myK2cglNidiebL73N6kmtyKMdeXTME1yLKpW3ByTQz2ajRa+yydBuEk7W4uu/vk1 2zrAG1lELS3/8scBUOg6ixAL0gRNebje5jq+ltmHDTThGhGN3LvLUZrEV0HuGIa3i5eq Kl2Q== X-Gm-Message-State: AOAM532y+orUxS8O5khPWZz+pYaTNM4tE3NKWn8OO1JZssaQqMy6gPuW sWRwmKTEV/v/sg0ChVfaaYptsA== X-Google-Smtp-Source: ABdhPJzSxBRm2Jc+FR3haOpBiZvOJNWnMLPpmqPSQ2uOi05bt+bgbNRdMNtr3yqqrTJeLgu2AeKf1g== X-Received: by 2002:a17:902:da8a:b0:151:6240:b877 with SMTP id j10-20020a170902da8a00b001516240b877mr5078007plx.22.1646032291347; Sun, 27 Feb 2022 23:11:31 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.243]) by smtp.gmail.com with ESMTPSA id i7-20020a17090a65c700b001b936b8abe0sm16240390pjs.7.2022.02.27.23.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 23:11:31 -0800 (PST) From: Muchun Song To: corbet@lwn.net, mike.kravetz@oracle.com, akpm@linux-foundation.org, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, Muchun Song Subject: [PATCH 1/3] mm: hugetlb: disable freeing vmemmap pages when struct page crosses page boundaries Date: Mon, 28 Feb 2022 15:10:20 +0800 Message-Id: <20220228071022.26143-2-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220228071022.26143-1-songmuchun@bytedance.com> References: <20220228071022.26143-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 479AD120004 X-Stat-Signature: scy99tsfupwuk416ay9jqnd1tmg9994r Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="e2F/6vYu"; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf29.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-HE-Tag: 1646032292-500465 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: If CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON is enabled and the size of "struct page" is not power of two, we cannot optimize vmemmap pages of HugeTLB pages. We should disable this feature in this case. Signed-off-by: Muchun Song --- mm/hugetlb_vmemmap.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index b3118dba0518..836d1117f08b 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -121,6 +121,17 @@ void __init hugetlb_vmemmap_init(struct hstate *h) if (!hugetlb_free_vmemmap_enabled()) return; + if (IS_ENABLED(CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON) && + !is_power_of_2(sizeof(struct page))) { + /* + * The hugetlb_free_vmemmap_enabled_key can be enabled when + * CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON. It should + * be disabled if "struct page" crosses page boundaries. + */ + static_branch_disable(&hugetlb_free_vmemmap_enabled_key); + return; + } + vmemmap_pages = (nr_pages * sizeof(struct page)) >> PAGE_SHIFT; /* * The head page is not to be freed to buddy allocator, the other tail