From patchwork Wed Mar 2 08:37:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12765617 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 067B2C433EF for ; Wed, 2 Mar 2022 08:38:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D27A8D0005; Wed, 2 Mar 2022 03:38:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7826C8D0001; Wed, 2 Mar 2022 03:38:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 671998D0005; Wed, 2 Mar 2022 03:38:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id 593AA8D0001 for ; Wed, 2 Mar 2022 03:38:21 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 0F6289F325 for ; Wed, 2 Mar 2022 08:38:21 +0000 (UTC) X-FDA: 79198794402.19.5AFD0DB Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf31.hostedemail.com (Postfix) with ESMTP id 98FA320005 for ; Wed, 2 Mar 2022 08:38:20 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id mg21-20020a17090b371500b001bef9e4657cso810724pjb.0 for ; Wed, 02 Mar 2022 00:38:20 -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=G5CCJorcD+mvdq6Rx3y5zrdO9Uswo4f2HKicBJt0MzQd5dDmOGdcpF5Q0T5Sb+0dMe 5Gh1k3gXFNEWbH8soeJvSqYskqaD8UIrfXhIbIZBJUvCoyOAUIlV90YNP9qy8+iB/ocD Xb6khWfXY6hJSuTWWhVIJQ5JO67wyCMgGKs/udM/CHgixLogCFxvXwpqr0oet2xKig0W 0HSsd5g99k3fdPHKiaprYso/2/8m4zlPpcL+YcAUzQ2mbDElyCAN1eccs9UdJZqorU/p mNdMO7mjcCYhtJPqtnIo8RbIlPjV8CS2QQbKSEsPE6xsiveggCAQsm8VeiNcWAjZ85av U3cg== 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=7osUpUtST0h940UHok0ey69F0qtk7V1JoL0CqxDTuDLxdLm2qvyndnfMTNLFtAi93J XBhLXMNqhdSBrffRXD9RsC9E1qv2r1woRjLqCsp7IxwM1HV/GurPtpevZEGwZcAOozvm OdsfEFKLAzawG8WWwOobJd00a1CF+G6BP91oV90dsw8zJ7bA2vcBlZOU3EZSpK8mdG5h XnY2vvyrx2bLzQCMSibpd497F5uuycj6wRGIXPzlZaOOjYMQkK58wXa815N/6MG7+z66 bGuB7TsO8xSxHjfMDSYL2RTH8uZFaC1smc8N5Cb9zm8csdlBHfYbkKU2aYwGmjrlgSf6 XR9A== X-Gm-Message-State: AOAM533J8vRSU/CYMBorNHDhQ/HJzWsmVwpEIYJ6hx8UdjYzoXlgNvc5 Oa2YAdqtDJfsAf2ZLlm//obEJQ== X-Google-Smtp-Source: ABdhPJxo987uh2sy4iVBcpuO3RBDBmmhqeJ+aQAyhMLaM+8AbMNcaI4YlJ2ED9/26vh1UTb91s0bdw== X-Received: by 2002:a17:90b:4b90:b0:1be:fd89:5402 with SMTP id lr16-20020a17090b4b9000b001befd895402mr769942pjb.117.1646210299670; Wed, 02 Mar 2022 00:38:19 -0800 (PST) Received: from FVFYT0MHHV2J.bytedance.net ([61.120.150.70]) by smtp.gmail.com with ESMTPSA id 17-20020a056a00071100b004f0f941d1e8sm18705141pfl.24.2022.03.02.00.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 00:38:19 -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, smuchun@gmail.com, Muchun Song Subject: [PATCH v2 1/3] mm: hugetlb: disable freeing vmemmap pages when struct page crosses page boundaries Date: Wed, 2 Mar 2022 16:37:56 +0800 Message-Id: <20220302083758.32528-2-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220302083758.32528-1-songmuchun@bytedance.com> References: <20220302083758.32528-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 98FA320005 X-Rspam-User: Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=G5CCJorc; spf=pass (imf31.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Stat-Signature: 5xu69mzy7a1x4snxx3btphquy4wj53oh X-HE-Tag: 1646210300-286912 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