Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1338670rdh; Fri, 24 Nov 2023 10:04:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEKKS6JS+b8dWPG3uITXxoYLh22Vod6GNU+twZaODR8eFn4ldSxhMuS6L6gleWIxMmK+pr X-Received: by 2002:a17:903:244e:b0:1cc:4677:2f0e with SMTP id l14-20020a170903244e00b001cc46772f0emr4717221pls.45.1700849087454; Fri, 24 Nov 2023 10:04:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700849087; cv=none; d=google.com; s=arc-20160816; b=OYCLVw+kJ4RcjRVEyiwhDMf5vML90eLp9E3npq8PlnOuKXivq41qGtzMpCrIe5NJUZ 4O4pVR84tqvDh/jOcdVewfzfI4wawgF8L/2tDDEoNH7epfYwVakH3fHtbQxtxqOFusbu SXjze8u7lFMz2OMq4NU6xnqiQDqoX0+51PCtMS57IXI3XEfrHt1jtEIePId18sCVfmOb dBCMpKbGHLnpZBZZQSIquYwQSqTknPEhye3v/T1jtKvX1e/HdiBOPEf+NpZ5Ch0OVXCR 1SEfO41HcgY12Cd2ZasSrKDmBLNPPLEyUA/Br+TZK2eRjWbmO0VbW4VElFDPiryB3mOr 2nLg== 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=wtlnunH2yprur8muH+SUwlX3z2UI3HfpRsjd2wOAwPQ=; fh=X+Fedw4hCbMH4Ev0QS2iCi+1HRHPhDeMRzp+H1VGUG0=; b=ujRBO/u47sgt2iEV7u0G1d0+75ZCYZMNnhL6Kd/pY65XbsZY55O9/BwmebtbDIg6cq e/PM2P4tMJ6bzwpF8EZB57NSd4iJdQgx24jmjY/EBRg9xd/M4a0fC3RQIkcGeE9xOkZN +PJbZ1UN8jkIHfScFX2N2jSEMG/6u406l8UASJvbNSZNf2flqpxUB6DrYaxDxwMZn+RQ pQ/MCHOicfOz9AlrKCcLps8s6Is0y4zHgMfjedJNN44dT0HVW772QN8ZC/BxpoVD9m8Q nrywZtC4ybTp1RcoV5r93jWpBV50Lkp7x70QKgZiCV4+N/ntJWjwjnYB8BAnLz2fa0Ik 2lGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MsQnQSKq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id l18-20020a170903245200b001cfb1926572si180616pls.488.2023.11.24.10.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 10:04:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MsQnQSKq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 6A64681F84E7; Fri, 24 Nov 2023 10:04:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231173AbjKXSEO (ORCPT + 99 others); Fri, 24 Nov 2023 13:04:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230104AbjKXSEM (ORCPT ); Fri, 24 Nov 2023 13:04:12 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB9211BC2 for ; Fri, 24 Nov 2023 10:04:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700849057; 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=wtlnunH2yprur8muH+SUwlX3z2UI3HfpRsjd2wOAwPQ=; b=MsQnQSKq5CgOP2vDbw/smi8d1cIiwMAXTB4ZVTrDF/liEMN5YYipiUTW3gP55k5KjROU4s +MZHbZbt6E4iXihvUqHqCYeqEsSXCUjN1ZIY914qBp34Y+mMiCMPSxdHkcvfxYhHlQ6rOB zOuSba5iajFQmQsCqf+3GUndqBOwzek= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-584-UdL2q99BNF2Bn_dflcLYiQ-1; Fri, 24 Nov 2023 13:04:16 -0500 X-MC-Unique: UdL2q99BNF2Bn_dflcLYiQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-332ee20a40fso183249f8f.3 for ; Fri, 24 Nov 2023 10:04:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700849055; x=1701453855; 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=wtlnunH2yprur8muH+SUwlX3z2UI3HfpRsjd2wOAwPQ=; b=Lm16GXaFZsgSmzOBMe7nH9twSMuOkSqOiumjV+9gFQPsc0XQVmFeyUPVi6Tl9YgR36 kWeDu1Y59Y5paGly0dPDZ5rGdls5AqKgOWFB/7NDm39QGf52D+ejGBg8jtmwDumhSERH +xmJPJgatxWDQye8bfZz94uDA6M3tclJC27/B6mnkmO8Km3xkmoie9/WLZYVH+JXwKd3 4miWeE4ZG8qOFZS04leJHkjL7msE34MBBDOyG9kQ78S8pZNXwvvbXAJxBtbn+gCmYoEZ gLoMPuyoIqf1z7kkcleV9dUyoNqJRz7kuUBdYcBggvwmNuPnBmtMnPsnczcB8GQdMbJK w6ng== X-Gm-Message-State: AOJu0YxAMnsD991eLRTzFzLCc4U8gordFl3S5OAvY8FDK3BHgPB4cBQF vaRhblOextJgyQtX4omuvJgSyloXjSWnDe8kf8rkulUEfFJLhqqQ9bI8ihVvMQui4HO+mIz+DSw gq/1U+sesO6S5mcEANuJt2uxk X-Received: by 2002:a5d:4f07:0:b0:32d:bf28:4519 with SMTP id c7-20020a5d4f07000000b0032dbf284519mr2574473wru.38.1700849055191; Fri, 24 Nov 2023 10:04:15 -0800 (PST) X-Received: by 2002:a5d:4f07:0:b0:32d:bf28:4519 with SMTP id c7-20020a5d4f07000000b0032dbf284519mr2574433wru.38.1700849054721; Fri, 24 Nov 2023 10:04:14 -0800 (PST) Received: from ?IPV6:2003:cb:c721:a000:7426:f6b4:82a3:c6ab? (p200300cbc721a0007426f6b482a3c6ab.dip0.t-ipconnect.de. [2003:cb:c721:a000:7426:f6b4:82a3:c6ab]) by smtp.gmail.com with ESMTPSA id m23-20020a056000025700b00332ce0d7300sm4851696wrz.92.2023.11.24.10.04.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Nov 2023 10:04:14 -0800 (PST) Message-ID: <98a8f9b9-79d6-4df1-8625-d6d65fc9b9f2@redhat.com> Date: Fri, 24 Nov 2023 19:04:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/7] mm/memory_hotplug: introduce mhp_flag MHP_OFFLINE_INACCESSIBLE 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: <20231123092343.1703707-1-sumanthk@linux.ibm.com> <20231123092343.1703707-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 ZW5icmFuZCA8ZGF2aWRAcmVkaGF0LmNvbT7CwZgEEw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E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20231123092343.1703707-2-sumanthk@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 24 Nov 2023 10:04:30 -0800 (PST) On 23.11.23 10:23, Sumanth Korikkar wrote: > Introduce MHP_OFFLINE_INACCESSIBLE mhp_flag to mark the hotplugged > memory block as inaccessible during the memory hotplug addition phase. > With support for "memmap on memory", the altmap is prepared at this > stage. Architectures like s390 anticipate that memmap should not be > accessed until memory is physically accessible and is accessible only > when it enters the memory hotplug onlining phase using the memory > notifier. Introduce the flag to inform the memory hotplug > infrastructure that the memory remains inaccessible until the memory > hotplug onlining phase begins. > > Implementation considerations: > mhp inaccessible flag is initially set in altmap. This is useful in > arch_add_memory(). When the memory block device is added, the mhp > inaccessible information is passed to memory_block. The flag is used in > subsequent patch to avoid accessing memmap during memory hotplug > addition phase. > > Signed-off-by: Sumanth Korikkar > --- > drivers/base/memory.c | 2 ++ > include/linux/memory.h | 1 + > include/linux/memory_hotplug.h | 10 ++++++++++ > include/linux/memremap.h | 1 + > mm/memory_hotplug.c | 3 ++- > 5 files changed, 16 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/memory.c b/drivers/base/memory.c > index 8a13babd826c..51915d5c3f88 100644 > --- a/drivers/base/memory.c > +++ b/drivers/base/memory.c > @@ -774,6 +774,8 @@ static int add_memory_block(unsigned long block_id, unsigned long state, > mem->state = state; > mem->nid = NUMA_NO_NODE; > mem->altmap = altmap; > + if (altmap) > + mem->inaccessible = altmap->inaccessible; > INIT_LIST_HEAD(&mem->group_next); > > #ifndef CONFIG_NUMA > diff --git a/include/linux/memory.h b/include/linux/memory.h > index f53cfdaaaa41..655714d4e65a 100644 > --- a/include/linux/memory.h > +++ b/include/linux/memory.h > @@ -67,6 +67,7 @@ struct memory_group { > struct memory_block { > unsigned long start_section_nr; > unsigned long state; /* serialized by the dev->lock */ > + bool inaccessible; /* during memory addition phase */ Is that really required? After all, the altmap is stored in the memory block and accessible there. > int online_type; /* for passing data to online routine */ > int nid; /* NID for this memory block */ > /* > diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h > index 7d2076583494..8988cd5ad55d 100644 > --- a/include/linux/memory_hotplug.h > +++ b/include/linux/memory_hotplug.h > @@ -106,6 +106,16 @@ typedef int __bitwise mhp_t; > * implies the node id (nid). > */ > #define MHP_NID_IS_MGID ((__force mhp_t)BIT(2)) > +/* > + * Mark the hotplugged memory block as inaccessible during the memory hotplug > + * addition phase. With support for "memmap on memory," the altmap is prepared > + * at this stage. Architectures like s390 anticipate that memmap should not be > + * accessed until memory is physically accessible and is accessible only when > + * it enters the memory hotplug onlining phase using the memory notifier. > + * Utilize this flag to inform the memory hotplug infrastructure that the > + * memory remains inaccessible until the memory hotplug onlining phase begins. > + */ > +#define MHP_OFFLINE_INACCESSIBLE ((__force mhp_t)BIT(3)) I'd suggest to squash all 3 patches. Then we can properly document here: /* * The hotplugged memory is completely inaccessible while the memory is * offline. The memory provider will handle MEM_PREPARE_ONLINE / * MEM_FINISH_OFFLINE notifications and make the memory accessible. * * This flag is only 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 available, and * the onlining phase will not require any memory allocations, which is * helpful in low-memory situations. */ Cheers, David / dhildenb