From mboxrd@z Thu Jan 1 00:00:00 1970 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 64800C4167B for ; Tue, 28 Nov 2023 07:54:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB23B6B0293; Tue, 28 Nov 2023 02:54:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B61076B029A; Tue, 28 Nov 2023 02:54:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4FDF6B02A2; Tue, 28 Nov 2023 02:54:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 96BFF6B0293 for ; Tue, 28 Nov 2023 02:54:54 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 68CC31C006A for ; Tue, 28 Nov 2023 07:54:54 +0000 (UTC) X-FDA: 81506601708.19.CD89ED9 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf30.hostedemail.com (Postfix) with ESMTP id 2147780004 for ; Tue, 28 Nov 2023 07:54:51 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=klNhIv9X; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf30.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=1701158092; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mvhId/iOn6bQbWlkTiJuvlh1+3b6/ZRtze8kpz/5F1U=; b=otClzQhT2xQAQd3yI89W1KLUn66zFafkN4LtPrj4x2Eunrb79BAl+ec+zUB2lMDoxaGEzy MErUN58szqnRSgFPaN8rhO9W8W1nVYajzRSOICwhymZ86mwtUPY2VhCQwNbjHHT/DrBg4B BmlY1NNc8FKx7zZ0+gpT0JVaPE9R1to= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=klNhIv9X; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf30.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=1701158092; a=rsa-sha256; cv=none; b=L27OSlAQrPdAD1DcZIPcRmoESeItDZnJhiyH4jit+0YS4e/7rvPaUkqpytSs1kcbhFy6gZ FwqueoLJ+CX89e6/Etm+npzJ3B3Ba6YtiwEQLq51r6Spa7liNlKjl0MLMqsUTjU5ohOrxv aBNTj3+20bNO+Mkk+kZKMSE0fl+i2G8= 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-Rspam-User: X-Stat-Signature: hify8hi7njjihrobujkpocmddmb7zok1 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2147780004 X-HE-Tag: 1701158091-959712 X-HE-Meta: U2FsdGVkX19674ZS2ylxacZw7jV5sg4wa2W/jCmNNrl1nP6Wp+sBztRRfClQ4eWpDvHFuzylHm1m6lQBczOK34Z/AcI/veDltIGUiOuPQQEMJY6LdbOfuvqw53DAEohzJqsAmd5HcEeC7/r/K2cH+qNCG0moD7Vg0G/RK1tyqH+CLQJ4UOREFkPzXpxEVh/W2qrbZ/Iab0/VC52BgK0MH+VBpa8gWJ62gq41fneoOlG5oYfvxPwjTF5qMKWHpgG4jAXUshLmkUgFJqgcBr8qrHE7yPHhsfww4gGzgs/mT4/RKFNF6j9Hc88bRBaDe5TTrBE/WBEsf/bAzGbaG94QutEoxZp6y7FyaaPIOk/YhdfD1XhPcimYfN/dxtwKFhPH/WMdDtimDklrnHCfTNtOGF/7HUlSBQKosa4LdwWzMtItun25z237XsJ01N1liVDZru+69IXy24aQqlPnY3uftitK+rQhE16iRqIYJZsPU52J0YH+92e8MrSR3VKDT5K+aMrgzBpioCbNqEpDr7WdkFBftwiW96qKWc39kgFodIXOMRQ/Pmgaa5espdO+VCSwmYTtpTwHeHG7ENflLzOlrYOlgs3AOKzHpIlb5w+YcPIeQI3qoQAfqiLsThT9wRrj6a6B91H14qfwmzKLhwN8+JjWDNt0DfLvuS7zrEzWi6kEin5f4lU/W+jYbnSO2p/rVPOeqgWB6Vbpdmp4gfJ9BOPaTS+RrD+kurNI7d8d+cnmG2Ijh+zwaZe1aq04RZikUjU+3jJu3n9t+iCNQC+a5AjHPBedbcxS0CHk8oTj9BerlCmMBlLOAvJCdMjUi4xUGZuYhhX7VnTsbnZ3XBAiu47x5HtBqld8raaIYmP+Vaaj0AZ957bsCC7nAkCs0WIdZ8+Gzc58MI40PMqCv3eICBtaykhyGYRBB31g+Q73gE3wXNlDG66lqf6hsv71vXhVA8jmL4paVnVDnysI50d rMIgv6jl wGoKNoatF+A/YBunmRp3iCsOFJMwGE+npy1lvboQNJRdT8oFJTe+K7aVQsAm7C5CHcRvamS2ACOnsjQ8w1uUHYAphj1XeZZ8HWQoYzW176ATtXAdLxUgh2XDYup0U2R+RbeHiBS4EhzXXm5IDtsb5ToFr16PQP39eggtdr5Oio11CUs0nKfBZ4RXXsvi2KvDdRS84HH7pxZbHGUCiF+GCxetVInwApBSgb4VDWkumO7mwv+4EpNSMT3aTrnXQ8pD0fyLD8OM8LQVvpO6xYLTw5lw4iJS9Hp1Gdfw0HCq516SMIhumFKR0QIP6joE1mqNz+qnlRMqpiBMi09G6G5KUeO/ZRFaiEK1zGNim 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: 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