Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3671634rdh; Mon, 27 Nov 2023 23:55:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHt8ypv8nHNADGTStVXZMCUzxJyuf32s+Yf3YNI+pFrwa9dl3MZtkfYLLGDbkL1nOq7+u/d X-Received: by 2002:a05:6358:7f1d:b0:16e:2898:5e01 with SMTP id p29-20020a0563587f1d00b0016e28985e01mr14004793rwn.3.1701158144651; Mon, 27 Nov 2023 23:55:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701158144; cv=none; d=google.com; s=arc-20160816; b=CeuLrRByHCSnA6K1mS2t1tJgmmy2QlqpFjflJNTF/6CVhEmMHfhzSxHFVvOwwBkUPh tI8e+jmP6eWoFSrsroxCg+eIJrx9IhDhXtZ+rLqLOmtJtAA5MpTaRFR+j09IGSWBx5XK RMpdgZPi2jGdnv6kETfur8XXnFKFGwr2aGdv6K1riQmR23Jxw1HSW1ccDEO5GP4A3I2n rTSnwrjzMQNZS358jiQ06LAq00dG319fEraQQ9D1lXLC3A9ETfl/b6RDl3RnmMqlLCPF P0ZqSnTBP239PKcIORKJV5AnOMbsfUUIy6RQRwDzszNGs8DMPz88Io9OXX9bBITYbcTo xTqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mvhId/iOn6bQbWlkTiJuvlh1+3b6/ZRtze8kpz/5F1U=; fh=zSdfwdfY54C9/udZTRlhmjTBbI0CKWDSGiWvzuMGAEs=; b=AHYmiMHRM51dvuX5wo6iS6ux9RMEEMgZl8tcOMXG8anDsaWb2yo76d8xGnTMfam/gL rQO12ldxjt2Eq8qWamx3+yIZOcieUT8RgXdStvh00nLlUmTaSvnO1AL0k9oTURrJF6Kk T3Cb7745rdb8TEt6/Z3yuBJPOQzj6R0S7cDvFmW+SL9OxZ0MzYWA1iKyHF7uPvnlQaBZ IeXytgfEB76MaYdMn0yl0V7PAMCqS2NjRnISumBKHw0xxMcHGI5H6e4EdgHRNpYtVd4H KolkskvGRybdXtN5nbd8bDNylh1Bl5jS/2XoHIn4i1RV7YcRf9TGMnYTyt44ihT3ed4o JbxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=klNhIv9X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id i30-20020a63585e000000b005bdfd3a0d3esi11668116pgm.185.2023.11.27.23.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 23:55:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=klNhIv9X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 26242807E467; Mon, 27 Nov 2023 23:55:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343904AbjK1Hyy (ORCPT + 99 others); Tue, 28 Nov 2023 02:54:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230390AbjK1Hyw (ORCPT ); Tue, 28 Nov 2023 02:54:52 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 279E598; Mon, 27 Nov 2023 23:54:59 -0800 (PST) Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AS7fkE8004051; Tue, 28 Nov 2023 07:54:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=pp1; bh=mvhId/iOn6bQbWlkTiJuvlh1+3b6/ZRtze8kpz/5F1U=; b=klNhIv9XTqECkEL2JmXlXqyYsYG7G930xOrFNYI7iEGormjavzrCJcXaRnuBEB16G/WY DBjwyzoeyV1+DsTAmoQQRbY++20gXl2672sxUfNHgH0NJjOqlzpK+IewGHCBpm2NrLu7 oc8TWaQObGZuPrAZb5iRB6eyGS6+HCs84siTXj7RaftRDWIEyCrTb7drD7EpH9n7AotR uu9QDOKxoFwRr4505PQOR9ObiaZe3fxRvFFIcmVrDrtwt9f7uVDOviLUUimGbgFXSqaX fij4X3Bj5bsHTJTRoa0eDYqmhJuvHDQQzvavdpnHBDXMQyqGUHAkUFp8ryO3qZVdJFRQ KA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3unah2k3py-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Nov 2023 07:54:49 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AS7fnm5004679; Tue, 28 Nov 2023 07:54:48 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 3unah2k3pn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Nov 2023 07:54:48 +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 3AS7NGli004930; Tue, 28 Nov 2023 07:54:47 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ukwfjwvkg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Nov 2023 07:54:47 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AS7si4f27066916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Nov 2023 07:54:44 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B3F8E2004B; Tue, 28 Nov 2023 07:54:44 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 141FC20043; Tue, 28 Nov 2023 07:54:44 +0000 (GMT) Received: from li-2b55cdcc-350b-11b2-a85c-a78bff51fc11.ibm.com (unknown [9.179.11.62]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTPS; Tue, 28 Nov 2023 07:54:44 +0000 (GMT) Date: Tue, 28 Nov 2023 08:54:42 +0100 From: Sumanth Korikkar To: David Hildenbrand Cc: linux-mm , Andrew Morton , Oscar Salvador , Michal Hocko , "Aneesh Kumar K.V" , Anshuman Khandual , Gerald Schaefer , Alexander Gordeev , Heiko Carstens , Vasily Gorbik , linux-s390 , LKML Subject: Re: [PATCH v3 1/5] mm/memory_hotplug: introduce MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE notifiers Message-ID: References: <20231127082023.2079810-1-sumanthk@linux.ibm.com> <20231127082023.2079810-2-sumanthk@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-GUID: kCNG8rYAMNiN1LpdXU_VXqr5NeMHArEt X-Proofpoint-ORIG-GUID: wc8ecEWfv7zif7pkpuC-EjvZRuKliQM4 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-28_06,2023-11-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 suspectscore=0 impostorscore=0 mlxlogscore=317 spamscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311280060 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 27 Nov 2023 23:55:14 -0800 (PST) On Mon, Nov 27, 2023 at 04:16:18PM +0100, David Hildenbrand wrote: > On 27.11.23 09:20, Sumanth Korikkar wrote: > > 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 and > > during the memory onlining phase s390 requires memory to be physically > > accessible and then subsequently initiate the "memmap on memory" > > initialization process. > > > > The memory provider will handle new MEM_PREPARE_ONLINE / > > MEM_FINISH_OFFLINE notifications and make the memory accessible. > > > > The mhp_flag MHP_OFFLINE_INACCESSIBLE is introduced and is relevant when > > used along with MHP_MEMMAP_ON_MEMORY, because the altmap cannot be > > written (e.g., poisoned) when adding memory -- before it is set online. > > This allows for adding memory with an altmap that is not currently made > > available by a hypervisor. When onlining that memory, the hypervisor can > > be instructed to make that memory accessible via the new notifiers and > > the onlining phase will not require any memory allocations, which is > > helpful in low-memory situations. > > > > All architectures ignore unknown memory notifiers. Therefore, the > > introduction of these new notifiers does not result in any functional > > modifications across architectures. > > > > Suggested-by: Gerald Schaefer > > Suggested-by: David Hildenbrand > > Signed-off-by: Sumanth Korikkar > > --- ... > > 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 = pfn + nr_pages; > > int ret, i; > > @@ -1092,7 +1109,14 @@ int mhp_init_memmap_on_memory(unsigned long pfn, unsigned long nr_pages, > > ret = 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); > > Can you elaborate why a simple page_init_poison() as for > sparse_add_section() is insufficient? > Looks like cond_resched() is not needed. page_init_poison() could be performed similar to when adding new memory in sparse_add_section(). IIUC, As memory is onlined in memory block granuality, this cond_resched() wouldnt be needed then. Thanks