From patchwork Wed Mar 6 10:28:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13583818 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 51AFBC54E5C for ; Wed, 6 Mar 2024 10:29:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 083EC6B0089; Wed, 6 Mar 2024 05:29:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DD8926B008A; Wed, 6 Mar 2024 05:29:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE0786B008C; Wed, 6 Mar 2024 05:29:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A31546B0089 for ; Wed, 6 Mar 2024 05:29:20 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 742A6140BF5 for ; Wed, 6 Mar 2024 10:29:20 +0000 (UTC) X-FDA: 81866242080.17.94C20A8 Received: from esa5.hc1455-7.c3s2.iphmx.com (esa5.hc1455-7.c3s2.iphmx.com [68.232.139.130]) by imf10.hostedemail.com (Postfix) with ESMTP id 2AAF9C000D for ; Wed, 6 Mar 2024 10:29:17 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=gQ6gfUro; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf10.hostedemail.com: domain of lizhijian@fujitsu.com designates 68.232.139.130 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709720958; 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=wg423God+C8SkCwIZt0kbQSq6lgqTTeY957x3wueu/w=; b=QWMQYg6CyvksEp0dRFWv1HdEB39SoZfvsY7IbketfMqAbNjsOLZl7aeKf037LA7wy1UCNV +ZVTFr8E0+/HUY3ptcMOdWQ/x3Mv1FJ8VL2fbEryR6LIEfC5vWLln4wF38IzILbSHFQ/RJ 9IhBA7OPKiZhCjrUiNUFKpNTeittzsI= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=gQ6gfUro; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf10.hostedemail.com: domain of lizhijian@fujitsu.com designates 68.232.139.130 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709720958; a=rsa-sha256; cv=none; b=yekwSnOMJ4vVxxVqG5my5aw9MuadinqbZ9VvQmaLtZRLUKCly24+RkI8ZlRXodRgA4//pV rOElV8UtGLobc6MpP7D0DXMSubVYKvHJdF/kB6oTLedyR8BNLfv4jzU+ACiAmAuyy7UBJn IvZW/IykLFk8Kvyk8hx4HjAMKNBXoo8= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709720958; x=1741256958; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qPTXg1j60dmCKgrUxhmFd4z9be0Rjp54MJE3FLxdEQM=; b=gQ6gfUroeJ4Bo4C+L3qvHWQXtnTq1ISL+C+jpR6MMLp9VB1aUfiIHbPG y61aRAe1y4KBDITQU/pPJDNlLQtO6VRHMPuECAqeGbS6z2Vu12gzx2z4q uy603uqVdnV8o/VJRDqwxV4s+JPJvD/H1VBM0tKqRRev8/tiSYdsYbJvE 8s215aICDBCTUm0lp8J7INbP2jUmwzS8eb6jo1mnGZ9BgFFH4jDlMSbgJ 5udFoMGHyl8ztGJgWbpqq/88EQLIr0/uWjHyADZW3/WpRHCEYiIFVsTu2 RxToThyIWdr7RM9lTk294bf2sUp2B+slhxVPEvfK4kOE/+CVdCtaSafa7 A==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="150857726" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="150857726" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa5.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:16 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 63186DD92F for ; Wed, 6 Mar 2024 19:29:09 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 92DC6FDA0B for ; Wed, 6 Mar 2024 19:29:08 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 041652030C7E9 for ; Wed, 6 Mar 2024 19:29:08 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 08E3D1A006A; Wed, 6 Mar 2024 18:29:06 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: y-goto@fujitsu.com, Alison Schofield , Andrew Morton , Baoquan He , Borislav Petkov , Dan Williams , Dave Hansen , Dave Jiang , Greg Kroah-Hartman , hpa@zytor.com, Ingo Molnar , Ira Weiny , Thomas Gleixner , Vishal Verma , linux-cxl@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, x86@kernel.org, kexec@lists.infradead.org, Li Zhijian Subject: [PATCH v3 2/7] mm: memremap: add pgmap_parent_resource() helper Date: Wed, 6 Mar 2024 18:28:41 +0800 Message-Id: <20240306102846.1020868-3-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240306102846.1020868-1-lizhijian@fujitsu.com> References: <20240306102846.1020868-1-lizhijian@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28234.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28234.006 X-TMASE-Result: 10-1.178600-10.000000 X-TMASE-MatchedRID: a4Q7dosAlP6Po+6vQMop+ikMR2LAnMRpCZa9cSpBObnAuQ0xDMaXkH4q tYI9sRE/7qN2AY1LBYfX/4cXJB77G82IoAvAG8Cytw+xHnsmQjMRKrbwgeEU4psoi2XrUn/Jn6K dMrRsL14qtq5d3cxkNePDdA+sPJoJpIWVq2FPrVRC8PbPp9VJvAwE3szHrU0AtN2HcZBPqwdFSR N53IQttjRtl6ZG50f040PXgYNLw2sECcFYp/ZlI4xrU96OxkmsFcUQf3Yp/ridO0/GUi4gFb0fO PzpgdcEKeJ/HkAZ8Is= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2AAF9C000D X-Stat-Signature: kyrtttca1mz1ej64d5r79w51synopnu7 X-HE-Tag: 1709720957-290680 X-HE-Meta: U2FsdGVkX182zM2noL2noWqCEx5Cee4q/zrkkh17kBvzHRksN1ZsoF63Vo/xS73xBdpPO9cb/PsYfXa24LJpxH51FFzUt1v2BxB6XWx1dCh077P1bhueWTNNnhp6Yg6Cxcsq9CSz+yB4IWSKaZXp0vGLt3ohw2N8TyAJ8BdkecL5m3QQHcKInfidIoXyx3Z0OqIAAbf9YN+ZvUROcpQJxiv6QaE4yrmI8ugXPO76AF7y6dXIJAB8KviIVLTf/QLHC0FOmTMYUOXMS3D47WxM5C6X87zOrU+7eNgwev70l2LXdAs1cWsPTxbGw0S44Iiht0euJW/R0O1sMQ8Al7jS/b+Bgufeg9TpaxiN8W/D+saHeILVRBYEQrCzwbKcZnNpyBwAiUAppJWXvqowVkKN6s20/NevSCONJnR3S+ITZOkHQVbjun6uQ89HdlmHvK84FamRkbP+NWdfpd8W9TwngzNflY8dYYcm8Xq66tk2sgKaKSDmenFRYmiwXlk9hFGEnZXMPng8mrGezWPRyk/9dSNmdYcsgb1MxFIWx1JqWp+LIGGqGziV0TLwsdksy5KuamyICX/UCQDe4Tgz3INF/5D+HcLR+U+7bDkGpd5HjIFkmo7FCYUSOeCyVSuSBvOhJzYnLdOc7VJb6nE/8e53mmtLXHzJ5XpXx3Iai1zVyR1Ou42oK7DQ0TdzBPy8nIlLaEXd7AXM7ltTpGOEjKekcLXoeeWt1UEl7HL+NGoio1ABxNe3U53pf55r+T9xrfXtLV+1xlGNcFegEWPTGEloglsgDfM5HXReQAdZ++wi6r42dwnrAFmzQnPBTb+eUCc1renx+a10i0ROFJk5Ku/Z0tx2b42xPfusWNH9xpiOZwvp1gSEuW8Llx6AzXk48PsrWLCHh2GpRgYnTCD9DsIFCjHxac2bdIwVskQ4IBVUET1My802PPINAj2JyBQyVUQ2wSBpt1jF+eWa8EaSDW5 JEh7cdfx ZY71YSEp8M4XwvxtzK5voJVFzuztMpd1sVJZv 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: It's a helper to set the parent resource for the altmap of a given pgmap CC: Andrew Morton CC: Dan Williams CC: Baoquan He CC: linux-mm@kvack.org Signed-off-by: Li Zhijian --- include/linux/memremap.h | 1 + mm/memremap.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index ca1f12353008..1e8b25352f7c 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -193,6 +193,7 @@ static inline bool folio_is_device_coherent(const struct folio *folio) void zone_device_page_init(struct page *page); void *memremap_pages(struct dev_pagemap *pgmap, int nid); void memunmap_pages(struct dev_pagemap *pgmap); +void pgmap_parent_resource(struct dev_pagemap *pgmap, struct resource *res); void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap); void devm_memunmap_pages(struct device *dev, struct dev_pagemap *pgmap); struct dev_pagemap *get_dev_pagemap(unsigned long pfn, diff --git a/mm/memremap.c b/mm/memremap.c index 78047157b0ee..0bbf163d4817 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -390,6 +390,13 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid) } EXPORT_SYMBOL_GPL(memremap_pages); +void pgmap_parent_resource(struct dev_pagemap *pgmap, struct resource *res) +{ + if (pgmap && res) + pgmap->altmap.parent = res; +} +EXPORT_SYMBOL_GPL(pgmap_parent_resource); + /** * devm_memremap_pages - remap and provide memmap backing for the given resource * @dev: hosting device for @res