From patchwork Mon May 9 07:43:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 12843093 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 2379DC433EF for ; Mon, 9 May 2022 07:39:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7978F6B0071; Mon, 9 May 2022 03:39:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 721916B0073; Mon, 9 May 2022 03:39:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59A4F6B0074; Mon, 9 May 2022 03:39:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 487726B0071 for ; Mon, 9 May 2022 03:39:59 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 24BE2120D33 for ; Mon, 9 May 2022 07:39:59 +0000 (UTC) X-FDA: 79445405718.23.9CB69EE Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by imf11.hostedemail.com (Postfix) with ESMTP id 2A66A40090 for ; Mon, 9 May 2022 07:39:53 +0000 (UTC) Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220509073954epoutp04d5cdb933b8a203239f6767c66f6649b4~tX9Io5sni1238412384epoutp04a for ; Mon, 9 May 2022 07:39:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220509073954epoutp04d5cdb933b8a203239f6767c66f6649b4~tX9Io5sni1238412384epoutp04a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1652081994; bh=rRe3C0Q8ATjSIOb08O8/klpyddeuBgZBmXw+O02/wG8=; h=From:To:Cc:Subject:Date:References:From; b=W69BJpF10Enj+We6lqF84BW1dnchR1zx2WwxN08LWPR+6YOQmQMeLkezOLBMBmlH8 /UvOOIaRX1fcsW4qCDxBXSJEcaF6jaoKAQxlHkRM6dfqx28qNvCKQiY9qx7F0E0l0q XDdGYEt+nfT4x6uCuxdG6SIS0i5sEm4nt1fbw038= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20220509073954epcas1p4258dee46bc81eb06eae1cb458752d9d3~tX9IXUE_S2991229912epcas1p4E; Mon, 9 May 2022 07:39:54 +0000 (GMT) Received: from epsmges1p3.samsung.com (unknown [182.195.36.223]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4KxY3Y5Fq9z4x9Pr; Mon, 9 May 2022 07:39:53 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p3.samsung.com (Symantec Messaging Gateway) with SMTP id CE.14.10038.945C8726; Mon, 9 May 2022 16:39:53 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220509073953epcas1p127f2d36186316642068c92c5d9dee1c4~tX9HiwVnC2388723887epcas1p1K; Mon, 9 May 2022 07:39:53 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220509073953epsmtrp1ff76061dfbae49c1d3f0b4636c4352dc~tX9HhkE5i1674016740epsmtrp1h; Mon, 9 May 2022 07:39:53 +0000 (GMT) X-AuditID: b6c32a37-111ff70000002736-75-6278c549122a Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id E7.86.08924.945C8726; Mon, 9 May 2022 16:39:53 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.100.104]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220509073953epsmtip265c272ca8e262f75384d56b250e7910a~tX9HXuIeM2917129171epsmtip2z; Mon, 9 May 2022 07:39:53 +0000 (GMT) From: Jaewon Kim To: vbabka@suse.cz, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, Jaewon Kim Subject: [RFC PATCH] page_ext: create page extension for all memblock memory regions Date: Mon, 9 May 2022 16:43:30 +0900 Message-Id: <20220509074330.4822-1-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNKsWRmVeSWpSXmKPExsWy7bCmvq7n0Yokg7Pf1S3mrF/DZtG9eSaj Re/7V0wWl3fNYbO4t+Y/q8Xsxj5GBzaPnbPusnts+jSJ3ePEjN8sHn1bVjF6nFlwhN3j8ya5 ALaobJuM1MSU1CKF1Lzk/JTMvHRbJe/geOd4UzMDQ11DSwtzJYW8xNxUWyUXnwBdt8wcoDOU FMoSc0qBQgGJxcVK+nY2RfmlJakKGfnFJbZKqQUpOQVmBXrFibnFpXnpenmpJVaGBgZGpkCF CdkZ3x9vZSu4IFrx+Cx3A+MfgS5GTg4JAROJ/mvbWbsYuTiEBHYwSkzZ1McO4XxilLh/B8b5 zCixfe96RpiWhjkToBK7GCXWrHkI5fxglHh7aTorSBWbgLbE+wWTwGwRAV2Jgz0tzCA2s0Cp xNs3J8BsYYEwiYPvnwPZHBwsAqoS/x6VgYR5BWwk3h66wgSxTF5i9YYDzCDzJQQ2sUtsv9jJ CpFwkdj4/SxUkbDEq+Nb2CFsKYmX/W1QdrbE05NHwOZLCORINGyQhTDtJd5fsgAxmQU0Jdbv 0ocoVpTY+XsuI8SRfBLvvvawQlTzSnS0CUGUqEm0PPsKtV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J+OFBNITS1KzU1MLUotgskwcnFINTNN12b7y ezOlOZ/tf35SZTnnFL2jR+8c39Adk77ITamzSMJ0m38S+z+pY0v3xG3lUvp5z0ml0f6WE1vy 0zDXU1f5WjwP8SkGKvzwu/Nz6razO+ouSQeWBU+5PuPHFrkdzxXil7zuu3j0r9OUlyePutd3 bZt8YP+t0tccXzuDFt14KjA58cveKberlwl+W2Z582ZP4I5z95wbVhwTbNvb8TBns6rYp7wD RVrPEl/cWs9uVjGJ97FTTtJeMY+Jpj+CFOwWbe2+ZvY2xOH1hryLnufi+Huu8L46mMckp9Pb ZRdnkGNatfXcJPOpe++d89+1Q+Uii+CPJNV1+SkKUn9y93dfNYwyWr387kofy5kvlisqsRRn JBpqMRcVJwIA7iuqCI4CAAA= X-CMS-MailID: 20220509073953epcas1p127f2d36186316642068c92c5d9dee1c4 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220509073953epcas1p127f2d36186316642068c92c5d9dee1c4 References: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 2A66A40090 X-Stat-Signature: 9j5gexkfnmwhzcsa7you7eory6dc9zfp X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=W69BJpF1; spf=pass (imf11.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.34 as permitted sender) smtp.mailfrom=jaewon31.kim@samsung.com; dmarc=pass (policy=none) header.from=samsung.com X-HE-Tag: 1652081993-297107 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 page extension can be prepared for each section. But if the first page is not valid, the page extension for the section was not initialized though there were many other valid pages within the section. To support the page extension for all sections, refer to memblock memory regions. If the page is valid use the nid from pfn_to_nid, otherwise use the previous nid. Also this pagech changed log to include total sections and a section size. i.e. allocated 100663296 bytes of page_ext for 64 sections (1 section : 0x8000000) Signed-off-by: Jaewon Kim --- mm/page_ext.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/mm/page_ext.c b/mm/page_ext.c index 2e66d934d63f..506d58b36a1d 100644 --- a/mm/page_ext.c +++ b/mm/page_ext.c @@ -381,41 +381,43 @@ static int __meminit page_ext_callback(struct notifier_block *self, void __init page_ext_init(void) { unsigned long pfn; - int nid; + int nid = 0; + struct memblock_region *rgn; + int nr_section = 0; + unsigned long next_section_pfn = 0; if (!invoke_need_callbacks()) return; - for_each_node_state(nid, N_MEMORY) { + /* + * iterate each memblock memory region and do not skip a section having + * !pfn_valid(pfn) + */ + for_each_mem_region(rgn) { unsigned long start_pfn, end_pfn; - start_pfn = node_start_pfn(nid); - end_pfn = node_end_pfn(nid); - /* - * start_pfn and end_pfn may not be aligned to SECTION and the - * page->flags of out of node pages are not initialized. So we - * scan [start_pfn, the biggest section's pfn < end_pfn) here. - */ + start_pfn = (unsigned long)(rgn->base >> PAGE_SHIFT); + end_pfn = start_pfn + (unsigned long)(rgn->size >> PAGE_SHIFT); + + if (start_pfn < next_section_pfn) + start_pfn = next_section_pfn; + for (pfn = start_pfn; pfn < end_pfn; pfn = ALIGN(pfn + 1, PAGES_PER_SECTION)) { - if (!pfn_valid(pfn)) - continue; - /* - * Nodes's pfns can be overlapping. - * We know some arch can have a nodes layout such as - * -------------pfn--------------> - * N0 | N1 | N2 | N0 | N1 | N2|.... - */ - if (pfn_to_nid(pfn) != nid) - continue; + if (pfn_valid(pfn)) + nid = pfn_to_nid(pfn); + nr_section++; if (init_section_page_ext(pfn, nid)) goto oom; cond_resched(); } + next_section_pfn = pfn; } + hotplug_memory_notifier(page_ext_callback, 0); - pr_info("allocated %ld bytes of page_ext\n", total_usage); + pr_info("allocated %ld bytes of page_ext for %d sections (1 section : 0x%x)\n", + total_usage, nr_section, (1 << SECTION_SIZE_BITS)); invoke_init_callbacks(); return;