From patchwork Tue Nov 14 18:02:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumanth Korikkar X-Patchwork-Id: 13455775 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 22B4BC4332F for ; Tue, 14 Nov 2023 18:02:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F6156B02F8; Tue, 14 Nov 2023 13:02:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A5FE6B02FA; Tue, 14 Nov 2023 13:02:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 547116B02FE; Tue, 14 Nov 2023 13:02:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 44C976B02F8 for ; Tue, 14 Nov 2023 13:02:56 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E7E5B1CB78E for ; Tue, 14 Nov 2023 18:02:55 +0000 (UTC) X-FDA: 81457330710.04.EFBFAD0 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf04.hostedemail.com (Postfix) with ESMTP id B67654002E for ; Tue, 14 Nov 2023 18:02:53 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="argcVbC/"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf04.hostedemail.com: domain of sumanthk@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=sumanthk@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699984973; 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:references:dkim-signature; bh=b9kbxAnG1pdTsFzVrWyA16FcOHZys5jgBlDNWM5n5cU=; b=edssGoLDpgS/ra52iefpMph42zuKG8aL3s0a5yyI3BGpZc8zRMxWsTQEMGNiV5iTZlst1j Q+zdeEsbRrAe5jVP6GU/wGQcwkoWpTBj2ZJ319cycsTNX1zBCSQtUSfr75kGQmm/Q7HzOi q8LEYa9mEtyM6BFaNxwYDwo76jXYiDY= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="argcVbC/"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf04.hostedemail.com: domain of sumanthk@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=sumanthk@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699984973; a=rsa-sha256; cv=none; b=7zWsyKohXrJfYmfGL/sD1kcqgwqSHGhrp92XitrcfLxEyhy0X9NIfhmnyWtIVuCbVbSjSn tJzH7Vv4cNvg+RyBJJBbXFjNo388xj3GR94WShUUNX4hBcZ26JE7rTyozCDNVvt2sIQhP0 OuhbSfEHiln1PEpKspbDSe0tmFQo8mc= Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AEHaWkQ020648; Tue, 14 Nov 2023 18:02:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=b9kbxAnG1pdTsFzVrWyA16FcOHZys5jgBlDNWM5n5cU=; b=argcVbC/VuADRxGIwrPjUi92qOLfoUirjTPWz/2XtxkmWK79zhhlPtOIUer81fDqn3P2 xdNvvh4yF4xZKZbGQ3tZCv7dK2nkSXEU1PNU+vCa5vHxbk1qaIuoxU1NIGxsURfPxOeo Qw+i6saXFs2cjC+T+GGBfaWsf2d52IuQJapGTPtLH8O6VAEhSe//Bdyu7UxVtu5fP2R9 +YDW9pVAi/B6TIGcUEgoxxNOp8aTu+vWOSTo1K/k6HmrqfhuIYK//A1yfCmlIC1XOf9v 5927Ify1U51S7HlIUrdOWRBuXmqcIAz6Sjc96TWk1fRLGaDgytJUt7siDWiE8JD3GBwF 9A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ucdeg8r8h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Nov 2023 18:02:50 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AEHan3b021195; Tue, 14 Nov 2023 18:02:49 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 3ucdeg8r7x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Nov 2023 18:02:49 +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 3AEGY3rk017575; Tue, 14 Nov 2023 18:02:49 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uanekhftm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Nov 2023 18:02:48 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AEI2jDS787092 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Nov 2023 18:02:45 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 794AF2004B; Tue, 14 Nov 2023 18:02:45 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D1532004D; Tue, 14 Nov 2023 18:02:45 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 14 Nov 2023 18:02:45 +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 , Alexander Gordeev , Heiko Carstens , Vasily Gorbik , linux-s390 , LKML Subject: [PATCH 0/8] implement "memmap on memory" feature on s390 Date: Tue, 14 Nov 2023 19:02:30 +0100 Message-Id: <20231114180238.1522782-1-sumanthk@linux.ibm.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 2WT_AHfHlzioBkvzqBUMo-HtrfzDZ5Ov X-Proofpoint-GUID: 1m10EwI2GbB1yhTCnXWcG05GeP1uqN1O 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-14_18,2023-11-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 mlxlogscore=414 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311140136 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: B67654002E X-Stat-Signature: 3ybgy7qjstodh9z86wtbr1c3moedp8q5 X-Rspam-User: X-HE-Tag: 1699984973-344526 X-HE-Meta: U2FsdGVkX192k9/XjoU3oMPpR/cU285QtoAduuMbBWSfM188B4x1GWv0+6Vo6VVfyA0dKKb8Bs+s6kvzyc+pHBV3YWjs3hzPHTmvTI3W3kEzf3nLH24NY9seHQti2kdu3Jq0QEaAzERcLbnSzY2YDfAvFYrfXjAUAdY0bs6hkHFpCVWPgJwQ3i1EDnVB/MksTb4Ja4wInks90plLMhdnTzh/YrKRtsnO7inqIamv2zfX+RSonumFc0VZH6dcRZ7nJSBrX4+3TDQiMPjMKz4+Bh90w6i7WsnvNOUaREEXBzUrOtSNSvLVwV9O/yQBqm/Cu3+ZAgIFR4+os0ItsUdeQmLcuW9w8G+iEziK39slSKsuhvJLucnLt0N2fUtOJ2oC6PeLRDRmsBN9AlLe1HqRk7lMhg1jX5ZXEmdfZsaIawY4H659QVbgXE1YOIDqUYNwsCN9tzN/vxka045wpv5xvUvm9MLNOyfkgEaPTdStzyDZxBCR6saWbqnb0ZQUqxTFT/qW5llKydUdryN+mwL3nCZLwDkrFiZNhqyD3HbxEtoTrbj+ZRPvzVxDB1qgxemnQLL0XYgyQ/d9wKilTKtJFSmwCJJLh5coJTK3VjlVn4cVI8Mv5li9EtjD5+ysnA+Ns1y0Iywj7vfTGWBsr+k25NuHP3k6WEeMiN/4K/YvgPBTsgfCIBzRievB3Bhi1vePA8enviXdhH0rvcbeMBh0pTxQ3LIGmVt1rUGTYC+0pEwDOWwYuntJQMjzOui9nq+0z/fRBKqIT+d8dMKBQemNSYeQ3Kh57sRsfdR5Ii+2jgU858KUSkAF8vJCbutohhqC218+KRRJktd7kVLopNQfV9km4fYlF8e3J9LWjlWd/QacSJny4Xi13VlJ7jfY5PX/f0FvZzNtBRRUXzppufeQCJj9Xdowp5Gaw9V1qXzkjIGAkg+c4Gjnzvtca3iGQ6CfeVJEGYt5X8SAxmD9HaR JBPYP+Ta 2VlvBLpyceYoQYwtBnkPrUtdapelzq0oMG3WCXjyQIeMbdgUCn8ya4jybXZR489QyTuiAx0LVe1+Ub4dI9Kj35cBicBRvrT16mPFbx3NauGjILmE06n/pEW7bAw== 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: Hi All, The patch series implements "memmap on memory" feature on s390 and provides the necessary fixes for it. Patch 1 addresses the locking order in memory hotplug operations, ensuring that the mem_hotplug_lock is held during critical operations like mhp_init_memmap_on_memory() and mhp_deinit_memmap_on_memory() Patch 2 deals with error handling in add_memory_resource() and considers the possibility of altmap support. This ensures proper deallocation of struct pages, aligning with the allocation strategy. Patch 3 relocates the vmem_altmap code to sparse-vmemmap.c, enabling the utilization of vmem_altmap_free() and vmem_altmap_offset() without the dependency on CONFIG_ZONE_DEVICE. Note: These functions are also used in arm64 architecture. However, ZONE_DEVICE or ARCH_HAS_ZONE_DEVICE doesnt seems to be enabled in arm64. Patch 4 introduces MEM_PHYS_ONLINE/OFFLINE memory notifiers. It facilitates the emulation of dynamic ACPI event-triggered logic for memory hotplug on platforms lacking such events. This sets the stage for implementing the "memmap on memory" feature for s390 in subsequent patches. All architecture/codepaths have the default cases handled in memory notifiers. Hence, introducing new memory notifiers will have no functional impact. Patches 5 allocates vmemmap pages from self-contained memory range for s390. It allocates memory map (struct pages array) from the hotplugged memory range, rather than using system memory by passing altmap to vmemmap functions. Patch 6 implements MEM_PHYS_ONLINE and MEM_PHYS_OFFLINE memory notifiers on s390. It involves making the memory block physically accessible and then calling __add_pages()/__remove_pages() with altmap parameter. Patch 7 removes unhandled memory notifier types. This is currently handled in default case Patch 8 finally enables MHP_MEMMAP_ON_MEMORY on s390 Thank you Sumanth Korikkar (8): mm/memory_hotplug: fix memory hotplug locking order mm/memory_hotplug: fix error handling in add_memory_resource() mm: use vmem_altmap code without CONFIG_ZONE_DEVICE mm/memory_hotplug: introduce MEM_PHYS_ONLINE/OFFLINE memory notifiers s390/mm: allocate vmemmap pages from self-contained memory range s390/mm: implement MEM_PHYS_ONLINE MEM_PHYS_OFFLINE memory notifiers s390/sclp: remove unhandled memory notifier type s390: enable MHP_MEMMAP_ON_MEMORY arch/s390/Kconfig | 1 + arch/s390/mm/init.c | 19 ++++++++--- arch/s390/mm/vmem.c | 62 ++++++++++++++++++++---------------- drivers/base/memory.c | 28 ++++++++++++++-- drivers/s390/char/sclp_cmd.c | 37 +++++++++++++++------ include/linux/memory.h | 2 ++ include/linux/memremap.h | 12 ------- include/linux/mm.h | 2 ++ mm/memory_hotplug.c | 15 ++++----- mm/memremap.c | 14 +------- mm/sparse-vmemmap.c | 13 ++++++++ 11 files changed, 129 insertions(+), 76 deletions(-)