From patchwork Sat Dec 17 10:58:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13075815 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 6EC10C3DA6E for ; Sat, 17 Dec 2022 10:58:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 663D38E0005; Sat, 17 Dec 2022 05:58:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 613A48E0001; Sat, 17 Dec 2022 05:58:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48CC48E0005; Sat, 17 Dec 2022 05:58:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3C3138E0001 for ; Sat, 17 Dec 2022 05:58:58 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1A4B680936 for ; Sat, 17 Dec 2022 10:58:58 +0000 (UTC) X-FDA: 80251500756.30.9983797 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by imf26.hostedemail.com (Postfix) with ESMTP id 76816140002 for ; Sat, 17 Dec 2022 10:58:56 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gmNhZUpz; spf=pass (imf26.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.216.54 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=1671274736; 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=zGtcBIBUfhLfuojWh++ev934zIQlEdFczfQrOY5ttcA=; b=HrzXAYFzgXGRqihtuwlfTTSDlnokYFG3VVu/4TdqSEeUBVG9LBqr30pXEBo9KKGoelzzX5 l6ZLlsKrxoPTzjkXTrXHY2xoBH4pwNSB/6Qd7J5Woq3bV+hharhygg7WH+a1ja63WPJ5bk oMJ1mVhsfeu3vii/qfZPgQo7IgmG6oc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gmNhZUpz; spf=pass (imf26.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.216.54 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=1671274736; a=rsa-sha256; cv=none; b=FqHNLg11UZsK/sdZlIqFlR4R9DmaDZa6W/wSioGMPmpIEiJGBvsFMIMccNarPWCS/KefV1 hgCwTF6sPG9mUCkFt3F5JAiFy6Jv2RLqlwjneGOAwAsH9SOB8JUxUrWdoIR8Uqsbb1Zc8u vPmAYPq95QPxjpQdyHRePf8v0ONttjE= Received: by mail-pj1-f54.google.com with SMTP id o1-20020a17090a678100b00219cf69e5f0so8560451pjj.2 for ; Sat, 17 Dec 2022 02:58:56 -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=zGtcBIBUfhLfuojWh++ev934zIQlEdFczfQrOY5ttcA=; b=gmNhZUpzp6hloXgPDrdYm+js8KM8oGUz4RoEPL8qMd5uk7RrsoS1YZ6uIO2DdXGx16 9GgmpmXbgPxf/HwpF9u3qbZxjhhzNwri4geXIi6jjYkW/iYYIIP31X5Mc3KKNXJsxB1/ S+Gt3KH/38IY0EJx3P5ji2beeqsHRgl8mOknhviq0tYTP5L8NSnPiWZSZ2KQkEqE/87q m7AmKzME5Hf8zDC2coAFkagXqRu9Uy/6mIsi6PtvZATbMi/O6NZVT+n7YAesHp0LvlGN yZrkBgzLoUPZMVLCgucQOdk5Z+6WDex9HfMsjM2TVI3ITuyT8TwqS6rRWvF1TRtNNLM/ +USA== 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=zGtcBIBUfhLfuojWh++ev934zIQlEdFczfQrOY5ttcA=; b=GGwZ6h5yKiyns9rH/9O506O7jf8rsaW9tS97AINipontzs8bLkeGB2RiRO6URNEw+j grPr2lRGFHdB5fcT6u+TARpMF9GKqoj3KhyHSTM3Qz4q+F5z74AVbBre1NV5vUVE2FS/ 6dTkjt1NrAJ46qWj5kGHyYETNRReAt2qk+W/Ss+UYh65qeZCmzCEirSirpE4IHWFdPk7 9WVQMmMYYinLvUsu3SvJSZ9us+9Wukxunxt9nHuZCnRo5TErs3q78VbMQ+f9gGUfB7FJ hye2qzjFs7WDCak9OIkZbNiDTemeboUdTOej/V88YdPUsA8qpRvjhlR0zE8xO8AgnN3P /gdg== X-Gm-Message-State: ANoB5pnXoxUApwU3w92BlOj8C2ntUNWbohSxjrE7ArzGj63E+BpNKSCw fdQxY5Gh6+NHxd2iT9QkWNA= X-Google-Smtp-Source: AA0mqf63o4O9RBsUnT44aWN6VWkFYvgMGQRxDyC41gIYrjFVkr5YHiKtTiG9UKOp5FXybj5c/nXA8g== X-Received: by 2002:a17:902:d4c3:b0:189:c322:df3a with SMTP id o3-20020a170902d4c300b00189c322df3amr49501096plg.43.1671274735433; Sat, 17 Dec 2022 02:58:55 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 02:58:54 -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 1/2] mm: page_owner: split page_owner's flag from the comm flags Date: Sat, 17 Dec 2022 10:58:32 +0000 Message-Id: <20221217105833.24851-2-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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 76816140002 X-Rspam-User: X-Stat-Signature: uiofxx5dhcbtfaosaikoibkbscfi35pm X-HE-Tag: 1671274736-804329 X-HE-Meta: U2FsdGVkX18sdIK6rGOjnnIvWpsrM57ptEwc+YxjjXYpmPHvkfnzufZTr/4MwhR0OSmLzTZG5FMaDp6isOgqIGxz8ldJqLb1VtXy+pwG4TX7mvXH1KGQOUEmSY+q/RJR3m0dm3xvnxafxFqw6hcyixvtE2J+T7u4TFiCUMmDd71ELUeDKKaAefEYZ5vcdP8HUD7Gv3P/Ke292IIufZCKs2l9OsO0Qjps3e8Wd1lyCJGdRHcyVuaxwIXDutlYwMcaafyRDOyDM7ZlnCYAbe1H2hrn4ed4Upz6BxOnk8KmZG/wfUrG1kQGOy5OQmnlEWmbtjUwL3w0tryRXq8mGW5uaIiQMwOE4dhMCuf1se/aX0TberGhTDxvc6enLLCKKtmCXqIYIkJPxTFHW9sEKUwuOoDPTycB96H1/9tzpjuOS+H0JI2w6PQX0ImKNctw/3XlZDnythtiw4iibT2UjY0yMl5mBC1oHfP6GXoefaIEGAXTSlqa7dPqDDyf1b/JV9IvV0GgMpHuDskgEBlyaJ3eWRtvrBuOQQHlFtA+kRQKUPk0a9EOjsW4V0hmCvLN5uJPfbPdg7tWHfNJibz6t9juRbv3sHPU2kieKlJkS8SgCuQHnMoNyCqaTmGatiOry5ZO682egOQhLtbkL8820OshoprkWZu/eZqDQtg3qM6CZF2UwfJG2CHKLz8XaCQyjs8aTOGhGZ0jw2tdxsmuPsOjOFavtKlXp342upRZOFeNgdeSwDppaKNgWkoJkpvQ9XIMv3aZxHhHX5W9bEZg83efTBUmWS7pC+GlW93/i9vvWko8AohtXP+vr90y+gHm9iqJzP5QMVR1bZ9ZjrDwpk6gwfhZp7+m7jUcLYLSNjxm06Sa6xWERiwiDMKWxqE9qjf6iP6sY61wb52Tp2lHONaIkWUdDTB2v4Sg8au3/fgNq7vQVmLJ9QkKx4YipQBFRhgpxxKyPR5ISTUYi2+Mrfr EGOELKPS qUbt/sS5wbyJAYjYKZbIkOz7qT9CX8VgDA7FelX0MBduH047F0xWUIs3mMChMM/WzGRFYoD6igcvpXMcWUVToqc54x08rRNVatPuSuq5aGmZYDujMuCrVkvWK2LjkwiFa1rC5/7aM7F8IWn1QPNDr2XTLHw/PfNUWSRYSyCj2EAawxCw1YfHEOuqCwPWDhWVcDWdTX0BAEIALvQEk+uU9lC/8NKMpjAQ6/qfRk+v42SE2n1OeyNhRhIBjLIdYQ4yXrGmIFxpn0FidT/Ikk1HCjI41bg== 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: We split page_owner's flag from the common page_ext's flag, temporarily this patch will increase the memory overhead of page owner. But considering the page owner is for debugging purpose only, it is acceptable. After we split all page exts' flags from the comm flags, we can reduce the memory overhead for the page ext which wants to run on production environment. Signed-off-by: Yafang Shao --- include/linux/page_ext.h | 6 ++---- mm/page_owner.c | 36 ++++++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h index 22be4582faae..c8ca4954145c 100644 --- a/include/linux/page_ext.h +++ b/include/linux/page_ext.h @@ -16,14 +16,12 @@ struct page_ext_operations { #ifdef CONFIG_PAGE_EXTENSION -enum page_ext_flags { - PAGE_EXT_OWNER, - PAGE_EXT_OWNER_ALLOCATED, #if defined(CONFIG_PAGE_IDLE_FLAG) && !defined(CONFIG_64BIT) +enum page_ext_flags { PAGE_EXT_YOUNG, PAGE_EXT_IDLE, -#endif }; +#endif /* * Page Extension can be considered as an extended mem_map. diff --git a/mm/page_owner.c b/mm/page_owner.c index 2d27f532df4c..f6e8ee8fa9c5 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -21,6 +21,11 @@ */ #define PAGE_OWNER_STACK_DEPTH (16) +enum page_owner_flag { + PAGE_EXT_OWNER, + PAGE_EXT_OWNER_ALLOCATED, +}; + struct page_owner { unsigned short order; short last_migrate_reason; @@ -32,6 +37,7 @@ struct page_owner { char comm[TASK_COMM_LEN]; pid_t pid; pid_t tgid; + unsigned long flags; }; static bool page_owner_enabled __initdata; @@ -147,8 +153,8 @@ void __reset_page_owner(struct page *page, unsigned short order) handle = save_stack(GFP_NOWAIT | __GFP_NOWARN); for (i = 0; i < (1 << order); i++) { - __clear_bit(PAGE_EXT_OWNER_ALLOCATED, &page_ext->flags); page_owner = get_page_owner(page_ext); + __clear_bit(PAGE_EXT_OWNER_ALLOCATED, &page_owner->flags); page_owner->free_handle = handle; page_owner->free_ts_nsec = free_ts_nsec; page_ext = page_ext_next(page_ext); @@ -174,8 +180,8 @@ static inline void __set_page_owner_handle(struct page_ext *page_ext, page_owner->ts_nsec = local_clock(); strscpy(page_owner->comm, current->comm, sizeof(page_owner->comm)); - __set_bit(PAGE_EXT_OWNER, &page_ext->flags); - __set_bit(PAGE_EXT_OWNER_ALLOCATED, &page_ext->flags); + __set_bit(PAGE_EXT_OWNER, &page_owner->flags); + __set_bit(PAGE_EXT_OWNER_ALLOCATED, &page_owner->flags); page_ext = page_ext_next(page_ext); } @@ -264,8 +270,8 @@ void __folio_copy_owner(struct folio *newfolio, struct folio *old) * in that case we also don't need to explicitly clear the info from * the new page, which will be freed. */ - __set_bit(PAGE_EXT_OWNER, &new_ext->flags); - __set_bit(PAGE_EXT_OWNER_ALLOCATED, &new_ext->flags); + __set_bit(PAGE_EXT_OWNER, &new_page_owner->flags); + __set_bit(PAGE_EXT_OWNER_ALLOCATED, &new_page_owner->flags); page_ext_put(new_ext); page_ext_put(old_ext); } @@ -325,10 +331,10 @@ void pagetypeinfo_showmixedcount_print(struct seq_file *m, if (unlikely(!page_ext)) continue; - if (!test_bit(PAGE_EXT_OWNER_ALLOCATED, &page_ext->flags)) + page_owner = get_page_owner(page_ext); + if (!test_bit(PAGE_EXT_OWNER_ALLOCATED, &page_owner->flags)) goto ext_put_continue; - page_owner = get_page_owner(page_ext); page_mt = gfp_migratetype(page_owner->gfp_mask); if (pageblock_mt != page_mt) { if (is_migrate_cma(pageblock_mt)) @@ -467,13 +473,13 @@ void __dump_page_owner(const struct page *page) gfp_mask = page_owner->gfp_mask; mt = gfp_migratetype(gfp_mask); - if (!test_bit(PAGE_EXT_OWNER, &page_ext->flags)) { + if (!test_bit(PAGE_EXT_OWNER, &page_owner->flags)) { pr_alert("page_owner info is not present (never set?)\n"); page_ext_put(page_ext); return; } - if (test_bit(PAGE_EXT_OWNER_ALLOCATED, &page_ext->flags)) + if (test_bit(PAGE_EXT_OWNER_ALLOCATED, &page_owner->flags)) pr_alert("page_owner tracks the page as allocated\n"); else pr_alert("page_owner tracks the page as freed\n"); @@ -556,22 +562,22 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos) if (unlikely(!page_ext)) continue; + page_owner = get_page_owner(page_ext); + /* * Some pages could be missed by concurrent allocation or free, * because we don't hold the zone lock. */ - if (!test_bit(PAGE_EXT_OWNER, &page_ext->flags)) + if (!test_bit(PAGE_EXT_OWNER, &page_owner->flags)) goto ext_put_continue; /* * Although we do have the info about past allocation of free * pages, it's not relevant for current memory usage. */ - if (!test_bit(PAGE_EXT_OWNER_ALLOCATED, &page_ext->flags)) + if (!test_bit(PAGE_EXT_OWNER_ALLOCATED, &page_owner->flags)) goto ext_put_continue; - page_owner = get_page_owner(page_ext); - /* * Don't print "tail" pages of high-order allocations as that * would inflate the stats. @@ -640,6 +646,7 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone) for (; pfn < block_end_pfn; pfn++) { struct page *page = pfn_to_page(pfn); + struct page_owner *page_owner; struct page_ext *page_ext; if (page_zone(page) != zone) @@ -667,8 +674,9 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone) if (unlikely(!page_ext)) continue; + page_owner = get_page_owner(page_ext); /* Maybe overlapping zone */ - if (test_bit(PAGE_EXT_OWNER, &page_ext->flags)) + if (test_bit(PAGE_EXT_OWNER, &page_owner->flags)) goto ext_put_continue; /* Found early allocated page */ 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