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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00022C4338F for ; Sat, 7 Aug 2021 19:13:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6CAA60551 for ; Sat, 7 Aug 2021 19:13:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229624AbhHGTNt (ORCPT ); Sat, 7 Aug 2021 15:13:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:39824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbhHGTNt (ORCPT ); Sat, 7 Aug 2021 15:13:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 89D766103B; Sat, 7 Aug 2021 19:13:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1628363612; bh=p8xBYLN6Lxc2cXthPNWIdKvoh2cUp06lUgJBadLmuMQ=; h=Date:From:To:Subject:From; b=KcUzi8xzTxlgRjN4X35RbVkW4DmVOiQcb7gp7ylyu5yelqihR3V1YCatLqy71Sdex 0cF2oqd9A3MLBwaoX3DOzQxWzwSO4kCKkW8PWFHKBUmg2UJqgSAXPXO6tb3iB6dhzP R4HDkFeMOh883vOh+RZYykwjbYoCYZPaHdwy6CJM= Date: Sat, 07 Aug 2021 12:13:31 -0700 From: akpm@linux-foundation.org To: mm-commits@vger.kernel.org, vkuznets@redhat.com, vbabka@suse.cz, teawater@gmail.com, rppt@kernel.org, rjw@rjwysocki.net, richard.weiyang@linux.alibaba.com, rafael.j.wysocki@intel.com, pasha.tatashin@soleen.com, pankaj.gupta.linux@gmail.com, osalvador@suse.de, mst@redhat.com, mkedzier@redhat.com, mhocko@kernel.org, lenb@kernel.org, jasowang@redhat.com, gregkh@linuxfoundation.org, dave.hansen@linux.intel.com, dan.j.williams@intel.com, anshuman.khandual@arm.com, david@redhat.com Subject: [to-be-updated] =?us-ascii?Q?acpi-memhotplug-use-a-single-static-memory-group-for-a-si?= =?us-ascii?Q?ngle-memory-device.patch?= removed from -mm tree Message-ID: <20210807191331.xCcxA%akpm@linux-foundation.org> User-Agent: s-nail v14.9.10 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: ACPI: memhotplug: use a single static memory group for a single memory device has been removed from the -mm tree. Its filename was acpi-memhotplug-use-a-single-static-memory-group-for-a-single-memory-device.patch This patch was dropped because an updated version will be merged ------------------------------------------------------ From: David Hildenbrand Subject: ACPI: memhotplug: use a single static memory group for a single memory device Let's group all memory we add for a single memory device - we want a single node for that (which also seems to be the sane thing to do). We won't care for now about memory that was already added to the system (e.g., via e820) -- usually *all* memory of a memory device was already added and we'll fail acpi_memory_enable_device(). Link: https://lkml.kernel.org/r/20210723125210.29987-6-david@redhat.com Signed-off-by: David Hildenbrand Acked-by: Rafael J. Wysocki Cc: Anshuman Khandual Cc: Dan Williams Cc: Dave Hansen Cc: Greg Kroah-Hartman Cc: Hui Zhu Cc: Jason Wang Cc: Len Brown Cc: Marek Kedzierski Cc: "Michael S. Tsirkin" Cc: Michal Hocko Cc: Mike Rapoport Cc: Oscar Salvador Cc: Pankaj Gupta Cc: Pavel Tatashin Cc: "Rafael J. Wysocki" Cc: Vitaly Kuznetsov Cc: Vlastimil Babka Cc: Wei Yang Signed-off-by: Andrew Morton --- drivers/acpi/acpi_memhotplug.c | 35 ++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) --- a/drivers/acpi/acpi_memhotplug.c~acpi-memhotplug-use-a-single-static-memory-group-for-a-single-memory-device +++ a/drivers/acpi/acpi_memhotplug.c @@ -54,6 +54,7 @@ struct acpi_memory_info { struct acpi_memory_device { struct acpi_device *device; struct list_head res_list; + int mgid; }; static acpi_status @@ -169,12 +170,33 @@ static void acpi_unbind_memory_blocks(st static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) { acpi_handle handle = mem_device->device->handle; + mhp_t mhp_flags = MHP_NID_IS_MGID; int result, num_enabled = 0; struct acpi_memory_info *info; - mhp_t mhp_flags = MHP_NONE; - int node; + u64 total_length = 0; + int node, mgid; node = acpi_get_node(handle); + + list_for_each_entry(info, &mem_device->res_list, list) { + if (!info->length) + continue; + /* We want a single node for the whole memory group */ + if (node < 0) + node = memory_add_physaddr_to_nid(info->start_addr); + total_length += info->length; + } + + if (!total_length) { + dev_err(&mem_device->device->dev, "device is empty\n"); + return -EINVAL; + } + + mgid = register_static_memory_group(node, PFN_UP(total_length)); + if (mgid < 0) + return mgid; + mem_device->mgid = mgid; + /* * Tell the VM there is more memory here... * Note: Assume that this function returns zero on success @@ -188,12 +210,10 @@ static int acpi_memory_enable_device(str */ if (!info->length) continue; - if (node < 0) - node = memory_add_physaddr_to_nid(info->start_addr); if (mhp_supports_memmap_on_memory(info->length)) mhp_flags |= MHP_MEMMAP_ON_MEMORY; - result = __add_memory(node, info->start_addr, info->length, + result = __add_memory(mgid, info->start_addr, info->length, mhp_flags); /* @@ -253,6 +273,10 @@ static void acpi_memory_device_free(stru if (!mem_device) return; + /* In case we succeeded adding *some* memory, unregistering fails. */ + if (mem_device->mgid >= 0) + unregister_memory_group(mem_device->mgid); + acpi_memory_free_device_resources(mem_device); mem_device->device->driver_data = NULL; kfree(mem_device); @@ -273,6 +297,7 @@ static int acpi_memory_device_add(struct INIT_LIST_HEAD(&mem_device->res_list); mem_device->device = device; + mem_device->mgid = -1; sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME); sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS); device->driver_data = mem_device; _ Patches currently in -mm which might be from david@redhat.com are mm-madvise-report-sigbus-as-efault-for-madv_populate_readwrite.patch memory-hotplugrst-remove-locking-details-from-admin-guide.patch memory-hotplugrst-complete-admin-guide-overhaul.patch mm-memory_hotplug-use-unsigned-long-for-pfn-in-zone_for_pfn_range.patch mm-memory_hotplug-remove-nid-parameter-from-arch_remove_memory.patch mm-memory_hotplug-remove-nid-parameter-from-remove_memory-and-friends.patch acpi-memhotplug-memory-resources-cannot-be-enabled-yet.patch dax-kmem-use-a-single-static-memory-group-for-a-single-probed-unit.patch virtio-mem-use-a-single-dynamic-memory-group-for-a-single-virtio-mem-device.patch mm-memory_hotplug-memory-group-aware-auto-movable-online-policy.patch mm-memory_hotplug-memory-group-aware-auto-movable-online-policy-fix.patch mm-memory_hotplug-improved-dynamic-memory-group-aware-auto-movable-online-policy.patch