Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3168981rdh; Mon, 27 Nov 2023 07:52:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFnMS4NsLNasM5GVVr/9yIW/wtHH4uMqNIh558J1d/iOvW09Ohw1FaVhH0J/HsWiK4TuFP3 X-Received: by 2002:a05:6a00:2d07:b0:6be:2991:d878 with SMTP id fa7-20020a056a002d0700b006be2991d878mr13433493pfb.15.1701100340212; Mon, 27 Nov 2023 07:52:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701100340; cv=none; d=google.com; s=arc-20160816; b=pk0V6p5R7y8Bs256M0urrwMeuw8mOr6lmQJCeE2P1xAkwqorOKhGDiAipzJzInua1k OM8j8HySdBh9ZRbG2LxL2cx1ohjHWBI2moMRmM7Tsov4vJPjdhTB40v7Ija2tq7GH2Ep xmawutoT0hG7EjDFqP2v2hJpi6gN+4CtEIjbyP7x7TpkPH7cL8HUUTwYsBWiwpsBqH1I IyYzovDJVgci/RnumUdvZtswLMPAbqRvhB1jG14FuKXTTpTLFs4hMheimEbMxrY3SUjg sZoVkVwXPTKJghylKtcQpW9OPkKnpGECgrkckL/x/EutBiBAEAKU41PV8noFmpkQMQrE EfmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:autocrypt:from:references:cc:to:content-language :subject:user-agent:mime-version:date:message-id:dkim-signature; bh=/MW6fXJWJVxOzUmBSa6MQ4ghqr1tOYYSz5WWxvHituE=; fh=X+Fedw4hCbMH4Ev0QS2iCi+1HRHPhDeMRzp+H1VGUG0=; b=hxiwFhqPLu9/UuPM6ubFGdAGFuBe+p/+2PwG9HG7rWPSfhpKSI3TQY3a8/9SMjdg6e H/nU5BmKQPO60yjO7Ol0pZWxfAlnLiwWwmDyTHZXqbRups3vz9kLxmwbjjuvWklRQ6Gc HOR1TwwZXjXeRpZ7Fkk7V47xhSkotL9Yqff/xOa0sIVwBhDmgZWlIPZ1b7f2zZWL6WnA YssTovnLNrDh/l0v1OzjNJT73py94vtqOmk5rDn8W7LO+/OTdW65ARpmIB5pWVRzq5Mq YzjEhhOHWPsVb7igC4G9MjVNFXZ7Gn5zOmNoXN97rqchCcQ4t8QORLJMHMZp0ySA7QZP xXyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ISOTGnOO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id fa33-20020a056a002d2100b006c0e02cdadcsi10180568pfb.208.2023.11.27.07.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 07:52:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ISOTGnOO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 17ACB8098487; Mon, 27 Nov 2023 07:51:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234149AbjK0PvT (ORCPT + 99 others); Mon, 27 Nov 2023 10:51:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234109AbjK0PvI (ORCPT ); Mon, 27 Nov 2023 10:51:08 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D0531AE for ; Mon, 27 Nov 2023 07:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701100271; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=/MW6fXJWJVxOzUmBSa6MQ4ghqr1tOYYSz5WWxvHituE=; b=ISOTGnOO5BoVtG/KVnj0caA7HdrNMLq1CnUkc7pLQtSY9eyvy+AvP32ok4ll7+vcXos0vq 3N1wqNs2pzPSP/Kqh3n53CHxwj0TgfP+8v1xGUyBW5xc5zhb7/74J9WaTTN/ZMz06yu8Zv M7n6dUYf8TBv4WJ5gXM8REPQaAlTdt0= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-319-GluuB6yyOzCcdnO4-17yYQ-1; Mon, 27 Nov 2023 10:51:08 -0500 X-MC-Unique: GluuB6yyOzCcdnO4-17yYQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-332f5ff511aso1681967f8f.2 for ; Mon, 27 Nov 2023 07:51:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701100261; x=1701705061; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/MW6fXJWJVxOzUmBSa6MQ4ghqr1tOYYSz5WWxvHituE=; b=EkZzJMcXnpAdrcfANAqDO2RlzBqsnXJuB9uCr6/APkRwPrbheuTx1nHPeANt2NPy70 QxBzGAm26qON+jU9/eW9qMx7QpXzJHs0vwsEVuvkt/jDTluurfIO1gDgsM412hPasSKZ hDzl8KoYPx//lXzzSiVpaEyNsxcrJGCNN4p6HghBvjq/ehN6WdSbwM0LLCKfgPlcHKmI x2rDMIrEglwUV5ONcTlu8hrzsSgmmaLS8RV/VgicKM/Z0UF53M8meqfVuTzKI14EDmDk aB/1Nz5hrvBkysK6+q4UxbvR8TbobOI2dBeMWF3jaYlOjnQbu+XKnFJvzFb1tAqcGSHx edYQ== X-Gm-Message-State: AOJu0YztPwuwL9d5JXraGSc2TJAgV+/LJeGZjj+xx8FjhtY2OfIAYy6g nfuQ6kl+ccUNk8KM3mmCoHS4PKKWEI8Tj/i93fXFfNUfFtM/Q0RDtiXC0Ua8ulLZibpvvYslJ7I OEUTDiOiEnyTnmgf0MKmSBIjV X-Received: by 2002:a5d:42c6:0:b0:32f:8248:e00 with SMTP id t6-20020a5d42c6000000b0032f82480e00mr7904607wrr.51.1701100260860; Mon, 27 Nov 2023 07:51:00 -0800 (PST) X-Received: by 2002:a5d:42c6:0:b0:32f:8248:e00 with SMTP id t6-20020a5d42c6000000b0032f82480e00mr7904593wrr.51.1701100260472; Mon, 27 Nov 2023 07:51:00 -0800 (PST) Received: from ?IPV6:2003:cb:c745:2a00:d74a:a8c5:20b6:3ec3? (p200300cbc7452a00d74aa8c520b63ec3.dip0.t-ipconnect.de. [2003:cb:c745:2a00:d74a:a8c5:20b6:3ec3]) by smtp.gmail.com with ESMTPSA id e15-20020a5d594f000000b00332fda15055sm4434889wri.111.2023.11.27.07.50.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Nov 2023 07:51:00 -0800 (PST) Message-ID: Date: Mon, 27 Nov 2023 16:50:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/5] mm/memory_hotplug: introduce MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE notifiers Content-Language: en-US To: Sumanth Korikkar , linux-mm , Andrew Morton Cc: Oscar Salvador , Michal Hocko , "Aneesh Kumar K.V" , Anshuman Khandual , Gerald Schaefer , Alexander Gordeev , Heiko Carstens , Vasily Gorbik , linux-s390 , LKML References: <20231127082023.2079810-1-sumanthk@linux.ibm.com> <20231127082023.2079810-2-sumanthk@linux.ibm.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT4wJCfxwocmqaRr6UYmrtZmND89X0KigoFD/XSeVv jwBRNjPAubK9/k5NoRrYqztM9W6sJqrH8+UWZ1Idd/DdmogJh0gNC0+N42Za9yBRURfIdKSb B3JfpUqcWwE7vUaYrHG1nw54pLUoPG6sAA7Mehl3nd4pZUALHwARAQABzSREYXZpZCBIaWxk ZW5icmFuZCA8Z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x7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20231127082023.2079810-2-sumanthk@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,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 lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 27 Nov 2023 07:51:47 -0800 (PST) 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 > --- > drivers/base/memory.c | 21 +++++++++++++++++++-- > 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 ++- > 6 files changed, 69 insertions(+), 6 deletions(-) > > diff --git a/drivers/base/memory.c b/drivers/base/memory.c > index 8a13babd826c..5c6b2af75db4 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 = section_nr_to_pfn(mem->start_section_nr); > unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; > unsigned long nr_vmemmap_pages = 0; > + struct memory_notify arg; > struct zone *zone; > int ret; > > @@ -197,6 +198,14 @@ static int memory_block_online(struct memory_block *mem) > zone = zone_for_pfn_range(mem->online_type, mem->nid, mem->group, > start_pfn, nr_pages); > > + arg.start_pfn = start_pfn; > + arg.nr_pages = nr_pages; Thinking about it, it's possibly cleanest to send the altmap range along here. Later memory onlining notifiers will only be notified about the actual !altmap part. arg.altmap_start_pfn = start_pfn; arg.altmap_nr_pages = nr_vmemmap_pages; arg.start_pfn = start_pfn + nr_vmemmap_pages; arg.nr_pages = nr_pages - nr_vmemmap_pages; Use that for the two new notifiers only and document it. Thoughts? -- Cheers, David / dhildenb