From patchwork Tue Jun 28 09:22:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12897949 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 61BACC433EF for ; Tue, 28 Jun 2022 09:23:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DDB1A8E0005; Tue, 28 Jun 2022 05:23:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D63D88E0001; Tue, 28 Jun 2022 05:23:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB6458E0005; Tue, 28 Jun 2022 05:23:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A554F8E0001 for ; Tue, 28 Jun 2022 05:23:54 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7DE0FC64 for ; Tue, 28 Jun 2022 09:23:54 +0000 (UTC) X-FDA: 79627107588.06.FF0D202 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf20.hostedemail.com (Postfix) with ESMTP id 175E91C0036 for ; Tue, 28 Jun 2022 09:23:53 +0000 (UTC) Received: by mail-pf1-f169.google.com with SMTP id 65so11439486pfw.11 for ; Tue, 28 Jun 2022 02:23:53 -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=g7r3zVYj3AvZ/3UidUc2ZI4PPOhwx3ZhlpO+4x/MXUA=; b=ZYRQ8+sE6n9u6F2XY8JCvWXwHfsNJkVRmGXVGMzdq4PLG7Ih9aIItBZtXjebp94oKv T+Z9BoixwlavlGo+fFGrnwD3vCjYJRtNsy222z6cPADrh7hflTPGEeo3ucVxuDoYjb4o ki+9urDmDyjqQL8kLeirpGizj19pLNX7gNAoQYWLOMo25EWLz4jS7SG9P+JNSckHpEja 2w8vIIVz6z01MSnU2CdAJJ/NE93gXAnpbvuifKgCGo3MwIRCXV/pQsfePV6oYDDIdODy MDYXzHlS2AE50nCgEZ824ZZ8+L9zEp7ZgSqZSE/XpB5kq+1QBNshwojokY/+y3EkoEW1 BH3Q== 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=g7r3zVYj3AvZ/3UidUc2ZI4PPOhwx3ZhlpO+4x/MXUA=; b=7pkgKIzGcAi8DDyxOgOtfYbspEEwTRRipf5v6Ctm1ueaI8yc7O44qE2MPEts/1zzaQ fKJyCmNw85NS0X3Ru9oxQI0UDr06q5pSIOBIADJwn8eH5yoi28X/3+y0l0Fd62ajeFKr 94fU/8YaFcVPSwuTzIFDfduEWKSUimFzOoLUhkm6JGyoFIf+C/x2omiJuVhwYpa7lx4J HAUzoZxvUSOhiXYOL2qwrEmPdSs28DpXu9x7Eh3MVWtc9zsgMQad+NcqxraZ7frTk+Oi OC9Ux5XVRfTHoXEkC4mM2Mvbv3IH0hz5OtdK8pujlOxB861uCO6R0LnPXmUXsxEB1+Sf VFRQ== X-Gm-Message-State: AJIora/pZRdOIZ0HhMSGQlDNerhHpzfEN8VgyciuhZw6bVxsRaq2X54E 1fgNwbNfA2vifMv41r1T3aFO2A== X-Google-Smtp-Source: AGRyM1v73L30amWxnk++qspTkF6VOQbffCogWNAnLP39+fpa769TYG6jfye+TfEhzCX83mAbbsbeug== X-Received: by 2002:aa7:81c1:0:b0:522:81c0:a646 with SMTP id c1-20020aa781c1000000b0052281c0a646mr3724444pfn.33.1656408233086; Tue, 28 Jun 2022 02:23:53 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id mm9-20020a17090b358900b001ec729d4f08sm8780463pjb.54.2022.06.28.02.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 02:23:52 -0700 (PDT) From: Muchun Song To: mike.kravetz@oracle.com, david@redhat.com, akpm@linux-foundation.org, corbet@lwn.net Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, duanxiongchun@bytedance.com, Muchun Song , Oscar Salvador , Catalin Marinas , Will Deacon , Anshuman Khandual Subject: [PATCH v2 1/8] mm: hugetlb_vmemmap: delete hugetlb_optimize_vmemmap_enabled() Date: Tue, 28 Jun 2022 17:22:28 +0800 Message-Id: <20220628092235.91270-2-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220628092235.91270-1-songmuchun@bytedance.com> References: <20220628092235.91270-1-songmuchun@bytedance.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=ZYRQ8+sE; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf20.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.169 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=1656408234; 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:in-reply-to:references:references:dkim-signature; bh=g7r3zVYj3AvZ/3UidUc2ZI4PPOhwx3ZhlpO+4x/MXUA=; b=FxoKIJDmV8C++KlYp8zh1BK2J7LdfCiEDZK/AMYTVo+FLMMo1tnEfna76oJZMdnan77Vlk ngkZWGbatKzR0QwXGNmAmLze6pfelbA15gu4CKsrpDFdpBQvNasdPgTagysuq4Qz8WeISk tcidHq8+9OqYUbh3/rqEe/Z5T+5pvPA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656408234; a=rsa-sha256; cv=none; b=fnRQmKNaEZBpRZ6pAoZF48alBwmgwg8FOEbztz474J22wxJtJC+BS/bVVAPIScx8MpPWwy tk69UdeEj75/DkCA8hbvpPJpjmRuepK9678oo/kB0FL6R4Q6YrPQF5r0m6BNHeSxrLqk72 xL65+BwD8cwWUaXW//fjEUR53SREGRk= X-Stat-Signature: z6fxjkii5dderthgzyuyn9i1us8wy1sy X-Rspamd-Queue-Id: 175E91C0036 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=ZYRQ8+sE; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf20.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1656408233-699287 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 name hugetlb_optimize_vmemmap_enabled() a bit confusing as it tests two conditions (enabled and pages in use). Instead of coming up to an appropriate name, we could just delete it. There is already a discussion about deleting it in thread [1]. 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). So it is easy to remove hugetlb_optimize_vmemmap_enabled(). Link: https://lore.kernel.org/all/c77c61c8-8a5a-87e8-db89-d04d8aaab4cc@oracle.com/ [1] Signed-off-by: Muchun Song Reviewed-by: Oscar Salvador Reviewed-by: Mike Kravetz Reviewed-by: Catalin Marinas Cc: Catalin Marinas Cc: Will Deacon Cc: Anshuman Khandual --- arch/arm64/mm/flush.c | 13 +++---------- include/linux/page-flags.h | 14 ++------------ 2 files changed, 5 insertions(+), 22 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 ea19528564d1..2455405ab82b 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -208,12 +208,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 @@ -232,7 +226,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; /* @@ -260,11 +255,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)