From patchwork Fri Jul 31 09:18:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11694525 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C70A138C for ; Fri, 31 Jul 2020 09:19:34 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 46E7721883 for ; Fri, 31 Jul 2020 09:19:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YRAc7jZA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46E7721883 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1RBp-0000Vs-Kt; Fri, 31 Jul 2020 09:18:57 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1RBn-0000Vm-BI for xen-devel@lists.xenproject.org; Fri, 31 Jul 2020 09:18:56 +0000 X-Inumbo-ID: dadd789c-d30e-11ea-8e1f-bc764e2007e4 Received: from us-smtp-1.mimecast.com (unknown [205.139.110.61]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id dadd789c-d30e-11ea-8e1f-bc764e2007e4; Fri, 31 Jul 2020 09:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596187134; 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; bh=7KJjJxh3LrCrOmiVZX7zoQLv4kMydPtkCS0ZPjF2DUk=; b=YRAc7jZAndJHzfvcACv97DJeo2rFUQwS1c0JV3aHgHUCRN2D5quQzwXbCozUdHxOAaYAC3 dYjRg3RCvTGoc6TRnYfFbu2eCD1Nei29sdWTuG535vgOHmL5fdT8Jq7AbrUgfDu8+c5RSd LX1BIHXcLj0pV2cTdjX9IuuWKcydwTE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-70-SolxhgZkNXO5E6nSxUQ3oA-1; Fri, 31 Jul 2020 05:18:49 -0400 X-MC-Unique: SolxhgZkNXO5E6nSxUQ3oA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07FF759; Fri, 31 Jul 2020 09:18:47 +0000 (UTC) Received: from t480s.redhat.com (ovpn-113-22.ams2.redhat.com [10.36.113.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC0631A835; Fri, 31 Jul 2020 09:18:39 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Subject: [PATCH RFCv1 0/5] mm/memory_hotplug: selective merging of memory resources Date: Fri, 31 Jul 2020 11:18:33 +0200 Message-Id: <20200731091838.7490-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: linux-hyperv@vger.kernel.org, Michal Hocko , David Hildenbrand , virtualization@lists.linux-foundation.org, linux-mm@kvack.org, "K. Y. Srinivasan" , Dan Williams , Wei Liu , Stefano Stabellini , Stephen Hemminger , Ard Biesheuvel , Jason Gunthorpe , xen-devel@lists.xenproject.org, Julien Grall , Kees Cook , Haiyang Zhang , Boris Ostrovsky , Juergen Gross , Thomas Gleixner , Wei Yang , Andrew Morton , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Some add_memory*() users add memory in small, contiguous memory blocks. Examples include virtio-mem, hyper-v balloon, and the XEN balloon. This can quickly result in a lot of memory resources, whereby the actual resource boundaries are not of interest (e.g., it might be relevant for DIMMs, exposed via /proc/iomem to user space). We really want to merge added resources in this scenario where possible. Resources are effectively stored in a list-based tree. Having a lot of resources not only wastes memory, it also makes traversing that tree more expensive, and makes /proc/iomem explode in size (e.g., requiring kexec-tools to manually merge resources when creating a kdump header. The current kexec-tools resource count limit does not allow more than ~100GB of memory with a memory block size of 128MB on x86-64). Let's allow to selectively merge resources, speciyfing a parent node and a resource idendifier string. The memory unplug path will properly split up merged resources again. Patch #3 contains a /proc/iomem example. Only tested with virtio-mem. Note: This gets the job done and is comparably simple. More complicated approaches would require introducing IORESOURCE_MERGEABLE and extending our add_memory*() interfaces with a flag, specifying that merging after adding succeeded is acceptable. I'd like to avoid that complexity and code churn for now. David Hildenbrand (5): kernel/resource: make release_mem_region_adjustable() never fail kernel/resource: merge_child_mem_resources() to merge memory resources after adding succeeded virtio-mem: try to merge "System RAM (virtio_mem)" resources xen/balloon: try to merge "System RAM" resources hv_balloon:: try to merge "System RAM" resources drivers/hv/hv_balloon.c | 3 ++ drivers/virtio/virtio_mem.c | 14 ++++- drivers/xen/balloon.c | 4 ++ include/linux/ioport.h | 7 ++- kernel/resource.c | 105 ++++++++++++++++++++++++++++-------- mm/memory_hotplug.c | 22 +------- 6 files changed, 109 insertions(+), 46 deletions(-)