From patchwork Mon Sep 2 12:24:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rong Qianfeng X-Patchwork-Id: 13787213 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 E0C75CD13CF for ; Mon, 2 Sep 2024 12:25:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0AFFB8D00D4; Mon, 2 Sep 2024 08:25:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 060008D0098; Mon, 2 Sep 2024 08:25:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1BB58D00D4; Mon, 2 Sep 2024 08:25:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C37BA8D0098 for ; Mon, 2 Sep 2024 08:25:53 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6642581C50 for ; Mon, 2 Sep 2024 12:25:53 +0000 (UTC) X-FDA: 82519719786.09.2515B4F Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2077.outbound.protection.outlook.com [40.107.255.77]) by imf05.hostedemail.com (Postfix) with ESMTP id E6B22100010 for ; Mon, 2 Sep 2024 12:25:49 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=DkH0goj1; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf05.hostedemail.com: domain of rongqianfeng@vivo.com designates 40.107.255.77 as permitted sender) smtp.mailfrom=rongqianfeng@vivo.com; dmarc=pass (policy=quarantine) header.from=vivo.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725279856; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=5hRT0pOvO7lfpsm388L41+nqwAtGmQPubJztREzsfdE=; b=AU8XfY1fvc2eBXEI19XFYDZn6TmpSg+jDiFw6ipvlOW2Ef83m0PCTxBSG38J8Fl0EDx8Rn GbgWp5VLPSvtV2svqIF6p6Xg9/i6CdvDspeqgNDLnPsXpvsCNnh10IZs4Pl9jTHd4D02SY 0UJPmg2LU2wGEqQG5JZcfmA43iZtsks= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1725279856; a=rsa-sha256; cv=pass; b=KWzh1l9GDPgTLH6ToklIlKyxsKm+gMsWoryR7pAYMHw4nVm9IisRlHnS4vvAJwLkelVFc+ LIZsbs0zosu8v+Mv2ftjPhS8JE4FSbkgAVt6Js9F4drPMTBZsL6q80brFyowXiv4eqUMvx HCiYSaPQV/CC9V3S9ljP3JlQ9yA629Y= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=DkH0goj1; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf05.hostedemail.com: domain of rongqianfeng@vivo.com designates 40.107.255.77 as permitted sender) smtp.mailfrom=rongqianfeng@vivo.com; dmarc=pass (policy=quarantine) header.from=vivo.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LArwxC3lrZg2RZSCRQIfmcZ8y+bINJFU8z/6iR+BLo+7u7XzQfJUR5U/tfQDXCEGbGLoKqg228ChYo0HTdj6kyy94Z0EZ2d7Zx6hWCReeITaIGbjeC1X03rYQXoSp5mrkgRWxZWFiC+c3PodAQLmjPqKKGRztH6V+Di0Ax2WMmTQ2VYPZIETyrC5UdxEDd0SuMjFqGvbiZ3NlxidI20MR4f24OZxzq0R8sW2nAWb41ByuvXxVyx0ljxB/MoDfIbvEEL16soyUif09Wza56ZfRLC/49r7YtgKoNVaeK84soZhfDvVM0+0Gp3DayZVXHH6ZpvK9YVnCI73F7Y7sHF5/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5hRT0pOvO7lfpsm388L41+nqwAtGmQPubJztREzsfdE=; b=gxWcABEmDEJBpE0r+TE1z2ihumEpEuuJ1HSeOpUcF3vH5aHP5EwHBlynFObxnE8Io/LX3F3Kk8qYIom93X40M9mxF1lOooRolxiAYKDMsEO0n6mFxTpOnmm4nqlLwC2ZP586LvX2eT2hlYLUoaTqRrkdBv3MTE6YhOEQktbKF3POSf79o6WMQsJK3FQeKNtYCA0Y0z/IeJYx9THsmYpp5GzwGp73o5ipe2xNxWOWJz/0R/s4N8Ii1jsC2Iv8WdiWuG48m4wG6WPJAncc8V/h+5IBoqTTOunBxnMkXm2MAmlubvgBEZYRurLXayogRQvrEFH8Yz0lOT/RGyKg7TqZcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5hRT0pOvO7lfpsm388L41+nqwAtGmQPubJztREzsfdE=; b=DkH0goj1sDq/yEjGZ/wFxdsRzuVzeJeaBsjqZ1+2haOnEM9NFdU3KwHMkYNXRJJ65YSGMWgux0XSE3Aaxs98TGjt8pUaTMIz8nLMQEoo7MDb8yXn3cNYAoSW+OnowYRy4N9D/SMliq+mPf0/EcHt4VsWxPaYZQDQKfwk2nw77WBxVGiXsyDGvJWYoGWV9avHh/ijXySqqQMPPmbaJGUsGpmPJYOAw7HKDrzodck6+0fAEQ+IW24PDTcZO5TgaqOZrcIoZF3UHYuitmmuh+cMJbIT32/DH8Bn1ccYV9tuIEdvaRonqSwPCmi3aoE5nGuZALfnBKPn5YtxircxuqC0Pg== Received: from SI2PR06MB5140.apcprd06.prod.outlook.com (2603:1096:4:1af::9) by KL1PR06MB6427.apcprd06.prod.outlook.com (2603:1096:820:f6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Mon, 2 Sep 2024 12:25:42 +0000 Received: from SI2PR06MB5140.apcprd06.prod.outlook.com ([fe80::468a:88be:bec:666]) by SI2PR06MB5140.apcprd06.prod.outlook.com ([fe80::468a:88be:bec:666%6]) with mapi id 15.20.7918.024; Mon, 2 Sep 2024 12:25:42 +0000 From: Rong Qianfeng To: vbabka@suse.cz, mgorman@techsingularity.net, Andrew Morton , Mike Rapoport , "Kirill A. Shutemov" , Zi Yan , Baolin Wang , Rong Qianfeng , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com Subject: [PATCH] mm: Skip the reserved bootmem for compaction Date: Mon, 2 Sep 2024 20:24:43 +0800 Message-Id: <20240902122445.11805-1-rongqianfeng@vivo.com> X-Mailer: git-send-email 2.39.0 X-ClientProxiedBy: TYCP286CA0080.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2b3::10) To SI2PR06MB5140.apcprd06.prod.outlook.com (2603:1096:4:1af::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SI2PR06MB5140:EE_|KL1PR06MB6427:EE_ X-MS-Office365-Filtering-Correlation-Id: b09874d4-0431-49c3-9857-08dccb4a5cad X-MS-Exchange-SenderADCheck: 1 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jxigKM6mHfyfKgsJLl7jaT78S/xHWVAwQZJNp5j+tFDGtJh/ZV3SRLPKiF5nAYlQZjSEN/HHAK6oIXX4f215g+M4J9lm7/fHBcgKIPXqCBxwjxGyyeoWvhgwwtyrAD1e7n656rQuLeRn97Fri7I2Zl8GoniS5RcD0Ujh9l0+aiZdsIVaYB9dU4UQTZDH1Oh8aUpxgGajtVg+poAx1xNWD4H1Swyty2bcnzgw7r6Mli6aXiF98KW/u/hDADfw7/v1+RyvUbdLYJq2w58OVXAK43DPkIX1UbDFKIZAj63SmPz8aPEuWxdJY2VYOrxs36GPammhImPVbPcDbrlwW8F3GYFxRmalV1MXkuiPc7evn3GeHfYRsplQaFLu48b3DtIPiDKM22Sd1e1pyAn6THvaLIOjXQvawpzlS5uLOs4PNtyS4AusrH1HAYdN6hNqZFfVpbpc4iUX4+uL+gD8WPpU5YpubfI5/U9nGrJqrLwCBYM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SI2PR06MB5140.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3EOMbUD0eofrSqtHf8WOYBqCV1hLMf3BQNDBNUfAQQ7jtUk7K0hILaVh1i/d1btV/fKLHG/us715kS0AK3zoC/a8K72EZUQpK//bW3cYbDfgtkhXzumiSVOOJbxeHdFoiitaWCQkdTcpTBPmC8qOWRh3OEMhefxl4+MODVz8io/NJGeuh6n2wQuk/kTsO5Rc+jInW9dmXqO95X3VnG8bl8TjXfVfbxLiSIbA35Jl3PYJ9lugF8WVJ/ou+w/J3tvMSpOQhlgyDXISmoniJ4LRpf6jXFPeW8GCW0cFga2TqT1Xm5758Z/nVaq4kkLShMGIHHpp04imeHdwWZH+IgZOX8B/PoZ8N1p96ke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r9b0O2TTIFtEwuE9H77F8BiP0scImUoXbpurqq+u/WH0rBpYRFYac4KH1IVidoHlb+G2tSasawcMfGD8IzhIf9/gZWP5UY9XRs98xzRnONQzd+3c8Wmf4T8o2gWhq2VHHPNxD3oNvymQwxZC9tMV6AGYsWb X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b09874d4-0431-49c3-9857-08dccb4a5cad X-MS-Exchange-CrossTenant-AuthSource: SI2PR06MB5140.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2024 12:25:42.4816 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xTQuU3/ofMVUs2VJXyzQc1bewcESO1J74qiRl22WH3Br//mCPgSDyubp5Coj54kKryarWiXea42V3sSLJWrcsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR06MB6427 X-Stat-Signature: ut64d4miqfhdkd44muj9iqq46tm583kw X-Rspamd-Queue-Id: E6B22100010 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1725279949-371756 X-HE-Meta: U2FsdGVkX1+/cujr0rZYBrdIoud9AXsWhjPJbIu16pBZDWSTX+uhAU4zA6FjKeWBjzkD6sk6dkg6wsDlBPDitue6LflfDbtNelr5oZrI2BzrcY3oQsWcVbqA8Wn9cbdY19E7CrdKNeq9xgbE/r1vB3BaX5iBlJbpycByiqluai4JfQKmazm8irrIHesz3ba97AWHEoeuJhaYzjSUPZIEtLeZJ9z66RDbUET18BIg5395ZBU9TJq8qaVaIILNO5Aw67kt81kVNKjWmoBiKo/SsG0XwNV5iYUMYZa33TPsgouk+wLQHYmwlm7WRzu3QXNmSFyEt5CWMwjLjUxA5eoRymTcjTsCrbu6KOZN+zZTGjBk1wXGQeD7gzMYr2LmawTb3EeYHKEVtI3NK7shCQv5N9pwWW9MeM13/a7Nf+4SrkB+Fe/RtECwLq0KlAVgLDq9KawmgEU/lyjKM8xUVGDHvEcUTRSgYSxADst6e+8Uslr0yJVBtfdPaMY3yaBkTeZRqJSv/JY9uBxuiXYwkkAri1HGidhqhNoYuyI9DpE14Mqgtp4y6eJLVBCKo6vzu/cubWpyxb9MPPP/DYnBSA9fDAaD4snL/OHGyQmRAhCDqGAV30SdHzGPOwmOTCjxs+6OawBmzzW/VJ+8m1XAnTwqQyZLKZgeXsjRSMIc2RnzGNCiianaPt9aupYO9UM6xw6eAf0jf6eNtKlmaKrQEy/Gi9/g3zIkkYU4v9q53HsCLMKJSyXTt3m1uueK78bHuvhJGfXeCqLI6Ip19gJJ959XjIw0OVcnmjFlPx+yLeooLJE5xYDrVJ9fKu/UUKAQ9zt3lttgGkP4/jKg4/Og6hzCO0e1JCutqDqMSikJZ7YPKYNDkvXj7NwHMXXH/AhUe1XZbFw1xnk6wMPU3xqSPsd0MJB0XPn9/P1IX0EBknlgELUEAhSPY6c/zqRucXxfQDmerYhTMTPM17NOEv3zX0e pE8Fjcct rcpeA8mN8GdMkFCNFtVmfZBpoTmyRKaxFrvQKcqHBAg3+LLKIMoFhkNzmT+CyMPQN2vF8MKhu8Ouipt8v0xcKuWe5rmpTvmVGouXIPCVjBHiJJUUP+AlRT7ZXUZVh99NRTfgQFlRrHhiVCwU9L14WLM36PmJhrJZ/is3ng6XXfnL665Qb2ZHi07hrM6EtfjIBx9GoC52f3si36/1dUcqcg37FDFApNr3w8EBVB3FU7f/WstlwzWkTo48xrXSF4fqzIL+V2TeAD1wTtSCsG7nq6BtYtYWlufM1qDko 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: List-Subscribe: List-Unsubscribe: Reserved pages are basically non-lru pages. This kind of memory can't be used as migration sources and targets, skip it can bring some performance benefits. Because some drivers may also use PG_reserved, we just set PB_migrate_skip for those clustered reserved bootmem during memory initialization. Signed-off-by: Rong Qianfeng --- include/linux/pageblock-flags.h | 13 +++++++++++ mm/compaction.c | 40 +++++++++++++++++++++++++++++++++ mm/mm_init.c | 14 ++++++++++++ mm/page_alloc.c | 7 ++++++ 4 files changed, 74 insertions(+) diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h index fc6b9c87cb0a..63c5b0c69c1a 100644 --- a/include/linux/pageblock-flags.h +++ b/include/linux/pageblock-flags.h @@ -86,6 +86,11 @@ void set_pfnblock_flags_mask(struct page *page, set_pfnblock_flags_mask(page, (1 << PB_migrate_skip), \ page_to_pfn(page), \ (1 << PB_migrate_skip)) + +extern void set_pageblock_skip_range(unsigned long start_pfn, + unsigned long end_pfn); +extern void clear_pageblock_skip_range(unsigned long start_pfn, + unsigned long end_pfn); #else static inline bool get_pageblock_skip(struct page *page) { @@ -97,6 +102,14 @@ static inline void clear_pageblock_skip(struct page *page) static inline void set_pageblock_skip(struct page *page) { } +static inline void set_pageblock_skip_range(unsigned long start_pfn, + unsigned long end_pfn) +{ +} +static inline void clear_pageblock_skip_range(unsigned long start_pfn, + unsigned long end_pfn) +{ +} #endif /* CONFIG_COMPACTION */ #endif /* PAGEBLOCK_FLAGS_H */ diff --git a/mm/compaction.c b/mm/compaction.c index f2af4493a878..7861588b34f3 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -286,6 +286,46 @@ static unsigned long skip_offline_sections_reverse(unsigned long start_pfn) } #endif +/* + * This function is currently used to set PB_migrate_skip for the reserved + * bootmem which can't be used as migration sources and targets(except CMA). + */ +void set_pageblock_skip_range(unsigned long start_pfn, + unsigned long end_pfn) +{ + unsigned long pfn; + + start_pfn = ALIGN(start_pfn, pageblock_nr_pages); + end_pfn = ALIGN_DOWN(end_pfn, pageblock_nr_pages); + + for (pfn = start_pfn; pfn < end_pfn; + pfn += pageblock_nr_pages) { + if (pfn_valid(pfn)) { + struct page *page = pfn_to_page(pfn); + + set_pageblock_skip(page); + } + } +} + +void clear_pageblock_skip_range(unsigned long start_pfn, + unsigned long end_pfn) +{ + unsigned long pfn; + + start_pfn = ALIGN_DOWN(start_pfn, pageblock_nr_pages); + end_pfn = ALIGN(end_pfn, pageblock_nr_pages); + + for (pfn = start_pfn; pfn < end_pfn; + pfn += pageblock_nr_pages) { + if (pfn_valid(pfn)) { + struct page *page = pfn_to_page(pfn); + + clear_pageblock_skip(page); + } + } +} + /* * Compound pages of >= pageblock_order should consistently be skipped until * released. It is always pointless to compact pages of such order (if they are diff --git a/mm/mm_init.c b/mm/mm_init.c index 4ba5607aaf19..8b7dc8e00bf1 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -768,6 +768,13 @@ void __meminit reserve_bootmem_region(phys_addr_t start, __SetPageReserved(page); } } + + /* + * Set PB_migrate_skip for reserved region. for cma memory + * and the memory released by free_reserved_area(), we will + * clear PB_migrate_skip when they are initialized. + */ + set_pageblock_skip_range(start_pfn, end_pfn); } /* If zone is ZONE_MOVABLE but memory is mirrored, it is an overlapped init */ @@ -2236,6 +2243,13 @@ void __init init_cma_reserved_pageblock(struct page *page) set_page_count(p, 0); } while (++p, --i); + /* + * We set the PB_migrate_skip in + * reserve_bootmem_region() for cma + * memory, clear it now. + */ + clear_pageblock_skip(page); + set_pageblock_migratetype(page, MIGRATE_CMA); set_page_refcounted(page); /* pages were reserved and not allocated */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b98f9bb28234..a7729dac0198 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5887,6 +5887,13 @@ unsigned long free_reserved_area(void *start, void *end, int poison, const char if (pages && s) pr_info("Freeing %s memory: %ldK\n", s, K(pages)); + /* + * Clear PB_migrate_skip if the memory have released + * to the buddy system. + */ + clear_pageblock_skip_range(page_to_pfn(virt_to_page(start)), + page_to_pfn(virt_to_page(end))); + return pages; }