From patchwork Sat Dec 17 10:58:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13075816 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 55323C4332F for ; Sat, 17 Dec 2022 10:59:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2AEF8E0006; Sat, 17 Dec 2022 05:59:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DDAE08E0001; Sat, 17 Dec 2022 05:59:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7B878E0006; Sat, 17 Dec 2022 05:59:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B88B88E0001 for ; Sat, 17 Dec 2022 05:59:00 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 898DE805C6 for ; Sat, 17 Dec 2022 10:59:00 +0000 (UTC) X-FDA: 80251500840.14.7E92A0C Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf23.hostedemail.com (Postfix) with ESMTP id EBAF9140006 for ; Sat, 17 Dec 2022 10:58:58 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=A4RLYhSC; spf=pass (imf23.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.175 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671274739; 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=QxGyKPfs+sngV8OdRh4vtvFJGrpA3J8U9SbnqqHNdtU=; b=ESpb9IfZn2jDVKva9W8wzFHfFuqwjd54nR9hK0z0tNiYOiQEq9GajKUAH34avBO2X4BmMf Uvb75OTd9rR8At7m2XzyqorNnnnsht9mN3nygGoRv9nNh/tlT71iM1p+IYer0x9lIwTYF4 aVtlJua9bFGAunFMRzX3mUtwrqZ4giM= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=A4RLYhSC; spf=pass (imf23.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.175 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671274739; a=rsa-sha256; cv=none; b=LtvLTLGz7SAoEOp3TCzcLmoD0PWeiqFXglwlqV/qm/rUtRG9Sr5PMEerSdiXbqPRfQeXIB RwXpjYSIaP362fgdGjf/SNCdEmuaT7ne6v0y+k3ZMZT0/SmxSswJ02kdNHIQMDfA02Ja3f Q0Y2ASfuwuDmBRyzcP7Fb2QF6/Bu0fQ= Received: by mail-pl1-f175.google.com with SMTP id t2so4714161ply.2 for ; Sat, 17 Dec 2022 02:58:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QxGyKPfs+sngV8OdRh4vtvFJGrpA3J8U9SbnqqHNdtU=; b=A4RLYhSCjMbY+Hi8V2eZ96PNQkxOiISKxvCXMgczx9/PzYvBPbRA0TqS4BzjU+SXQx n5ytDgM5W/ssopGYlhPDVK3jhJahFlqmKEFaoVfhoRvDEtXjEa2N2yYxhkhVRX8cZLWh mKg0eAveigBHaVNWkVPMRje7D+OY1YWlRxSuTjwBOkArCt0Hgnwug6SkjPiThbQX87NM P/0BifGwXNtqNHsbXr2JtGLI1p/OYm++eG8SmDDj9Fe3/7/3VL430GzRLq7NIh3g7c7I ljpAMNmCZ3F5Tfy7vnjpwB3B1N50BH9XElKcK+1Iph46WygJMJKk8pjUurPIliBmsVfk Q+sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QxGyKPfs+sngV8OdRh4vtvFJGrpA3J8U9SbnqqHNdtU=; b=L7Dg5kGkG4FfotjPuGt4My40uZ+XyGOYj8pvi1ETMUfUT3Q2idxrzNMy107shLUn0X ZhFcc4y0H0uuyI0K7Rhd7C6h0dm7wLp0j8fZcL5OdBEnQdUsOR7Di84L7enO7/X22C3s MHXoMoUHq1WJs3MfRr5VnsvvKGIe3R32Oxrqk9xqgX/+xJdq2T1a5/C0LD99wZXLJIZE lvor+pH/X3G5CcNsy/o+zd+zIkWKVugs+vpEDMu3EKp132HEFv80BkeyGGLIdgE02IyL 3+1+B1tGOvbutKL7PKwgky2fNHBCeJC3hT98X8BU1iZFw6IAx8GBbIB9hqeP/zeaQNit XCxQ== X-Gm-Message-State: ANoB5plchJzmR3+60i+YAowTyhYBb9hZQbIn6SlLcBi2VZ9QWBQzo1a/ y42yBV2CYMlD6LS3JCFPe0c= X-Google-Smtp-Source: AA0mqf7G48s5/7ErvWk55YmR4gUMrizLAEHnhQdaUeTYH69rl86cquugZU7uVvhB297pYqrqHXzA3g== X-Received: by 2002:a17:902:6901:b0:185:441e:4cfa with SMTP id j1-20020a170902690100b00185441e4cfamr35243617plk.42.1671274737847; Sat, 17 Dec 2022 02:58:57 -0800 (PST) Received: from vultr.guest ([2001:19f0:7001:12a1:5400:4ff:fe3e:f0b8]) by smtp.gmail.com with ESMTPSA id q10-20020a170902daca00b00185402cfedesm3226690plx.246.2022.12.17.02.58.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 02:58:57 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: vbabka@suse.cz, 42.hyeyoo@gmail.com, willy@infradead.org, linux-mm@kvack.org, Yafang Shao Subject: [PATCH -mm 2/2] mm: page_idle: split 32bit page_idle's flag from the common flags Date: Sat, 17 Dec 2022 10:58:33 +0000 Message-Id: <20221217105833.24851-3-laoar.shao@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221217105833.24851-1-laoar.shao@gmail.com> References: <20221217105833.24851-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Stat-Signature: dk4bpde6pg5oz6u4miarhp5mt61545ms X-Rspam-User: X-Rspamd-Queue-Id: EBAF9140006 X-Rspamd-Server: rspam06 X-HE-Tag: 1671274738-434799 X-HE-Meta: U2FsdGVkX1/pzng1X4G1/IuMDwwXedyZqsF/kcqrpWI4gw/ka4Ffr5uHGD/h1ufCD4CqH1qqLYDKOdmtkELizp2gkqgwwMJyPH5v5cwUChsIqaoXrLK+0TrzuIpLqb1MtGS8Ga68joKLhARGt8nQ466JLCiPQgPuZsJ0z6RXGzZP0pY5QPBgCfcS0V4s585exNWBMTUoUzBo1z1Xnh6KumPkExIvCUfG70oh67Mj20FXmaCSdp3qb4RPHMiXRPvVI0aWSspyEdG+J0QRzeWLlmPVPS49V80g4xiOUnTnS6bcC+eR1YSG3ZM90JWyigJSKfD4n73NPv+jsnHqfAgRyxdMolIbLUQw/1MT2jkVYLlw66OshrqKMO9hZ+O1j48CJ6FKC+iTZ8Zn8gBS2PJ5+2YNcEoFHks86UzeStmt4mPUEAiqqXtwfk7BGpZYZ/Cd4iduaHf8c7wX8W8z4eVgqapWiPE3EABUZ2CUfXDa3JZ+L8H7UlyLaoDrwgSST4Lsgo/S/z/IbBUYQ0ahwN2/BqE6yq6ekpFSvr/OU9GBAz8EexJYo5OnK3hy6nBmOD75kQ0Xh7tLdA9pbNLvbkDoYMFqH8+jB2rNrCGql3rTl8VEKh3Iskp3RctB1tKGZ6RaS8zgy10u9RKhfZ3fQQ+gfPF8UDmqpqW9tgahKhh60fbVdwJaS4/921pD3p+9+NKsMGG7YbrXU/X47ZQcscDoqPfHj0/jV8t/HfCnyTkoYx7FChlCdilJXAksz25NBG2fUbM7KeTinexGl7i/pYbdBar0rjzGg2Edf2JyKnR9hGutjDsb7Is12rhInMUXtKhA40L/DPrhkCSt4jjnBXICVYH9MSOK19aVoT1xElOHpM1FGyTJyQJMv5Oyx8UYtYFvFnn8nOO6dOMY/nSBGgcvx2WD6NMLrSITyQWzy+SMj7OykdfWGSo7uJTJRh8Q+4DIA1GmK6k697h3Tuq1XQ2 9Ky4kpqG rf+Pl+3ZX0nhTrVHzHxd0VgmKEKTfFmF03i+mUp0VZKHz/i+ZKjYEx1SjEgrGE6HOOU0dkqZBnlLSb5bjBnjqc5bBFvvu3/hjHhYzHgva3Y9vfoErLv6yyyxQ3Pf1VS4v8cVbhsZtfb3C/gJOychxyNNPDLbxxMwVCOKVG7styt0gtRpql6mEGTB8EuknPIV5MR7NhpP4hGopA6ivAqNGdxnTx1XGobDyyGEJKWN8bgmHgImyeeHEY3jfjdt6lQ1/KyoC9K0xDhT+Km8S5RihJyI1eA== 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: After we split page_owner's flag from the common page_ext flags, now only 32bit page_idle is using the commt flags. Then we can define a flag for 32bit page_idle only. After this patch, the size of struct page_ext will be 0, so it won't take extra memory overhead for the page_ext which don't use this flag. Signed-off-by: Yafang Shao --- include/linux/page_ext.h | 12 +----------- include/linux/page_idle.h | 39 +++++++++++++++++++++++++++++++++------ mm/page_ext.c | 10 ---------- mm/page_idle.c | 12 ++++++++++++ 4 files changed, 46 insertions(+), 27 deletions(-) diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h index c8ca4954145c..6515d2a62f34 100644 --- a/include/linux/page_ext.h +++ b/include/linux/page_ext.h @@ -15,14 +15,6 @@ struct page_ext_operations { }; #ifdef CONFIG_PAGE_EXTENSION - -#if defined(CONFIG_PAGE_IDLE_FLAG) && !defined(CONFIG_64BIT) -enum page_ext_flags { - PAGE_EXT_YOUNG, - PAGE_EXT_IDLE, -}; -#endif - /* * Page Extension can be considered as an extended mem_map. * A page_ext page is associated with every page descriptor. The @@ -30,9 +22,7 @@ enum page_ext_flags { * All page_ext are allocated at boot or memory hotplug event, * then the page_ext for pfn always exists. */ -struct page_ext { - unsigned long flags; -}; +struct page_ext {}; extern bool early_page_ext; extern unsigned long page_ext_size; diff --git a/include/linux/page_idle.h b/include/linux/page_idle.h index 5cb7bd2078ec..4d1311fdae1d 100644 --- a/include/linux/page_idle.h +++ b/include/linux/page_idle.h @@ -9,6 +9,21 @@ #ifdef CONFIG_PAGE_IDLE_FLAG #ifndef CONFIG_64BIT +enum page_idle_flags { + PAGE_EXT_YOUNG, + PAGE_EXT_IDLE, +}; + +struct page_idle { + unsigned long flags; +}; + +extern struct page_ext_operations page_idle_ops; +static inline struct page_idle *get_page_idle(struct page_ext *page_ext) +{ + return (void *)page_ext + page_idle_ops.offset; +} + /* * If there is not enough space to store Idle and Young bits in page flags, use * page ext flags instead. @@ -16,12 +31,14 @@ static inline bool folio_test_young(struct folio *folio) { struct page_ext *page_ext = page_ext_get(&folio->page); + struct page_idle *pi; bool page_young; if (unlikely(!page_ext)) return false; - page_young = test_bit(PAGE_EXT_YOUNG, &page_ext->flags); + pi = get_page_idle(page_ext); + page_young = test_bit(PAGE_EXT_YOUNG, &pi->flags); page_ext_put(page_ext); return page_young; @@ -30,23 +47,27 @@ static inline bool folio_test_young(struct folio *folio) static inline void folio_set_young(struct folio *folio) { struct page_ext *page_ext = page_ext_get(&folio->page); + struct page_idle *pi; if (unlikely(!page_ext)) return; - set_bit(PAGE_EXT_YOUNG, &page_ext->flags); + pi = get_page_idle(page_ext); + set_bit(PAGE_EXT_YOUNG, &pi->flags); page_ext_put(page_ext); } static inline bool folio_test_clear_young(struct folio *folio) { struct page_ext *page_ext = page_ext_get(&folio->page); + struct page_idle *pi; bool page_young; if (unlikely(!page_ext)) return false; - page_young = test_and_clear_bit(PAGE_EXT_YOUNG, &page_ext->flags); + pi = get_page_idle(page_ext); + page_young = test_and_clear_bit(PAGE_EXT_YOUNG, &pi->flags); page_ext_put(page_ext); return page_young; @@ -55,12 +76,14 @@ static inline bool folio_test_clear_young(struct folio *folio) static inline bool folio_test_idle(struct folio *folio) { struct page_ext *page_ext = page_ext_get(&folio->page); + struct page_idle *pi; bool page_idle; if (unlikely(!page_ext)) return false; - page_idle = test_bit(PAGE_EXT_IDLE, &page_ext->flags); + pi = get_page_idle(page_ext); + page_idle = test_bit(PAGE_EXT_IDLE, &pi->flags); page_ext_put(page_ext); return page_idle; @@ -69,22 +92,26 @@ static inline bool folio_test_idle(struct folio *folio) static inline void folio_set_idle(struct folio *folio) { struct page_ext *page_ext = page_ext_get(&folio->page); + struct page_idle *pi; if (unlikely(!page_ext)) return; - set_bit(PAGE_EXT_IDLE, &page_ext->flags); + pi = get_page_idle(page_ext); + set_bit(PAGE_EXT_IDLE, &pi->flags); page_ext_put(page_ext); } static inline void folio_clear_idle(struct folio *folio) { struct page_ext *page_ext = page_ext_get(&folio->page); + struct page_idle *pi; if (unlikely(!page_ext)) return; - clear_bit(PAGE_EXT_IDLE, &page_ext->flags); + pi = get_page_idle(page_ext); + clear_bit(PAGE_EXT_IDLE, &pi->flags); page_ext_put(page_ext); } #endif /* !CONFIG_64BIT */ diff --git a/mm/page_ext.c b/mm/page_ext.c index 4ee522fd381c..b3459bf08b78 100644 --- a/mm/page_ext.c +++ b/mm/page_ext.c @@ -64,16 +64,6 @@ #define PAGE_EXT_INVALID (0x1) #endif -#if defined(CONFIG_PAGE_IDLE_FLAG) && !defined(CONFIG_64BIT) -static bool need_page_idle(void) -{ - return true; -} -static struct page_ext_operations page_idle_ops __initdata = { - .need = need_page_idle, -}; -#endif - static struct page_ext_operations *page_ext_ops[] __initdata = { #ifdef CONFIG_PAGE_OWNER &page_owner_ops, diff --git a/mm/page_idle.c b/mm/page_idle.c index bc08332a609c..ea1b08a541b3 100644 --- a/mm/page_idle.c +++ b/mm/page_idle.c @@ -18,6 +18,18 @@ #define BITMAP_CHUNK_SIZE sizeof(u64) #define BITMAP_CHUNK_BITS (BITMAP_CHUNK_SIZE * BITS_PER_BYTE) +#ifndef CONFIG_64BIT +static bool need_page_idle(void) +{ + return true; +} + +struct page_ext_operations page_idle_ops __initdata = { + .size = sizeof(struct page_idle), + .need = need_page_idle, +}; +#endif + /* * Idle page tracking only considers user memory pages, for other types of * pages the idle flag is always unset and an attempt to set it is silently