From patchwork Mon Nov 27 08:20:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumanth Korikkar X-Patchwork-Id: 13469257 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 3817AC4167B for ; Mon, 27 Nov 2023 08:20:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 87A1D6B0311; Mon, 27 Nov 2023 03:20:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 82A156B0313; Mon, 27 Nov 2023 03:20:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CB006B0314; Mon, 27 Nov 2023 03:20:35 -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 5CA7C6B0311 for ; Mon, 27 Nov 2023 03:20:35 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3718780151 for ; Mon, 27 Nov 2023 08:20:35 +0000 (UTC) X-FDA: 81503037630.07.3A814F7 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf08.hostedemail.com (Postfix) with ESMTP id E540F160013 for ; Mon, 27 Nov 2023 08:20:32 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=TxFgPzCD; spf=pass (imf08.hostedemail.com: domain of sumanthk@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=sumanthk@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701073233; 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=uF4hMmPu1tXjkVZJ+uKsx8mNtonIST1XxO8s9m//hfs=; b=3Ki/u4HEn8eZZTBwk6OI1UJlOprFire5+vuMGc+cNb9OzGLcxLL9pKutkQxMhoUmJuLAHu UtqGQLUXOtUKqROQLPahLLJoj51iIaWoRMiLVUzZKO6JaZwAfkOHxaLVbH2h3K0FtgfGeI 1h1JHg24Xs1mO6uCJkN12mJoAT7eH84= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701073233; a=rsa-sha256; cv=none; b=JV0uK7jBUw8+vQF4a6QCAC6WGTwOSkFhW2K9kYleqzfDDEf2kcxf+LonSYvE7/UU/7snqb nnhIwRygorWKnOUdel+F1RfvRDsiEEoTGv9OhLgfkem/9RDbskguXxqM76K08Lo6qzvDYW Au4I9tWpNR5Ucmpcg6Elxk667uNC6nA= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=TxFgPzCD; spf=pass (imf08.hostedemail.com: domain of sumanthk@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=sumanthk@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AR814s9002447; Mon, 27 Nov 2023 08:20:30 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=uF4hMmPu1tXjkVZJ+uKsx8mNtonIST1XxO8s9m//hfs=; b=TxFgPzCDOmNTBlo0mMhwodytTrlHubBzCeOjlt31bTzLdihSl4VfYF/vo30a0c2F9fNd PorW58FJCj+woxkc5nsGhVDhVmFIX9IiBu/FE5XgxmBjXDAO/pvLogyC0Pcr6DtqwZ1x xJflLHUoElor9iPYmX+2S5FN7I0hAq7b13ozdkp77Nig0CYvf0z9W1WaYWm0AvRLij49 5dHnwGTpSO9zr4xaa5zKUx234zvJl7ZzaiI52WwGxqUXp7ksYyUAT0ukr0CBcpdYL99D 915BubV56EYHvP59bKRSwqnAnt7q6AX+g+u5RmLiEKbSM4yRixQIoS+tHJGrZRXulKPv HQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3umj76ew6v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Nov 2023 08:20:29 +0000 Received: from m0353723.ppops.net (m0353723.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AR8G0Sh017041; Mon, 27 Nov 2023 08:20:29 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 3umj76ew6d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Nov 2023 08:20:29 +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 3AR8JKUV010951; Mon, 27 Nov 2023 08:20:28 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ukwy1esjy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Nov 2023 08:20:28 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AR8KPf039584186 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Nov 2023 08:20:25 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC35520043; Mon, 27 Nov 2023 08:20:25 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4EF7120040; Mon, 27 Nov 2023 08:20:25 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 27 Nov 2023 08:20:25 +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 v3 0/5] implement "memmap on memory" feature on s390 Date: Mon, 27 Nov 2023 09:20:18 +0100 Message-Id: <20231127082023.2079810-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: Tv0ls7kE_i3UAa44_HeKoUx5BaeuQuPW X-Proofpoint-GUID: sIvF8QSusNakFDxIC41Wib62yVXgCH-P 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-27_06,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 priorityscore=1501 spamscore=0 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=332 phishscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311270057 X-Rspamd-Queue-Id: E540F160013 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 4j4mj5q83zr9cjxq5358xkbydfuspmb9 X-HE-Tag: 1701073232-331248 X-HE-Meta: U2FsdGVkX19UIp7bYYVaL3s2/3M1fZYOBaaWFmwCWQfCd1xCgORT+FlGY6z2K17e86qqTpht4g4r9shaP8X51zrl7jYMReHN84vmhn7Nsb2QCtWqErNDs8QjrAzzbPh7wMncK4wSZb4AkXX2ODNm8nsR+7bNfgQin55HFA/J7edleFjhEQfRBjjNRlQZ8JCUCnEG/8v4sOGJotiSCDNrJ+QTOZdCRz2dyz5E1DYzQlQC5pFxpLrmJpXCDgPMZyMnBxG17iDIfjrzzafmI+JaxpuiE8awsf4AJuq7KkhwWQ6ibBsR39WAUFm/rp8La4Tc2JqYlPN48Z1JMq5U3H97aRAtz/zcjoW7Zi4EJ5b0xzAhM/N9bnzNE0ZgUAOyTHLzK4uxLf+GP1RR5D/6F13pIYmC4dxXZHZ+UJfv7S20zVjlPFVsU7/rAX9a7LbcwHPVvuv6pk2w506h7bit/zE2F50olfFntAyj1irLO/8ICfJNM/WVNfXxAFFMZF55B03CBQxw+jE1fJlR2gn2jR5KcqW1mdFwh8tzLhJsZXT6/44gST8NBL6+3dASiBcXAE/4VkQqF/UJ1Uf7CPwGpxcavBNrDJ6MSkR4Kk2piQJYbnMNyv07GXUvz6sVFMrJ03JIgiNanxySF51a52og2bX1/LT5xEnfYhnUlVU281vq9cyuP7SXOpZC3xxg9NxETIMZcdC3QzvMm9J60myhPE2z0fA3ZCyWXzvDMWxlgVMJrU6gIy7BMAUrQUN4ZShCVOgnhWhkflKzLY/QdVMqZc5NENIMHI23wlgCKwBC9JXZ9musQ4/LwM246NiDlLmPPpSPAbq9w7/MjgIyJ/MuaZ2Wq+V0BuK4P+yJ54ko98YfMXpa0ET+5qOCKHuKkR5dZZVRfVvW+t8VcxYyVngMxPzde4acHFkZxIwLHqwCGnBxkDx7RmllsaBAt1fgqnKxm3ZA20M189EmPoF1OrnLu0w p6X+nU+p vjB/NSoshmKtKvbAOQbC0E+TsBazWbFMTx0I6ORwS3Fm+ZDe02DqVC69xUSqo63eo54hgWxrdGwpV9smdsf2Uxbi4qI5zUBYmw5CsODf9m9IwK2eReIi7jF1v5MyXWFUzzm1ep7UapG8MMOOHyNOemTPjVj+5P7HTrpeiwqhRsAnwXx+l0n5hY9PpVrr3U2HO4PNqGKLIClGlaTncPGUMqH5lZQ== 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. Patch 1 introduces MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE memory notifiers to prepare the transition of memory to and from a physically accessible state. New mhp_flag MHP_OFFLINE_INACCESSIBLE is introduced to ensure altmap cannot be written when addidng memory - before it is set online. This enhancement is crucial for implementing the "memmap on memory" feature for s390 in a subsequent patch. Patches 2 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 3 removes unhandled memory notifier types on s390. Patch 4 implements MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE memory notifiers on s390. 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 Patch 5 finally enables MHP_MEMMAP_ON_MEMORY on s390 Note: These patches are rebased on top of three fixes: mm: use vmem_altmap code without CONFIG_ZONE_DEVICE mm/memory_hotplug: fix error handling in add_memory_resource() mm/memory_hotplug: add missing mem_hotplug_lock v3: * added comments to MHP_OFFLINE_ACCESSIBLE as suggested by David. * Squashed three commits related to new memory notifier. v2: * Fixes are integrated and hence removed from this patch series Suggestions from David: * Add new flag MHP_OFFLINE_INACCESSIBLE to avoid accessing memory during memory hotplug addition phase. * Avoid page_init_poison() on memmap during mhp addition phase, when MHP_OFFLINE_INACCESSIBLE mhp_flag is passed in add_memory(). * Do not skip add_pages() in arch_add_memory(). Similarly, remove similar hacks in arch_remove_memory(). * Use MHP_PREPARE_ONLINE/MHP_FINISH_OFFLINE naming convention for new memory notifiers. * Rearrange removal of unused s390 memory notifier. * Necessary commit messages changes. Thank you Sumanth Korikkar (5): mm/memory_hotplug: introduce MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE notifiers s390/mm: allocate vmemmap pages from self-contained memory range s390/sclp: remove unhandled memory notifier type s390/mm: implement MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE notifiers s390: enable MHP_MEMMAP_ON_MEMORY arch/s390/Kconfig | 1 + arch/s390/mm/init.c | 3 -- arch/s390/mm/vmem.c | 62 +++++++++++++++++++--------------- drivers/base/memory.c | 21 ++++++++++-- drivers/s390/char/sclp_cmd.c | 31 ++++++++++++----- include/linux/memory.h | 2 ++ include/linux/memory_hotplug.h | 18 +++++++++- include/linux/memremap.h | 1 + mm/memory_hotplug.c | 30 ++++++++++++++-- mm/sparse.c | 3 +- 10 files changed, 127 insertions(+), 45 deletions(-)