From nobody Wed Dec 17 17:25:10 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69B13C5AD4C for ; Thu, 23 Nov 2023 09:24:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232712AbjKWJYT (ORCPT ); Thu, 23 Nov 2023 04:24:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231656AbjKWJYF (ORCPT ); Thu, 23 Nov 2023 04:24:05 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9AF5D41; Thu, 23 Nov 2023 01:24:11 -0800 (PST) Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN9MJew015055; Thu, 23 Nov 2023 09:24:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=HwbCfMd9FDVn6PpCGOGhbJh/24QSajgcDKz+c2O+fJc=; b=DTKWH7wJ+GKrW6nB2PoOXQvtPeUg8dEfEpNuODKRz5a5fJqMzfj/Iz5aZsuyadd6TfZg z4M8xjYHa+Wbm7VriuZgLgkskdJqvJKQxnbpnEzYFctTRKMit24KMFRIGV2JExslsySd sCLbfORP7jslfw2sFInRbxAxEIptrtTdV+sLZcdIOUbJX8R0r9y2BB4pE2mHCkWjaqlf n3c2vZV08K+k97D4alFSjAtvaqYNTUPDpUE44c7cn/axC4AZhGdjoh8ku4wmL+KcXs1E ZD/KIJslqPBZEV9VNlmN31RgmtnQ9487YMMY0KsC0XvyE3qpR4X2FJyrvMfeKdZCm5wd kg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj41vr1b4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:00 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AN9N0Bm017396; Thu, 23 Nov 2023 09:24:00 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj41vr1ad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:23:59 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN8nEja023488; Thu, 23 Nov 2023 09:23:59 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3uf9tknumx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:23:58 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AN9NuvC29229736 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Nov 2023 09:23:56 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF6F120040; Thu, 23 Nov 2023 09:23:55 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C09F32004B; Thu, 23 Nov 2023 09:23:55 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 23 Nov 2023 09:23:55 +0000 (GMT) From: Sumanth Korikkar To: linux-mm , Andrew Morton , David Hildenbrand Cc: Oscar Salvador , Michal Hocko , "Aneesh Kumar K.V" , Anshuman Khandual , Gerald Schaefer , Sumanth Korikkar , Alexander Gordeev , Heiko Carstens , Vasily Gorbik , linux-s390 , LKML Subject: [PATCH v2 1/7] mm/memory_hotplug: introduce mhp_flag MHP_OFFLINE_INACCESSIBLE Date: Thu, 23 Nov 2023 10:23:37 +0100 Message-Id: <20231123092343.1703707-2-sumanthk@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123092343.1703707-1-sumanthk@linux.ibm.com> References: <20231123092343.1703707-1-sumanthk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 1LOAtid-uln_WgoAXOcTLt5CJX2DCdKE X-Proofpoint-GUID: 43IddKH6wX7PlbvKGysk-2j4SFo5RpMm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-23_07,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 mlxscore=0 phishscore=0 mlxlogscore=447 clxscore=1015 bulkscore=0 adultscore=0 priorityscore=1501 suspectscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311230067 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Introduce MHP_OFFLINE_INACCESSIBLE mhp_flag to mark the hotplugged memory block as inaccessible during the memory hotplug addition phase. With support for "memmap on memory", the altmap is prepared at this stage. Architectures like s390 anticipate that memmap should not be accessed until memory is physically accessible and is accessible only when it enters the memory hotplug onlining phase using the memory notifier. Introduce the flag to inform the memory hotplug infrastructure that the memory remains inaccessible until the memory hotplug onlining phase begins. Implementation considerations: mhp inaccessible flag is initially set in altmap. This is useful in arch_add_memory(). When the memory block device is added, the mhp inaccessible information is passed to memory_block. The flag is used in subsequent patch to avoid accessing memmap during memory hotplug addition phase. Signed-off-by: Sumanth Korikkar --- drivers/base/memory.c | 2 ++ include/linux/memory.h | 1 + include/linux/memory_hotplug.h | 10 ++++++++++ include/linux/memremap.h | 1 + mm/memory_hotplug.c | 3 ++- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 8a13babd826c..51915d5c3f88 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -774,6 +774,8 @@ static int add_memory_block(unsigned long block_id, uns= igned long state, mem->state =3D state; mem->nid =3D NUMA_NO_NODE; mem->altmap =3D altmap; + if (altmap) + mem->inaccessible =3D altmap->inaccessible; INIT_LIST_HEAD(&mem->group_next); =20 #ifndef CONFIG_NUMA diff --git a/include/linux/memory.h b/include/linux/memory.h index f53cfdaaaa41..655714d4e65a 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -67,6 +67,7 @@ struct memory_group { struct memory_block { unsigned long start_section_nr; unsigned long state; /* serialized by the dev->lock */ + bool inaccessible; /* during memory addition phase */ int online_type; /* for passing data to online routine */ int nid; /* NID for this memory block */ /* diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 7d2076583494..8988cd5ad55d 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -106,6 +106,16 @@ typedef int __bitwise mhp_t; * implies the node id (nid). */ #define MHP_NID_IS_MGID ((__force mhp_t)BIT(2)) +/* + * Mark the hotplugged memory block as inaccessible during the memory hotp= lug + * addition phase. With support for "memmap on memory," the altmap is prep= ared + * at this stage. Architectures like s390 anticipate that memmap should no= t be + * accessed until memory is physically accessible and is accessible only w= hen + * it enters the memory hotplug onlining phase using the memory notifier. + * Utilize this flag to inform the memory hotplug infrastructure that the + * memory remains inaccessible until the memory hotplug onlining phase beg= ins. + */ +#define MHP_OFFLINE_INACCESSIBLE ((__force mhp_t)BIT(3)) =20 /* * Extended parameters for memory hotplug: diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 744c830f4b13..9837f3e6fb95 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -25,6 +25,7 @@ struct vmem_altmap { unsigned long free; unsigned long align; unsigned long alloc; + bool inaccessible; }; =20 /* diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 7a5fc89a8652..1e02eba166b0 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1092,7 +1092,6 @@ int mhp_init_memmap_on_memory(unsigned long pfn, unsi= gned long nr_pages, ret =3D kasan_add_zero_shadow(__va(PFN_PHYS(pfn)), PFN_PHYS(nr_pages)); if (ret) return ret; - move_pfn_range_to_zone(zone, pfn, nr_pages, NULL, MIGRATE_UNMOVABLE); =20 for (i =3D 0; i < nr_pages; i++) @@ -1439,6 +1438,8 @@ int __ref add_memory_resource(int nid, struct resourc= e *res, mhp_t mhp_flags) if (mhp_flags & MHP_MEMMAP_ON_MEMORY) { if (mhp_supports_memmap_on_memory(size)) { mhp_altmap.free =3D memory_block_memmap_on_memory_pages(); + if (mhp_flags & MHP_OFFLINE_INACCESSIBLE) + mhp_altmap.inaccessible =3D true; params.altmap =3D kmalloc(sizeof(struct vmem_altmap), GFP_KERNEL); if (!params.altmap) { ret =3D -ENOMEM; --=20 2.39.2 From nobody Wed Dec 17 17:25:10 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B19CC5AD4C for ; Thu, 23 Nov 2023 09:24:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232481AbjKWJYL (ORCPT ); Thu, 23 Nov 2023 04:24:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231478AbjKWJYE (ORCPT ); Thu, 23 Nov 2023 04:24:04 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B5D2DD; Thu, 23 Nov 2023 01:24:11 -0800 (PST) Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN97U12030589; Thu, 23 Nov 2023 09:24:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=uoYg6XFVhnl9z1m4lIqYlmnlEpI3Bitpu8U7076l1/0=; b=NfaQnenE1yp4HWqR+BEL+kF6EZb5gVgWUwl18bsE/tWMoGAd9ruHHX6xCyzEWnlEwpNg YqEhLPKXe1WJXRGSIaHlezzfvfEWr4se4tlYZWQm2H1PkN8sIi09W/inz3f11xsYdKKZ cTVClozXIqZcTAi8TzH1XmPJ6iWu2SD6A3VNS6sydVKrfSzZjwz7Ze8O4ZVQARoCYRft O8otFGiHDfIfgYHIZCVGrbVrocnU3J6MMAIWVmYdRyUMnE5mrcrYDBo6kZSt9QxddrIr ulcYI9PIzeO71Xdc5bk8ZAwWaNP3vyXxkUF/pbKRTiv3BlPJw7mj1vyXSndsXozDqIW9 pw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj3twrepb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:00 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AN9FU5P027019; Thu, 23 Nov 2023 09:24:00 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj3twrenq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:00 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN8nA1Y018157; Thu, 23 Nov 2023 09:23:59 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ufaa2dp5e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:23:58 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AN9Nuaj29229738 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Nov 2023 09:23:56 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F08620040; Thu, 23 Nov 2023 09:23:56 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 005CB20043; Thu, 23 Nov 2023 09:23:56 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 23 Nov 2023 09:23:55 +0000 (GMT) From: Sumanth Korikkar To: linux-mm , Andrew Morton , David Hildenbrand Cc: Oscar Salvador , Michal Hocko , "Aneesh Kumar K.V" , Anshuman Khandual , Gerald Schaefer , Sumanth Korikkar , Alexander Gordeev , Heiko Carstens , Vasily Gorbik , linux-s390 , LKML Subject: [PATCH v2 2/7] mm/memory_hotplug: avoid poisoning memmap during mhp addition phase Date: Thu, 23 Nov 2023 10:23:38 +0100 Message-Id: <20231123092343.1703707-3-sumanthk@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123092343.1703707-1-sumanthk@linux.ibm.com> References: <20231123092343.1703707-1-sumanthk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: F68q5nW_FI2KdT5X8K-1UeDdw0_hK_Ml X-Proofpoint-ORIG-GUID: kQUWhC4ccdO8whY8KOUfTcwkFzLFfVMj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-23_07,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=356 adultscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311230067 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When memory block is marked inaccessible, avoid page_init_poison() on memmap during memory hotplug addition phase. Instead, perform it later when the memory is physically accessible in memory hotplug online phase. When the memory block is marked accessible (by default turned on without passing any mhp_flags), page poisoning initialization on memmap is performed in sparse_add_section(). Page init poisining on memmap is performed with cond_resched(). This reflects the functionality of commit d33695b16a9f ("mm/memory_hotplug: poison memmap in remove_pfn_range_from_zone()") Architectures can pass MHP_OFFLINE_INACCESSIBLE mhp_flag in add_memory() to mark the memory block as initially inaccessible during memory hotplug addition phase. Signed-off-by: Sumanth Korikkar --- drivers/base/memory.c | 3 ++- include/linux/memory_hotplug.h | 2 +- mm/memory_hotplug.c | 27 ++++++++++++++++++++++++++- mm/sparse.c | 3 ++- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 51915d5c3f88..cbff43b2ef44 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -209,7 +209,8 @@ static int memory_block_online(struct memory_block *mem) =20 mem_hotplug_begin(); if (nr_vmemmap_pages) { - ret =3D mhp_init_memmap_on_memory(start_pfn, nr_vmemmap_pages, zone); + ret =3D mhp_init_memmap_on_memory(start_pfn, nr_vmemmap_pages, + zone, mem->inaccessible); if (ret) goto out; } diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 8988cd5ad55d..791bc019e992 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -164,7 +164,7 @@ extern void adjust_present_page_count(struct page *page, long nr_pages); /* VM interface that may be used by firmware interface */ extern int mhp_init_memmap_on_memory(unsigned long pfn, unsigned long nr_p= ages, - struct zone *zone); + struct zone *zone, bool mhp_off_inaccessible); extern void mhp_deinit_memmap_on_memory(unsigned long pfn, unsigned long n= r_pages); extern int online_pages(unsigned long pfn, unsigned long nr_pages, struct zone *zone, struct memory_group *group); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 1e02eba166b0..ac7cfc09502d 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1083,8 +1083,25 @@ void adjust_present_page_count(struct page *page, st= ruct memory_group *group, group->present_kernel_pages +=3D nr_pages; } =20 +static void page_init_poison_with_resched(unsigned long start_pfn, unsigne= d long nr_pages) +{ + const unsigned long end_pfn =3D start_pfn + nr_pages; + unsigned long pfn, cur_nr_pages; + + /* Poison struct pages because they are now uninitialized again. */ + for (pfn =3D start_pfn; pfn < end_pfn; pfn +=3D cur_nr_pages) { + cond_resched(); + + /* Select all remaining pages up to the next section boundary */ + cur_nr_pages =3D + min(end_pfn - pfn, SECTION_ALIGN_UP(pfn + 1) - pfn); + page_init_poison(pfn_to_page(pfn), + sizeof(struct page) * cur_nr_pages); + } +} + int mhp_init_memmap_on_memory(unsigned long pfn, unsigned long nr_pages, - struct zone *zone) + struct zone *zone, bool mhp_off_inaccessible) { unsigned long end_pfn =3D pfn + nr_pages; int ret, i; @@ -1092,6 +1109,14 @@ int mhp_init_memmap_on_memory(unsigned long pfn, uns= igned long nr_pages, ret =3D kasan_add_zero_shadow(__va(PFN_PHYS(pfn)), PFN_PHYS(nr_pages)); if (ret) return ret; + /* + * Memory block is accessible at this stage and hence poison the struct + * pages now. If the memory block is accessible during memory hotplug + * addition phase, then page poisining is already performed in + * sparse_add_section(). + */ + if (mhp_off_inaccessible) + page_init_poison_with_resched(pfn, nr_pages); move_pfn_range_to_zone(zone, pfn, nr_pages, NULL, MIGRATE_UNMOVABLE); =20 for (i =3D 0; i < nr_pages; i++) diff --git a/mm/sparse.c b/mm/sparse.c index 77d91e565045..3991c717b769 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -907,7 +907,8 @@ int __meminit sparse_add_section(int nid, unsigned long= start_pfn, * Poison uninitialized struct pages in order to catch invalid flags * combinations. */ - page_init_poison(memmap, sizeof(struct page) * nr_pages); + if (!altmap || !altmap->inaccessible) + page_init_poison(memmap, sizeof(struct page) * nr_pages); =20 ms =3D __nr_to_section(section_nr); set_section_nid(section_nr, nid); --=20 2.39.2 From nobody Wed Dec 17 17:25:10 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 186E6C636CB for ; Thu, 23 Nov 2023 09:24:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231394AbjKWJYE (ORCPT ); Thu, 23 Nov 2023 04:24:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbjKWJYC (ORCPT ); Thu, 23 Nov 2023 04:24:02 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 691F319E; Thu, 23 Nov 2023 01:24:08 -0800 (PST) Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN97SOE030489; Thu, 23 Nov 2023 09:24:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=HYgtCZxFyEih59yMBfurLMGboumwZXHsg8XyOU1jf9U=; b=Vc4+O1y+QnWgZoO0+wVbdg6ae+z4jqwMk/Ws7zP2dNJO8E/MxWGbarmZ6q41B2n3aDak oX8SobRQYsO4XYSOFktWOfr6Vqx7H3w0rHahmf1buRqmK7WD2HPkTmuJdpnw0wroQkrP O/rU08cbXksW+pNdMs6n7I7qfKLOUXqAArJemAtJTfNxxB8ivpbTLH/bCas17tYa8P3a hcNnQ4Pj6iCjNxRXr7GlQaEJptjmXoi6rGrsltjuoNzbUac4cDqKaGhdAZ231oU8Ex4t OylgpPPoQLMWfKexJyXEkJc+QJOHv1Rz+lOmfalm7Gz1Ccj9OsxZiEzC7DN84IjRj5P1 Xg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj3twrepv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:01 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AN98Cl1001750; Thu, 23 Nov 2023 09:24:01 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj3twrep2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:00 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN8nG1e021112; Thu, 23 Nov 2023 09:23:59 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uf8kp67bb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:23:59 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AN9Nugb35979694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Nov 2023 09:23:56 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6387C20040; Thu, 23 Nov 2023 09:23:56 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 34A712004B; Thu, 23 Nov 2023 09:23:56 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 23 Nov 2023 09:23:56 +0000 (GMT) From: Sumanth Korikkar To: linux-mm , Andrew Morton , David Hildenbrand Cc: Oscar Salvador , Michal Hocko , "Aneesh Kumar K.V" , Anshuman Khandual , Gerald Schaefer , Sumanth Korikkar , Alexander Gordeev , Heiko Carstens , Vasily Gorbik , linux-s390 , LKML Subject: [PATCH v2 3/7] mm/memory_hotplug: introduce MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE notifiers Date: Thu, 23 Nov 2023 10:23:39 +0100 Message-Id: <20231123092343.1703707-4-sumanthk@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123092343.1703707-1-sumanthk@linux.ibm.com> References: <20231123092343.1703707-1-sumanthk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Yp3vEj8jyuT_QEU8ZsHP0Gw5R-tAowx- X-Proofpoint-ORIG-GUID: vfXWQ1jzYRqboH9Tkb3l5IQQkwYio78y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-23_07,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=473 adultscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311230067 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Introduce MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE memory notifiers to prepare the transition of memory to and from a physically accessible state. This enhancement is crucial for implementing the "memmap on memory" feature for s390 in a subsequent patch. Platforms such as x86 can support physical memory hotplug via ACPI. When there is physical memory hotplug, ACPI event leads to the memory addition with the following callchain: acpi_memory_device_add() -> acpi_memory_enable_device() -> __add_memory() After this, the hotplugged memory is physically accessible, and altmap support prepared, before the "memmap on memory" initialization in memory_block_online() is called. On s390, memory hotplug works in a different way. The available hotplug memory has to be defined upfront in the hypervisor, but it is made physically accessible only when the user sets it online via sysfs, currently in the MEM_GOING_ONLINE notifier. This is too late and "memmap on memory" initialization is performed before calling MEM_GOING_ONLINE notifier. During the memory hotplug addition phase, altmap support is prepared (but not yet accessed) and during the memory onlining phase s390 requires memory to be physically accessible and then subsequently initiate the "memmap on memory" initialization process. The new MEM_PREPARE_ONLINE notifier allows to work around the problem, by providing a hook to prepare the memory and make it physically accessible. Similarly, the MEM_FINISH_OFFLINE notifier allows to make the memory physically inaccessible at the end of memory_block_offline(). All architectures ignore unknown memory notifiers, so this patch should not introduce any functional changes. Reviewed-by: Gerald Schaefer Signed-off-by: Sumanth Korikkar --- drivers/base/memory.c | 18 +++++++++++++++++- include/linux/memory.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index cbff43b2ef44..a06a0b869992 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -188,6 +188,7 @@ static int memory_block_online(struct memory_block *mem) unsigned long start_pfn =3D section_nr_to_pfn(mem->start_section_nr); unsigned long nr_pages =3D PAGES_PER_SECTION * sections_per_block; unsigned long nr_vmemmap_pages =3D 0; + struct memory_notify arg; struct zone *zone; int ret; =20 @@ -197,6 +198,14 @@ static int memory_block_online(struct memory_block *me= m) zone =3D zone_for_pfn_range(mem->online_type, mem->nid, mem->group, start_pfn, nr_pages); =20 + arg.start_pfn =3D start_pfn; + arg.nr_pages =3D nr_pages; + mem_hotplug_begin(); + ret =3D memory_notify(MEM_PREPARE_ONLINE, &arg); + ret =3D notifier_to_errno(ret); + if (ret) + goto out_notifier; + /* * Although vmemmap pages have a different lifecycle than the pages * they describe (they remain until the memory is unplugged), doing @@ -207,7 +216,6 @@ static int memory_block_online(struct memory_block *mem) if (mem->altmap) nr_vmemmap_pages =3D mem->altmap->free; =20 - mem_hotplug_begin(); if (nr_vmemmap_pages) { ret =3D mhp_init_memmap_on_memory(start_pfn, nr_vmemmap_pages, zone, mem->inaccessible); @@ -232,7 +240,11 @@ static int memory_block_online(struct memory_block *me= m) nr_vmemmap_pages); =20 mem->zone =3D zone; + mem_hotplug_done(); + return ret; out: + memory_notify(MEM_FINISH_OFFLINE, &arg); +out_notifier: mem_hotplug_done(); return ret; } @@ -245,6 +257,7 @@ static int memory_block_offline(struct memory_block *me= m) unsigned long start_pfn =3D section_nr_to_pfn(mem->start_section_nr); unsigned long nr_pages =3D PAGES_PER_SECTION * sections_per_block; unsigned long nr_vmemmap_pages =3D 0; + struct memory_notify arg; int ret; =20 if (!mem->zone) @@ -276,6 +289,9 @@ static int memory_block_offline(struct memory_block *me= m) mhp_deinit_memmap_on_memory(start_pfn, nr_vmemmap_pages); =20 mem->zone =3D NULL; + arg.start_pfn =3D start_pfn; + arg.nr_pages =3D nr_pages; + memory_notify(MEM_FINISH_OFFLINE, &arg); out: mem_hotplug_done(); return ret; diff --git a/include/linux/memory.h b/include/linux/memory.h index 655714d4e65a..76e5ab68dab7 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -97,6 +97,8 @@ int set_memory_block_size_order(unsigned int order); #define MEM_GOING_ONLINE (1<<3) #define MEM_CANCEL_ONLINE (1<<4) #define MEM_CANCEL_OFFLINE (1<<5) +#define MEM_PREPARE_ONLINE (1<<6) +#define MEM_FINISH_OFFLINE (1<<7) =20 struct memory_notify { unsigned long start_pfn; --=20 2.39.2 From nobody Wed Dec 17 17:25:10 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FC3AC5AD4C for ; Thu, 23 Nov 2023 09:24:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232357AbjKWJY3 (ORCPT ); Thu, 23 Nov 2023 04:24:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231831AbjKWJYF (ORCPT ); Thu, 23 Nov 2023 04:24:05 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79BF21B3; Thu, 23 Nov 2023 01:24:11 -0800 (PST) Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN9GJZX001602; Thu, 23 Nov 2023 09:24:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=41K4icimMJIT45DxBnMIJJ2CEMSN8J+yKTR1FikXIs0=; b=CzoF3zocC3/hffz59bu5ojGuDiayP+RkLom6Fu6Wl/+hnSD39LFB6JlaGYqlQ5+ecvEW BGvjIMYlOKgwcBXlU5dZa7gslkSIbAv3kqN/wddSt0y2gXSxtoo+pU9Xe9xRJrdo+NKW 19ZCpzBqz4h1Q5iMEuMcZZ5rMOfvgRt/BG9hhow6naZHa8JlPYILlzjEWvRnElcjkmm5 8Szh92hc+0i1/tGUo+sDeUOZ4X8LzI1/dIiKYQ2V6fKBC7xzsoYWu91W/4spkhVgLGMU 0qBJyXW5iAvzF6Y8aTn23RSA2/SPT3dYSQMFMKRKPPSgsJVMOeUyRRAcJ69OrSvjvG5f nA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj2qpt38u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:01 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AN9HwFg007550; Thu, 23 Nov 2023 09:24:01 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj2qpt38d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:01 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN8n9CQ019199; Thu, 23 Nov 2023 09:23:59 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uf7yyxcmk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:23:59 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AN9NuNg29229742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Nov 2023 09:23:56 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9DE3A20040; Thu, 23 Nov 2023 09:23:56 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6871520043; Thu, 23 Nov 2023 09:23:56 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 23 Nov 2023 09:23:56 +0000 (GMT) From: Sumanth Korikkar To: linux-mm , Andrew Morton , David Hildenbrand Cc: Oscar Salvador , Michal Hocko , "Aneesh Kumar K.V" , Anshuman Khandual , Gerald Schaefer , Sumanth Korikkar , Alexander Gordeev , Heiko Carstens , Vasily Gorbik , linux-s390 , LKML Subject: [PATCH v2 4/7] s390/mm: allocate vmemmap pages from self-contained memory range Date: Thu, 23 Nov 2023 10:23:40 +0100 Message-Id: <20231123092343.1703707-5-sumanthk@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123092343.1703707-1-sumanthk@linux.ibm.com> References: <20231123092343.1703707-1-sumanthk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: aT6V4RuQRLbsRdxflQw3IeQf8R6_w5ys X-Proofpoint-ORIG-GUID: pflV894kYMasUOBdS7P6s82-BPDeEhJO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-23_07,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 impostorscore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 spamscore=0 mlxlogscore=939 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311230067 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Allocate memory map (struct pages array) from the hotplugged memory range, rather than using system memory. The change addresses the issue where standby memory, when configured to be much larger than online memory, could potentially lead to ipl failure due to memory map allocation from online memory. For example, 16MB of memory map allocation is needed for a memory block size of 1GB and when standby memory is configured much larger than online memory, this could lead to ipl failure. To address this issue, the solution involves introducing "memmap on memory" using the vmem_altmap structure on s390. Architectures that want to implement it should pass the altmap to the vmemmap_populate() function and its associated callchain. This enhancement is discussed in the commit 4b94ffdc4163 ("x86, mm: introduce vmem_altmap to augment vmemmap_populate()"). Provide "memmap on memory" support for s390 by passing the altmap in vmemmap_populate() and its callchain. The allocation path is described as follows: * When altmap is NULL in vmemmap_populate(), memory map allocation occurs using the existing vmemmap_alloc_block_buf(). * When altmap is not NULL in vmemmap_populate(), memory map allocation still uses vmemmap_alloc_block_buf(), but this function internally calls altmap_alloc_block_buf(). For deallocation, the process is outlined as follows: * When altmap is NULL in vmemmap_free(), memory map deallocation happens through free_pages(). * When altmap is not NULL in vmemmap_free(), memory map deallocation occurs via vmem_altmap_free(). While memory map allocation is primarily handled through the self-contained memory map range, there might still be a small amount of system memory allocation required for vmemmap pagetables. To mitigate this impact, this feature will be limited to machines with EDAT1 support. Reviewed-by: Gerald Schaefer Signed-off-by: Sumanth Korikkar --- arch/s390/mm/init.c | 3 --- arch/s390/mm/vmem.c | 62 +++++++++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 43e612bc2bcd..8d9a60ccb777 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -281,9 +281,6 @@ int arch_add_memory(int nid, u64 start, u64 size, unsigned long size_pages =3D PFN_DOWN(size); int rc; =20 - if (WARN_ON_ONCE(params->altmap)) - return -EINVAL; - if (WARN_ON_ONCE(params->pgprot.pgprot !=3D PAGE_KERNEL.pgprot)) return -EINVAL; =20 diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c index 186a020857cf..eb100479f7be 100644 --- a/arch/s390/mm/vmem.c +++ b/arch/s390/mm/vmem.c @@ -33,8 +33,12 @@ static void __ref *vmem_alloc_pages(unsigned int order) return memblock_alloc(size, size); } =20 -static void vmem_free_pages(unsigned long addr, int order) +static void vmem_free_pages(unsigned long addr, int order, struct vmem_alt= map *altmap) { + if (altmap) { + vmem_altmap_free(altmap, 1 << order); + return; + } /* We don't expect boot memory to be removed ever. */ if (!slab_is_available() || WARN_ON_ONCE(PageReserved(virt_to_page((void *)addr)))) @@ -156,7 +160,8 @@ static bool vmemmap_unuse_sub_pmd(unsigned long start, = unsigned long end) =20 /* __ref: we'll only call vmemmap_alloc_block() via vmemmap_populate() */ static int __ref modify_pte_table(pmd_t *pmd, unsigned long addr, - unsigned long end, bool add, bool direct) + unsigned long end, bool add, bool direct, + struct vmem_altmap *altmap) { unsigned long prot, pages =3D 0; int ret =3D -ENOMEM; @@ -172,11 +177,11 @@ static int __ref modify_pte_table(pmd_t *pmd, unsigne= d long addr, if (pte_none(*pte)) continue; if (!direct) - vmem_free_pages((unsigned long) pfn_to_virt(pte_pfn(*pte)), 0); + vmem_free_pages((unsigned long)pfn_to_virt(pte_pfn(*pte)), get_order(P= AGE_SIZE), altmap); pte_clear(&init_mm, addr, pte); } else if (pte_none(*pte)) { if (!direct) { - void *new_page =3D vmemmap_alloc_block(PAGE_SIZE, NUMA_NO_NODE); + void *new_page =3D vmemmap_alloc_block_buf(PAGE_SIZE, NUMA_NO_NODE, al= tmap); =20 if (!new_page) goto out; @@ -213,7 +218,8 @@ static void try_free_pte_table(pmd_t *pmd, unsigned lon= g start) =20 /* __ref: we'll only call vmemmap_alloc_block() via vmemmap_populate() */ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr, - unsigned long end, bool add, bool direct) + unsigned long end, bool add, bool direct, + struct vmem_altmap *altmap) { unsigned long next, prot, pages =3D 0; int ret =3D -ENOMEM; @@ -234,11 +240,11 @@ static int __ref modify_pmd_table(pud_t *pud, unsigne= d long addr, if (IS_ALIGNED(addr, PMD_SIZE) && IS_ALIGNED(next, PMD_SIZE)) { if (!direct) - vmem_free_pages(pmd_deref(*pmd), get_order(PMD_SIZE)); + vmem_free_pages(pmd_deref(*pmd), get_order(PMD_SIZE), altmap); pmd_clear(pmd); pages++; } else if (!direct && vmemmap_unuse_sub_pmd(addr, next)) { - vmem_free_pages(pmd_deref(*pmd), get_order(PMD_SIZE)); + vmem_free_pages(pmd_deref(*pmd), get_order(PMD_SIZE), altmap); pmd_clear(pmd); } continue; @@ -261,7 +267,7 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned = long addr, * page tables since vmemmap_populate gets * called for each section separately. */ - new_page =3D vmemmap_alloc_block(PMD_SIZE, NUMA_NO_NODE); + new_page =3D vmemmap_alloc_block_buf(PMD_SIZE, NUMA_NO_NODE, altmap); if (new_page) { set_pmd(pmd, __pmd(__pa(new_page) | prot)); if (!IS_ALIGNED(addr, PMD_SIZE) || @@ -280,7 +286,7 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned = long addr, vmemmap_use_sub_pmd(addr, next); continue; } - ret =3D modify_pte_table(pmd, addr, next, add, direct); + ret =3D modify_pte_table(pmd, addr, next, add, direct, altmap); if (ret) goto out; if (!add) @@ -302,12 +308,12 @@ static void try_free_pmd_table(pud_t *pud, unsigned l= ong start) for (i =3D 0; i < PTRS_PER_PMD; i++, pmd++) if (!pmd_none(*pmd)) return; - vmem_free_pages(pud_deref(*pud), CRST_ALLOC_ORDER); + vmem_free_pages(pud_deref(*pud), CRST_ALLOC_ORDER, NULL); pud_clear(pud); } =20 static int modify_pud_table(p4d_t *p4d, unsigned long addr, unsigned long = end, - bool add, bool direct) + bool add, bool direct, struct vmem_altmap *altmap) { unsigned long next, prot, pages =3D 0; int ret =3D -ENOMEM; @@ -347,7 +353,7 @@ static int modify_pud_table(p4d_t *p4d, unsigned long a= ddr, unsigned long end, } else if (pud_large(*pud)) { continue; } - ret =3D modify_pmd_table(pud, addr, next, add, direct); + ret =3D modify_pmd_table(pud, addr, next, add, direct, altmap); if (ret) goto out; if (!add) @@ -370,12 +376,12 @@ static void try_free_pud_table(p4d_t *p4d, unsigned l= ong start) if (!pud_none(*pud)) return; } - vmem_free_pages(p4d_deref(*p4d), CRST_ALLOC_ORDER); + vmem_free_pages(p4d_deref(*p4d), CRST_ALLOC_ORDER, NULL); p4d_clear(p4d); } =20 static int modify_p4d_table(pgd_t *pgd, unsigned long addr, unsigned long = end, - bool add, bool direct) + bool add, bool direct, struct vmem_altmap *altmap) { unsigned long next; int ret =3D -ENOMEM; @@ -394,7 +400,7 @@ static int modify_p4d_table(pgd_t *pgd, unsigned long a= ddr, unsigned long end, goto out; p4d_populate(&init_mm, p4d, pud); } - ret =3D modify_pud_table(p4d, addr, next, add, direct); + ret =3D modify_pud_table(p4d, addr, next, add, direct, altmap); if (ret) goto out; if (!add) @@ -415,12 +421,12 @@ static void try_free_p4d_table(pgd_t *pgd, unsigned l= ong start) if (!p4d_none(*p4d)) return; } - vmem_free_pages(pgd_deref(*pgd), CRST_ALLOC_ORDER); + vmem_free_pages(pgd_deref(*pgd), CRST_ALLOC_ORDER, NULL); pgd_clear(pgd); } =20 static int modify_pagetable(unsigned long start, unsigned long end, bool a= dd, - bool direct) + bool direct, struct vmem_altmap *altmap) { unsigned long addr, next; int ret =3D -ENOMEM; @@ -445,7 +451,7 @@ static int modify_pagetable(unsigned long start, unsign= ed long end, bool add, goto out; pgd_populate(&init_mm, pgd, p4d); } - ret =3D modify_p4d_table(pgd, addr, next, add, direct); + ret =3D modify_p4d_table(pgd, addr, next, add, direct, altmap); if (ret) goto out; if (!add) @@ -458,14 +464,16 @@ static int modify_pagetable(unsigned long start, unsi= gned long end, bool add, return ret; } =20 -static int add_pagetable(unsigned long start, unsigned long end, bool dire= ct) +static int add_pagetable(unsigned long start, unsigned long end, bool dire= ct, + struct vmem_altmap *altmap) { - return modify_pagetable(start, end, true, direct); + return modify_pagetable(start, end, true, direct, altmap); } =20 -static int remove_pagetable(unsigned long start, unsigned long end, bool d= irect) +static int remove_pagetable(unsigned long start, unsigned long end, bool d= irect, + struct vmem_altmap *altmap) { - return modify_pagetable(start, end, false, direct); + return modify_pagetable(start, end, false, direct, altmap); } =20 /* @@ -474,7 +482,7 @@ static int remove_pagetable(unsigned long start, unsign= ed long end, bool direct) static int vmem_add_range(unsigned long start, unsigned long size) { start =3D (unsigned long)__va(start); - return add_pagetable(start, start + size, true); + return add_pagetable(start, start + size, true, NULL); } =20 /* @@ -483,7 +491,7 @@ static int vmem_add_range(unsigned long start, unsigned= long size) static void vmem_remove_range(unsigned long start, unsigned long size) { start =3D (unsigned long)__va(start); - remove_pagetable(start, start + size, true); + remove_pagetable(start, start + size, true, NULL); } =20 /* @@ -496,9 +504,9 @@ int __meminit vmemmap_populate(unsigned long start, uns= igned long end, int node, =20 mutex_lock(&vmem_mutex); /* We don't care about the node, just use NUMA_NO_NODE on allocations */ - ret =3D add_pagetable(start, end, false); + ret =3D add_pagetable(start, end, false, altmap); if (ret) - remove_pagetable(start, end, false); + remove_pagetable(start, end, false, altmap); mutex_unlock(&vmem_mutex); return ret; } @@ -509,7 +517,7 @@ void vmemmap_free(unsigned long start, unsigned long en= d, struct vmem_altmap *altmap) { mutex_lock(&vmem_mutex); - remove_pagetable(start, end, false); + remove_pagetable(start, end, false, altmap); mutex_unlock(&vmem_mutex); } =20 --=20 2.39.2 From nobody Wed Dec 17 17:25:10 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96C1CC61D85 for ; Thu, 23 Nov 2023 09:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232628AbjKWJYP (ORCPT ); Thu, 23 Nov 2023 04:24:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231571AbjKWJYF (ORCPT ); Thu, 23 Nov 2023 04:24:05 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45F771AE; Thu, 23 Nov 2023 01:24:11 -0800 (PST) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN9GBo7011369; Thu, 23 Nov 2023 09:24:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=DwHOG1newJu1qjx/f0p46r3XXYNsOT2O58COXkYKOuc=; b=tEwLHAqpNwhif0+Ag62KIocPybR/tNk1cSj5MMY8kPdTaJS/EWQx8jaifMNNAqqi2Nq7 Ki3UdWR3EnRGhXPJfmZgpRsCWcuzCVrYUrdSygnnmBly9cr8vddRDUg+p9nGgBJOlJgi 91R1ik2d7bF48J4MLH5o60gJZFyJswaGH0XWeW4lOXhdrgcxfL6Kq9NflyXC3TI5SDL2 0C2n/pOw4aB9XEetOUfBTsDlHcCFgiO3jrhkNonp8gNqNlxT1OE1KOHoL4F0WNpZ0sCH 2X3NH24Vos+O2ThHz60ehYpoTYiM0GW6OaXkSbBM0287dsy+79hvuw7yp4fbsKJFLapB 5Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj3txrdc5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:01 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AN9GUei013633; Thu, 23 Nov 2023 09:24:00 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj3txrdbj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:00 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN8nLq6023559; Thu, 23 Nov 2023 09:23:59 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3uf9tknun1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:23:59 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AN9Nu0V43188718 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Nov 2023 09:23:57 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D9B3720040; Thu, 23 Nov 2023 09:23:56 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A29792004B; Thu, 23 Nov 2023 09:23:56 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 23 Nov 2023 09:23:56 +0000 (GMT) From: Sumanth Korikkar To: linux-mm , Andrew Morton , David Hildenbrand Cc: Oscar Salvador , Michal Hocko , "Aneesh Kumar K.V" , Anshuman Khandual , Gerald Schaefer , Sumanth Korikkar , Alexander Gordeev , Heiko Carstens , Vasily Gorbik , linux-s390 , LKML Subject: [PATCH v2 5/7] s390/sclp: remove unhandled memory notifier type Date: Thu, 23 Nov 2023 10:23:41 +0100 Message-Id: <20231123092343.1703707-6-sumanthk@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123092343.1703707-1-sumanthk@linux.ibm.com> References: <20231123092343.1703707-1-sumanthk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: eFLCguzwJR0xI4ArxCKRpAwSv_nwpZA3 X-Proofpoint-GUID: wjBewFb2_JFDdMGvDJlHQOQoAm403n7C X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-23_07,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=734 malwarescore=0 phishscore=0 clxscore=1015 bulkscore=0 mlxscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311230067 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Remove memory notifier types which are unhandled by s390. Unhandled memory notifier types are covered by default case. Suggested-by: Alexander Gordeev Signed-off-by: Sumanth Korikkar --- drivers/s390/char/sclp_cmd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c index 11c428f4c7cf..355e63e44e95 100644 --- a/drivers/s390/char/sclp_cmd.c +++ b/drivers/s390/char/sclp_cmd.c @@ -340,9 +340,6 @@ static int sclp_mem_notifier(struct notifier_block *nb, if (contains_standby_increment(start, start + size)) rc =3D -EPERM; break; - case MEM_ONLINE: - case MEM_CANCEL_OFFLINE: - break; case MEM_GOING_ONLINE: rc =3D sclp_mem_change_state(start, size, 1); break; --=20 2.39.2 From nobody Wed Dec 17 17:25:10 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FADAC636BD for ; Thu, 23 Nov 2023 09:24:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232374AbjKWJYJ (ORCPT ); Thu, 23 Nov 2023 04:24:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbjKWJYE (ORCPT ); Thu, 23 Nov 2023 04:24:04 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E37071A4; Thu, 23 Nov 2023 01:24:10 -0800 (PST) Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN8GH1E024136; Thu, 23 Nov 2023 09:24:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=ewbkfVQBj0M9I8UbdtY2XS3tABNia4iOMwJYWS5n50M=; b=P2jwBsiiB9KZyUclRC/qIyrUvPimJExVuso8pPMvhDFqzEnEEP6RTF9U4M+jEFRvpRAl S7tj8Pfe5IN88qMxiXVRU1ugV73Z/6bjzcguT08hKmZfqDor90Gt+ufKcfoMpljMn3Pm hQIqbal1makbqsnaqlUHDQ8exFF4lCpkGppShjh0BFb8MAzLXjAv9eDwfHvq+NCHyavj QY0MK0Zd9HNDvOqPJbzJtln1LtBNlSx/5CrBh6E5y6zRote50nhHBhH7+S9/A4U52kmP ZHLUPjA/pDTfXnGpYFRm57yYIaNvmb1OHocKZwlwqHV/H1FBuDEiMKkZKfr07yjgdSfr sA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj32u1n6a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:02 +0000 Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AN8fN6u006581; Thu, 23 Nov 2023 09:24:01 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj32u1n4d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:01 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN8n31u018103; Thu, 23 Nov 2023 09:23:59 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ufaa2dp5f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:23:59 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AN9NvBi2163292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Nov 2023 09:23:57 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1819320040; Thu, 23 Nov 2023 09:23:57 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DEAC320043; Thu, 23 Nov 2023 09:23:56 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 23 Nov 2023 09:23:56 +0000 (GMT) From: Sumanth Korikkar To: linux-mm , Andrew Morton , David Hildenbrand Cc: Oscar Salvador , Michal Hocko , "Aneesh Kumar K.V" , Anshuman Khandual , Gerald Schaefer , Sumanth Korikkar , Alexander Gordeev , Heiko Carstens , Vasily Gorbik , linux-s390 , LKML Subject: [PATCH v2 6/7] s390/mm: implement MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE notifiers Date: Thu, 23 Nov 2023 10:23:42 +0100 Message-Id: <20231123092343.1703707-7-sumanthk@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123092343.1703707-1-sumanthk@linux.ibm.com> References: <20231123092343.1703707-1-sumanthk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: nApaJoMH-KY3uRKJLQnwJfmUJM5pdMoa X-Proofpoint-ORIG-GUID: sXRtQvlnca6MCDp35otHAIbFMyCOS4rl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-23_07,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 spamscore=0 clxscore=1015 mlxlogscore=999 mlxscore=0 priorityscore=1501 impostorscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311230067 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" MEM_PREPARE_ONLINE memory notifier makes memory block physical accessible via sclp assign command. The notifier ensures self-contained memory maps are accessible and hence enabling the "memmap on memory" on s390. MEM_FINISH_OFFLINE memory notifier shifts the memory block to an inaccessible state via sclp unassign command. Implementation considerations: * When MHP_MEMMAP_ON_MEMORY is disabled, the system retains the old behavior. This means the memory map is allocated from default memory. * If MACHINE_HAS_EDAT1 is unavailable, MHP_MEMMAP_ON_MEMORY is automatically disabled. This ensures that vmemmap pagetables do not consume additional memory from the default memory allocator. * The MEM_GOING_ONLINE notifier has been modified to perform no operation, as MEM_PREPARE_ONLINE already executes the sclp assign command. * The MEM_CANCEL_ONLINE/MEM_OFFLINE notifier now performs no operation, as MEM_FINISH_OFFLINE already executes the sclp unassign command. Reviewed-by: Gerald Schaefer Signed-off-by: Sumanth Korikkar --- drivers/s390/char/sclp_cmd.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c index 355e63e44e95..30b829e4c052 100644 --- a/drivers/s390/char/sclp_cmd.c +++ b/drivers/s390/char/sclp_cmd.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,7 @@ #include #include #include +#include =20 #include "sclp.h" =20 @@ -319,6 +321,7 @@ static bool contains_standby_increment(unsigned long st= art, unsigned long end) static int sclp_mem_notifier(struct notifier_block *nb, unsigned long action, void *data) { + struct memory_block *memory_block; unsigned long start, size; struct memory_notify *arg; unsigned char id; @@ -340,18 +343,29 @@ static int sclp_mem_notifier(struct notifier_block *n= b, if (contains_standby_increment(start, start + size)) rc =3D -EPERM; break; - case MEM_GOING_ONLINE: + case MEM_PREPARE_ONLINE: + memory_block =3D find_memory_block(pfn_to_section_nr(arg->start_pfn)); + if (!memory_block) { + rc =3D -EINVAL; + goto out; + } rc =3D sclp_mem_change_state(start, size, 1); + if (rc || !memory_block->altmap) + goto out; + /* + * Set CMMA state to nodat here, since the struct page memory + * at the beginning of the memory block will not go through the + * buddy allocator later. + */ + __arch_set_page_nodat((void *)__va(start), memory_block->altmap->free); break; - case MEM_CANCEL_ONLINE: - sclp_mem_change_state(start, size, 0); - break; - case MEM_OFFLINE: + case MEM_FINISH_OFFLINE: sclp_mem_change_state(start, size, 0); break; default: break; } +out: mutex_unlock(&sclp_mem_mutex); return rc ? NOTIFY_BAD : NOTIFY_OK; } @@ -397,7 +411,9 @@ static void __init add_memory_merged(u16 rn) if (!size) goto skip_add; for (addr =3D start; addr < start + size; addr +=3D block_size) - add_memory(0, addr, block_size, MHP_NONE); + add_memory(0, addr, block_size, + MACHINE_HAS_EDAT1 ? + MHP_MEMMAP_ON_MEMORY | MHP_OFFLINE_INACCESSIBLE : MHP_NONE); skip_add: first_rn =3D rn; num =3D 1; --=20 2.39.2 From nobody Wed Dec 17 17:25:10 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20D0AC61D85 for ; Thu, 23 Nov 2023 09:24:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232067AbjKWJYH (ORCPT ); Thu, 23 Nov 2023 04:24:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbjKWJYD (ORCPT ); Thu, 23 Nov 2023 04:24:03 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF28CB; Thu, 23 Nov 2023 01:24:09 -0800 (PST) Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN97W5U030640; Thu, 23 Nov 2023 09:24:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=KPRlQtJdP2SQXlU1DKJM3r95nlRPrmMCK5sKODwSOzA=; b=jKsXgpfE8uTD8DkWewDFNsQIV76G5OCDgmpj+/Dch0O5EHpYNv7wGYdt1U4YrQ9fQU69 C9TGeylUy0SCKdMogksk8tsXRL1A/sw2g0oeep2fPL8UHqkyjhFn9a+q5fzGy9pecCfl n6Zi43Am6VEJ8K3GyvKgXet7LI1H20GPpsA0hHQgj1Y5BTluK19VeHKAInsUisyaOfk6 NhpMougB1kbcai5bawSSC7MeRl9HVoTDOyOXu1RrOMDwOLE6Sl2WrZqihPomj1rZc2DI OAvC/aom2gpLyn/IEWYgKFQCcHAwLh/019VwerFD2EOcCGMbMHa4ObU/pAvl0I04Jzxg tw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj3twreq5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:02 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AN9GJCQ029906; Thu, 23 Nov 2023 09:24:01 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uj3twrepp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:01 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AN8nDUT022805; Thu, 23 Nov 2023 09:24:00 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uf93m61sy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Nov 2023 09:24:00 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AN9NvIZ2163294 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Nov 2023 09:23:57 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 53A7320040; Thu, 23 Nov 2023 09:23:57 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1CCE62004B; Thu, 23 Nov 2023 09:23:57 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 23 Nov 2023 09:23:57 +0000 (GMT) From: Sumanth Korikkar To: linux-mm , Andrew Morton , David Hildenbrand Cc: Oscar Salvador , Michal Hocko , "Aneesh Kumar K.V" , Anshuman Khandual , Gerald Schaefer , Sumanth Korikkar , Alexander Gordeev , Heiko Carstens , Vasily Gorbik , linux-s390 , LKML Subject: [PATCH v2 7/7] s390: enable MHP_MEMMAP_ON_MEMORY Date: Thu, 23 Nov 2023 10:23:43 +0100 Message-Id: <20231123092343.1703707-8-sumanthk@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123092343.1703707-1-sumanthk@linux.ibm.com> References: <20231123092343.1703707-1-sumanthk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: yS8mHflc-hQ0QxnqPWywWogbjP7kcYb5 X-Proofpoint-ORIG-GUID: 0kVFvKCEU7cKCqrnqQ1w2WWgDLzYcr_Z X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-23_07,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=806 adultscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311230067 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Enable MHP_MEMMAP_ON_MEMORY to support "memmap on memory". memory_hotplug.memmap_on_memory=3Dtrue kernel parameter should be set in kernel boot option to enable the feature. Reviewed-by: Gerald Schaefer Signed-off-by: Sumanth Korikkar --- arch/s390/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 3bec98d20283..4b9b0f947ddb 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -113,6 +113,7 @@ config S390 select ARCH_INLINE_WRITE_UNLOCK_BH select ARCH_INLINE_WRITE_UNLOCK_IRQ select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE + select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE select ARCH_STACKWALK select ARCH_SUPPORTS_ATOMIC_RMW select ARCH_SUPPORTS_DEBUG_PAGEALLOC --=20 2.39.2