Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5855328rdb; Thu, 14 Dec 2023 01:11:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZaNzMFpR5XdcVfQvPUySIlOl3pxqHOfn9HOkE2nvdKC12b4ulS6fRWdN0zEwy6ACVsrRx X-Received: by 2002:a05:6871:5209:b0:203:37c3:77ff with SMTP id ht9-20020a056871520900b0020337c377ffmr1853732oac.49.1702545070407; Thu, 14 Dec 2023 01:11:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702545070; cv=none; d=google.com; s=arc-20160816; b=Ea92jZzPS3OtRcf3gw2ApnG8qPdAhIomgsu3NlekDCtkxYzV9vfSA4Hw3I7SkRew6s n4GnpbcMJxIh7sZICtx8y7WPSomWXGbR+NtaUbYr3CLGcKk9zLPBJ19hS8/UoFw3dqV9 /zEMtXf0iL3pGhie6GAQ6+6xrJQhvJkqGmslAmBWGYb9XplqdQGz3oBrIwhMpjHbLL/K Y7a/DheJa0E+y7m/QE5O+AcKSgaJ8Lt21eSl82sSKbT41SmwXs9BXlWyMPTdhWGsvCCL CQulu+6HAhohEx/B20BxUY3ExX8r+Ay74JqaExf5bgtWwncXV/uhD4jLJ1cHWMxFZZnP CY5w== 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=VKHE7jI2ItzkPojzmqif9xZF1gx8hMjEdVxpLC4Oaqc=; fh=JxTPXwiv72nXMXC5M7R02Cgg7804UkRgYqJYP9f9OiI=; b=TreQgnQaXWm4tyuEfdcJJuT8hgQlkils9IaXh+BAiGqeC32bMiG0zgAwDBO2TPPXBj Qk3B0vNpX7fl7dFxftesB4dwMXv/s2iSUcFBz8UXoT3X1ogfv8s6YexKXNPWw+nfOZcE 2yWeuuYzRDOOcka3TF8CBbbKmcH573LKENP4sdGAmVCHfQ6FR7fW0AvAk+M7gDivXnMc ri1nxBVNEvLQ6yZzudZa1zBJRF2+XoPb50SUodTUabGYOnTv1f319t75go332+KFaqPb 7oBaNrhWtFQfY6YNZiAlQ/2WOwAQpjTXvSw4G/RQP2H6HMaMPtCdx/tw9w49eegaGDUc Owig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QHHX+q3v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id o2-20020a655202000000b005c65dc887dbsi10515118pgp.557.2023.12.14.01.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 01:11:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QHHX+q3v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 51A84801B641; Thu, 14 Dec 2023 01:11:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229633AbjLNJKr (ORCPT + 99 others); Thu, 14 Dec 2023 04:10:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235557AbjLNJKm (ORCPT ); Thu, 14 Dec 2023 04:10:42 -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 92A26A6 for ; Thu, 14 Dec 2023 01:10:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702545047; 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=VKHE7jI2ItzkPojzmqif9xZF1gx8hMjEdVxpLC4Oaqc=; b=QHHX+q3vD1W3xuVSONyNieqSQVizo4q3KtUL4bIZ7aIfAx+rW0PYk5Vs5Gmd8zF0qz+JSE sTG+ScnB4iCmhl8bX2WBCbJ4pU/HCyw1ViJ9PwpThwrehLyyEKnY5EIX+obsRhR/PyFonS CPXvivca85E3WDPTeKdG9E40DLCz44w= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-340-9cR9u2-GP8ax_zBPAIXY4A-1; Thu, 14 Dec 2023 04:10:46 -0500 X-MC-Unique: 9cR9u2-GP8ax_zBPAIXY4A-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-40c4a824c4bso26912855e9.2 for ; Thu, 14 Dec 2023 01:10:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702545045; x=1703149845; 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=VKHE7jI2ItzkPojzmqif9xZF1gx8hMjEdVxpLC4Oaqc=; b=oriS+paASRlO+hDfSji4eJK1CgbPd0KZILAKFrFoqY+YwCdU70mg16WBHf6YzOe2d8 tvQcWqExdlDw/JSzTQ870VIYmD9EMNEVttelRv4fgBRGC78q5pHB79HZcOjZ1+Z6YVG1 sBzo/gQj4GsMsTb0w4JQjeTJQZfJhzzBjGAdThOsy2GYHDVVhAyrDwIgBInGiaCTbYRB BLCXu3PcU+NwiCbrd53JIa2NcAccPScjIZnOFkEOi8OoqBEuTCbYKsHh1ZnRdu8JGG+l 9sEZBGPLmxKH1Xt2fWc97L9Wzwc1xmqoSSvOi+0o46GMYYoy7otJypp+sPNyVTuXfw/p abwQ== X-Gm-Message-State: AOJu0YxXQcoD2F5rSvUPi8S/YLsH86LC+marEnCqkiD4VnI70269i0hn 5kwwLFVM7SBeWum3MlgnCpvfCfB1ms5hxhh9bCITKKF/7C7p3Z+yVdfMeBZSgtbOurpZKIz8QXY eMYyCIhMgPU/+n+A9ge4p4OOc X-Received: by 2002:a05:600c:6907:b0:40b:5e21:cc27 with SMTP id fo7-20020a05600c690700b0040b5e21cc27mr4290519wmb.82.1702545045149; Thu, 14 Dec 2023 01:10:45 -0800 (PST) X-Received: by 2002:a05:600c:6907:b0:40b:5e21:cc27 with SMTP id fo7-20020a05600c690700b0040b5e21cc27mr4290513wmb.82.1702545044656; Thu, 14 Dec 2023 01:10:44 -0800 (PST) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id j25-20020a05600c1c1900b004076f522058sm26234485wms.0.2023.12.14.01.10.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Dec 2023 01:10:44 -0800 (PST) Message-ID: Date: Thu, 14 Dec 2023 10:10:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 3/4] mm/memory_hotplug: export mhp_supports_memmap_on_memory() Content-Language: en-US To: Vishal Verma , Dan Williams , Dave Jiang , Andrew Morton , Oscar Salvador Cc: linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, Dave Hansen , Huang Ying , Greg Kroah-Hartman , linux-mm@kvack.org, Michal Hocko References: <20231214-vv-dax_abi-v5-0-3f7b006960b4@intel.com> <20231214-vv-dax_abi-v5-3-3f7b006960b4@intel.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 ZW5icmFuZCA8ZGF2aWRAcmVkaGF0LmNvbT7CwZgEEwEIAEICGwMGCwkIBwMCBhUIAgkKCwQW AgMBAh4B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w+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20231214-vv-dax_abi-v5-3-3f7b006960b4@intel.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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 14 Dec 2023 01:11:07 -0800 (PST) On 14.12.23 08:37, Vishal Verma wrote: > In preparation for adding sysfs ABI to toggle memmap_on_memory semantics > for drivers adding memory, export the mhp_supports_memmap_on_memory() > helper. This allows drivers to check if memmap_on_memory support is > available before trying to request it, and display an appropriate > message if it isn't available. As part of this, remove the size argument > to this - with recent updates to allow memmap_on_memory for larger > ranges, and the internal splitting of altmaps into respective memory > blocks, the size argument is meaningless. > > Cc: Andrew Morton > Cc: David Hildenbrand > Cc: Michal Hocko > Cc: Oscar Salvador > Cc: Dan Williams > Cc: Dave Jiang > Cc: Dave Hansen > Cc: Huang Ying > Suggested-by: David Hildenbrand > Signed-off-by: Vishal Verma > --- > include/linux/memory_hotplug.h | 6 ++++++ > mm/memory_hotplug.c | 17 ++++++----------- > 2 files changed, 12 insertions(+), 11 deletions(-) > > diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h > index 7d2076583494..ebc9d528f00c 100644 > --- a/include/linux/memory_hotplug.h > +++ b/include/linux/memory_hotplug.h > @@ -121,6 +121,7 @@ struct mhp_params { > > bool mhp_range_allowed(u64 start, u64 size, bool need_mapping); > struct range mhp_get_pluggable_range(bool need_mapping); > +bool mhp_supports_memmap_on_memory(void); > > /* > * Zone resizing functions > @@ -262,6 +263,11 @@ static inline bool movable_node_is_enabled(void) > return false; > } > > +static bool mhp_supports_memmap_on_memory(void) > +{ > + return false; > +} > + > static inline void pgdat_kswapd_lock(pg_data_t *pgdat) {} > static inline void pgdat_kswapd_unlock(pg_data_t *pgdat) {} > static inline void pgdat_kswapd_lock_init(pg_data_t *pgdat) {} > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 926e1cfb10e9..751664c519f7 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1325,7 +1325,7 @@ static inline bool arch_supports_memmap_on_memory(unsigned long vmemmap_size) > } > #endif > > -static bool mhp_supports_memmap_on_memory(unsigned long size) > +bool mhp_supports_memmap_on_memory(void) > { > unsigned long vmemmap_size = memory_block_memmap_size(); > unsigned long memmap_pages = memory_block_memmap_on_memory_pages(); > @@ -1334,17 +1334,11 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) > * Besides having arch support and the feature enabled at runtime, we > * need a few more assumptions to hold true: > * > - * a) We span a single memory block: memory onlining/offlinin;g happens > - * in memory block granularity. We don't want the vmemmap of online > - * memory blocks to reside on offline memory blocks. In the future, > - * we might want to support variable-sized memory blocks to make the > - * feature more versatile. > - * > - * b) The vmemmap pages span complete PMDs: We don't want vmemmap code > + * a) The vmemmap pages span complete PMDs: We don't want vmemmap code > * to populate memory from the altmap for unrelated parts (i.e., > * other memory blocks) > * > - * c) The vmemmap pages (and thereby the pages that will be exposed to > + * b) The vmemmap pages (and thereby the pages that will be exposed to > * the buddy) have to cover full pageblocks: memory onlining/offlining > * code requires applicable ranges to be page-aligned, for example, to > * set the migratetypes properly. > @@ -1356,7 +1350,7 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) > * altmap as an alternative source of memory, and we do not exactly > * populate a single PMD. > */ > - if (!mhp_memmap_on_memory() || size != memory_block_size_bytes()) > + if (!mhp_memmap_on_memory()) > return false; > > /* > @@ -1379,6 +1373,7 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) > > return arch_supports_memmap_on_memory(vmemmap_size); > } > +EXPORT_SYMBOL_GPL(mhp_supports_memmap_on_memory); > > static void __ref remove_memory_blocks_and_altmaps(u64 start, u64 size) > { > @@ -1512,7 +1507,7 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) > * Self hosted memmap array > */ > if ((mhp_flags & MHP_MEMMAP_ON_MEMORY) && > - mhp_supports_memmap_on_memory(memory_block_size_bytes())) { > + mhp_supports_memmap_on_memory()) { > ret = create_altmaps_and_memory_blocks(nid, group, start, size); > if (ret) > goto error; > Acked-by: David Hildenbrand -- Cheers, David / dhildenb