Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3257039iob; Mon, 16 May 2022 17:20:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLscKvQcM6VZsDzlsIb/R+Tuo+EvcR9wpXoCtrAXKFyHhtd7qPfl6DU+yVTrahJiaG8vwE X-Received: by 2002:a05:6402:1257:b0:42a:aae6:d5b2 with SMTP id l23-20020a056402125700b0042aaae6d5b2mr10665802edw.297.1652746830161; Mon, 16 May 2022 17:20:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652746830; cv=none; d=google.com; s=arc-20160816; b=TThUVt2NEsJFBAvlMmmDKMQEmLc30s4diEPVnxdm//wlq6KPN79X1mgMmHghirEu6f Aem6NR1i7TSgbZ0DM5N3ZeYpV3XtfCN4mnSmpmeJl/DeMli00ncgbFRTB2P1CtUxna0+ xoSfaF6iOjfiFrzNrDNd8PrM2QnhfDR95dOpIrDA9OLxX3Eu1F1Rt4d/Qml8a1jiE7R1 XxeIW0oydmwebObMXe3r6TCr9fzm6ARUrV8bSQegidz1gnW76AoUwcULOKA6DQz00Xnp h7VDIYjCXzCowB8qxs3uroZURUnoWrLwJfsgZUxr2cITBP7WcdKdJldnhOypELKi9eno VOww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jSjHlEJZ1lWJ5sUgf+NErUi604xPZiJFf+96LoXPZRA=; b=lPDdYS1otQIBM+/6D24Ppnbl7wiKdby8dyZHN5uOVpLQqIPRhX32ACXQnOSkvYvguA Pwi6eb9/EHZhihCxZjBlNd0wRV7DCR5ySmm06r9VswbsNH6eBPXisBJh0t9eWR2fCjFk h71nIkUs6BLweAYuWyuXLZuQh+bfvsBm4X01j8D4tA7rtOapFg1CFVHBTS/9gjrGUr6x gFcs3wg8HFk0yjpUkftoJ5M4jH46prppRnt5RgJ9nyEU3YtmGL3WKhrUgmWCihwlK5cS jvflw1V8RUDwq6bmm+/m0rV9uaGSEcoBGFcMxaqL8zt6WohuuAqgi9fS3D7opHDwW6ct jorA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=tvaEqhT5; 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 z3-20020a056402274300b0041d70e6ea5bsi14716452edd.533.2022.05.16.17.20.04; Mon, 16 May 2022 17:20:30 -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=tvaEqhT5; 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 S242521AbiEPKYO (ORCPT + 99 others); Mon, 16 May 2022 06:24:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242616AbiEPKYB (ORCPT ); Mon, 16 May 2022 06:24:01 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E79BDDF5F for ; Mon, 16 May 2022 03:23:32 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id t11-20020a17090a6a0b00b001df6f318a8bso823174pjj.4 for ; Mon, 16 May 2022 03:23:32 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=jSjHlEJZ1lWJ5sUgf+NErUi604xPZiJFf+96LoXPZRA=; b=tvaEqhT5/0VShTdmGcoV7QtkaEOFtFRpQgSee1AARQzV7qYhbtTSIUiemTABLiPqRJ wO0IWpVnGfUGXIuoRzl/oYax5/wlxFS7PIMUc9w28HhTQ9vupeD5RBq5b+SWjGq4BUQ+ daFSBYXRBJyH7Mb0rqkhKeUBYrwF2/lSQtUUcPp9B5FpIXRdP+dp11fvmMhY3RQwUct8 Qn6SF5MYrU6EgxrBpTj+oTe7c8e/pZXcdGtirgqcBmgBpO8pECK6KjYP7pzgUhQvU8BN XmKyNkvkbG2dH7BgTbrwpssZKSaxayfFF0JxUZ9QyiXXmkeT0M59bXNImnZ/bz6nZsY5 ASBw== 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=jSjHlEJZ1lWJ5sUgf+NErUi604xPZiJFf+96LoXPZRA=; b=KNd539p0MMSveEwmMozo6y0kuY4VxZwtPYlsjziYZpJGSvEEDtdRgc+nsvUntghcg4 KilaYPC3JPf2SVx8Z0DBBfsWaC8ManXapYmA/lPe7sqN3gFCfOLKy3QUHqMf3O4DwpeP 1PZOWRfp0cHFqb4+qM8RIO4vbWHBi5kY1rIcImFUW47CwZhcdDxmO0TDL5jFLW8XvxRe V0fHNeLVEgiG7QrB//KRlYhL20AGzymz7Qrqq1gV7TI+PVKbLJyvHWZxSacekiPNzvYn h1Y0MFpiXHygnCOeZn30hA+uGoKtEEI/6zxRxgMGCIum1F1RGHO+QabcnBsR0tHd8H0X bjag== X-Gm-Message-State: AOAM533g08FlRttA3+EueQdghmISIe4inpH0PYZc7pEGMTE64Q3PWJ1A SytRqOZBrEV1Ca7QsLJfVYVWNQ== X-Received: by 2002:a17:90b:1249:b0:1df:257a:539a with SMTP id gx9-20020a17090b124900b001df257a539amr9957427pjb.47.1652696612277; Mon, 16 May 2022 03:23:32 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id i9-20020aa79089000000b0050dc76281e4sm6472731pfa.190.2022.05.16.03.23.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:23:32 -0700 (PDT) From: Muchun Song To: corbet@lwn.net, mike.kravetz@oracle.com, akpm@linux-foundation.org, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com, osalvador@suse.de, david@redhat.com, masahiroy@kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, smuchun@gmail.com, Muchun Song , Catalin Marinas , Will Deacon , Anshuman Khandual Subject: [PATCH v12 5/7] mm: hugetlb_vmemmap: remove hugetlb_optimize_vmemmap_enabled() Date: Mon, 16 May 2022 18:22:09 +0800 Message-Id: <20220516102211.41557-6-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220516102211.41557-1-songmuchun@bytedance.com> References: <20220516102211.41557-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=unavailable 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 There is only one user of hugetlb_optimize_vmemmap_enabled() outside of hugetlb_vmemmap, that is flush_dcache_page() in arch/arm64/mm/flush.c. However, it does not need to call hugetlb_optimize_vmemmap_enabled() in flush_dcache_page() since HugeTLB pages are always fully mapped and only head page will be set PG_dcache_clean meaning only head page 's flag may need to be cleared (see commit cf5a501d985b). After this change, there is no users of hugetlb_optimize_vmemmap_enabled() outside of hugetlb_vmemmap. So remove hugetlb_optimize_vmemmap_enabled() to simplify the code. Signed-off-by: Muchun Song Cc: Catalin Marinas Cc: Will Deacon Cc: Anshuman Khandual --- arch/arm64/mm/flush.c | 13 +++---------- include/linux/page-flags.h | 14 ++------------ mm/hugetlb_vmemmap.c | 3 ++- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c index fc4f710e9820..5f9379b3c8c8 100644 --- a/arch/arm64/mm/flush.c +++ b/arch/arm64/mm/flush.c @@ -76,17 +76,10 @@ EXPORT_SYMBOL_GPL(__sync_icache_dcache); void flush_dcache_page(struct page *page) { /* - * Only the head page's flags of HugeTLB can be cleared since the tail - * vmemmap pages associated with each HugeTLB page are mapped with - * read-only when CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP is enabled (more - * details can refer to vmemmap_remap_pte()). Although - * __sync_icache_dcache() only set PG_dcache_clean flag on the head - * page struct, there is more than one page struct with PG_dcache_clean - * associated with the HugeTLB page since the head vmemmap page frame - * is reused (more details can refer to the comments above - * page_fixed_fake_head()). + * HugeTLB pages are always fully mapped and only head page will be + * set PG_dcache_clean (see comments in __sync_icache_dcache()). */ - if (hugetlb_optimize_vmemmap_enabled() && PageHuge(page)) + if (PageHuge(page)) page = compound_head(page); if (test_bit(PG_dcache_clean, &page->flags)) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index b70124b9c7c1..404f4ede17f5 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -203,12 +203,6 @@ enum pageflags { DECLARE_STATIC_KEY_MAYBE(CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON, hugetlb_optimize_vmemmap_key); -static __always_inline bool hugetlb_optimize_vmemmap_enabled(void) -{ - return static_branch_maybe(CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON, - &hugetlb_optimize_vmemmap_key); -} - /* * If the feature of optimizing vmemmap pages associated with each HugeTLB * page is enabled, the head vmemmap page frame is reused and all of the tail @@ -227,7 +221,8 @@ static __always_inline bool hugetlb_optimize_vmemmap_enabled(void) */ static __always_inline const struct page *page_fixed_fake_head(const struct page *page) { - if (!hugetlb_optimize_vmemmap_enabled()) + if (!static_branch_maybe(CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON, + &hugetlb_optimize_vmemmap_key)) return page; /* @@ -255,11 +250,6 @@ static inline const struct page *page_fixed_fake_head(const struct page *page) { return page; } - -static inline bool hugetlb_optimize_vmemmap_enabled(void) -{ - return false; -} #endif static __always_inline int page_is_fake_head(struct page *page) diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 970c36b8935f..d1fea65fec98 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -124,7 +124,8 @@ void __init hugetlb_vmemmap_init(struct hstate *h) BUILD_BUG_ON(__NR_USED_SUBPAGE >= RESERVE_VMEMMAP_SIZE / sizeof(struct page)); - if (!hugetlb_optimize_vmemmap_enabled()) + if (!static_branch_maybe(CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON, + &hugetlb_optimize_vmemmap_key)) return; if (!is_power_of_2(sizeof(struct page))) { -- 2.11.0