From patchwork Wed Mar 6 10:28:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13583820 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 64077C5475B for ; Wed, 6 Mar 2024 10:29:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A82046B008C; Wed, 6 Mar 2024 05:29:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0E036B0092; Wed, 6 Mar 2024 05:29:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BFA86B0096; Wed, 6 Mar 2024 05:29:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 599086B0092 for ; Wed, 6 Mar 2024 05:29:21 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3B41D1C0EF6 for ; Wed, 6 Mar 2024 10:29:21 +0000 (UTC) X-FDA: 81866242122.12.F75CC60 Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) by imf01.hostedemail.com (Postfix) with ESMTP id 00E4740002 for ; Wed, 6 Mar 2024 10:29:18 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=O7huPLry; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf01.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.36.223 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=1709720959; 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=kf+dqckNIPa+VIzI7/vfMs0S0JsrUqEwDfy3Alr0qO0=; b=MpySzzvmCMCrmHK31saMDnOmuBQsFVcRjT+8jng7tJ//X/OxScqtB2vB7LAv3NDuikgOzx zjFEvOALxnKJ4Ps9zk4coeYIQqbzKhFT/fbD9RkhIR2auwFk6sMgZHvkId47WqsnU5udjN Gjro3WLzGK901wFx26FEEs+5/dLQM+4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=O7huPLry; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf01.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.36.223 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709720959; a=rsa-sha256; cv=none; b=SlNoik3eaYI77ABSDM6IjhxU0gICowfAGzt/CYY8zAXmRa7POd2vXCPlRaqSKU27j0xupE femSk6CQSzQJCRs40w5SPKxUKRD3npQAMlWokAsW41wvoAhTD/q1tjijWTUlB19XcZUO5C TTr9Nq8QMmoa715BVCLtj1sTGddzi5U= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709720959; x=1741256959; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XdN3aG00u/QsuyGD6b2X8W2/qtDpU1h/uB9UBsmVuQc=; b=O7huPLryOmxMjE+QAIPqs23PchrhoijR7lzzy0rKqG8Ig23YkNp8iD4b Nj5c7ZVvDiemyyXlB9WIMZosCeLcXc2hE//t2w289EdbbH1V7VWkG9Z0u Me6qnZdLt3qkHJHnOqWGb1zLAO8V2SuM+WoFHFk6BfemV1jzoUDHUtZEE WGc6/fN/ogvP74iA1X7EWi4zmtXwqKO5OSyoA4xu3JZd+89412tbI+v9r pG2+iF09Y3dlKbkvgVBUYLUxsrWnU0dWrE+u7Gkjcky+vjzeSi4B7LQiE icNgZyNlxSfYmHp/14LkxEZYPRYnylHZBd8pY/0vJdyEUW2apBbBjSzL+ w==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="139869814" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="139869814" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa9.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:16 +0900 Received: from yto-m3.gw.nic.fujitsu.com (yto-nat-yto-m3.gw.nic.fujitsu.com [192.168.83.66]) by yto-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id A4079B62EE for ; Wed, 6 Mar 2024 19:29:11 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id E98D2E6181 for ; Wed, 6 Mar 2024 19:29:10 +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 6969220097BE1 for ; Wed, 6 Mar 2024 19:29:10 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 782981A006D; Wed, 6 Mar 2024 18:29:09 +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 5/7] resource: Introduce walk device_backed_vmemmap res() helper Date: Wed, 6 Mar 2024 18:28:44 +0800 Message-Id: <20240306102846.1020868-6-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--2.753200-10.000000 X-TMASE-MatchedRID: VGeBglENKylzKOD0ULzeCRFbgtHjUWLyPeYVUCg2LRwBLwIiWDU8ay15 IFUNL+ETjx5X3FdI4UDmn3xyPJAJoh2P280ZiGmRcFEiuPxHjsXDCscXmnDN79P7VmP7Drr66us OKvlQZawRYCju0yIRX4Ay6p60ZV62Mhe627A+8aHdB/CxWTRRu+rAZ8KTspSzZ9zg/iRwE4LkAQ bstzNuLM5Iu+GqAiaI4D/GW2/5ILcxeNB9x03X8fQFNK0GDkNxsoGRy2pyHXLNTBw2qqp0+A7H6 7Vl1o7oIcmnZRhVxyrE4HwnSlEuHInEpJmLAFfpC1FNc6oqYVV+3BndfXUhXQ== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Rspamd-Queue-Id: 00E4740002 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 6pmfjb6ytzngoomcjn7at9u6gnc71map X-HE-Tag: 1709720958-852751 X-HE-Meta: U2FsdGVkX19MAQuYwyPvefdIz9QzHg/0Q8Nf9asMi3XXGUql6s/klaVnROcHaX5YAgG7Hkz1JmGNpKsplf+Dalio1G8aZKetNb23fdOQ4amOJkOb9l0+4WukKDJWM/temNcp2LwQs3Yz0KQWs2E7Pm3ZCSxvqz/bOMnQSg9j78bRpIyqRon8uUoqbALQ8zn4FVjSdF2wnOigXfqQBWzcrdwCe6+wr9N//dH80eGzY/ZNBs6vfQLvjbBLj4UpvN5JMik9+3RDMNAHpXOzxovGjAiw39KTVlW7xPVcBxqDtP6LNWykM9C045orfnr7Ejh0VY/yh4KirDxMPCm8iZ4n7p4jDTrQQE6AolOUFxdPnpNlEWFVO7TdsEFbyapj/1Vxv92wI5WLhyvG/EAsZOO5zhlDBAxDWrm7GOy7OZSsZJuH0TSDWfjcRv8PZbc3+ZMIZ38Gef4PpHizK+UY9xzCce+6s0AyINjStTcumlgGK+yGLuiGmwnl/daDcuSwSNuN6blVn71F4Yil/cnw/BkpnsWnNPb71Tpqe/0N42NgLoKJfv1cVtRfIhZWyjgKMqJ7q816ibR7zEK0JTVUSlXKQ7j7JDwg0Kef8QoukUzq3biZpM578qS0mznI9XUwJBIvHh7rHG0Lw7aMgrajX8PFdDc/FaQivYI5lJB1FsfRYzoTBp+WT2JveQuPqWxrnxObVLTyv/XXMaLCM51fh5Gxzqhl1SlP+kUaKHQStF72RiqN5LsvwiMNOe6Cbxjg2ogBhCXoB9r8tRzUlROoPgIabisaXLMWZ1ei/vguGNM/56Opxwp4Z2K53gSN3DnS69rrCG0o6QsQ89xmy2Gthmk/oEPLouw35SLYYk6w5LQo3V6bd28EXoH41LNcENBI7kYvF9+ZyOe9CHppkBdrq4hId8P8gvFg7fDo61B6c35gUxro1Dolj1NxRHg47KYV6vc7HBch0Cj9o0/GFpBDG38 iKo2LMYq 9rIb1nc0DRHlFOE4sIUPEKUBzpVjXNx5jh157 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 walks resources registered with flags (IORESOURCE_DEVICE_BACKED_VMEMMAP | IORESOURCE_BUSY), usually used by device backed vmemmap region. currently, it only sticks to the persistent memory type since it is only one user. CC: Andrew Morton CC: Baoquan He CC: Greg Kroah-Hartman CC: Alison Schofield CC: Dave Jiang CC: Dan Williams Signed-off-by: Li Zhijian --- include/linux/ioport.h | 3 +++ kernel/resource.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 3b59e924f531..10a60227d6c2 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -332,6 +332,9 @@ extern int walk_system_ram_res(u64 start, u64 end, void *arg, int (*func)(struct resource *, void *)); extern int +walk_device_backed_vmemmap_res(u64 start, u64 end, void *arg, + int (*func)(struct resource *, void *)); +extern int walk_system_ram_res_rev(u64 start, u64 end, void *arg, int (*func)(struct resource *, void *)); extern int diff --git a/kernel/resource.c b/kernel/resource.c index fcbca39dbc45..5f484266af07 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -431,6 +431,19 @@ int walk_system_ram_res(u64 start, u64 end, void *arg, func); } +/* + * This function calls the @func callback against all memory ranges, which + * are ranges marked as (IORESOURCE_DEVICE_BACKED_VMEMMAP | IORESOURCE_BUSY) + * and IORES_DESC_PERSISTENT_MEMORY. + */ +int walk_device_backed_vmemmap_res(u64 start, u64 end, void *arg, + int (*func)(struct resource *, void *)) +{ + return __walk_iomem_res_desc(start, end, + IORESOURCE_DEVICE_BACKED_VMEMMAP | IORESOURCE_BUSY, + IORES_DESC_PERSISTENT_MEMORY, arg, func); +} + /* * This function, being a variant of walk_system_ram_res(), calls the @func * callback against all memory ranges of type System RAM which are marked as