From patchwork Thu Jul 20 07:14:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 13319891 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D4E8EB64DD for ; Thu, 20 Jul 2023 07:14:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B4A02800C4; Thu, 20 Jul 2023 03:14:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9650A28004C; Thu, 20 Jul 2023 03:14:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82BE92800C4; Thu, 20 Jul 2023 03:14:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 734DD28004C for ; Thu, 20 Jul 2023 03:14:34 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 469D31C8243 for ; Thu, 20 Jul 2023 07:14:34 +0000 (UTC) X-FDA: 81031127268.27.BAD41DF Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf06.hostedemail.com (Postfix) with ESMTP id A4618180005 for ; Thu, 20 Jul 2023 07:14:31 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="bTx8w/XO"; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf06.hostedemail.com: domain of vishal.l.verma@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689837272; h=from:from:sender: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: references:dkim-signature; bh=msNgdh5DR0viNVeGMAm+vaNgf6ss6rUvHQ06M2jlsB8=; b=dbnds03MpFk+Z1QRfZxxAD3q1MGs8MEQkk9xGLEJDc6kN2fF9Fr4mHSTXRvqc4BuPcIhcK alvnffpCWK6eXdsQDb2EJbVUhG+5JC//sLc+subGT4F0q7zt31dPDnlE9EP+mI+9LCR6Q6 s54es/sDGp25O4cougss5m3lwfTmcIE= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="bTx8w/XO"; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf06.hostedemail.com: domain of vishal.l.verma@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689837272; a=rsa-sha256; cv=none; b=Iu+SLwX8Ti2+LrFO8BhfOKSyGOZiHD0atCgdkwsQZVGTjIFWeIFEakWraxXJhr//KudTe2 80vorKzCWBEXIAf1nC4sqxjo5DSsb9mYuQeHa7l61wMLKskJPijvHvCohCP8qQ2sHPFgql CdGUsFY/y9S6rLxEmVm2d/ARiqcq02U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689837271; x=1721373271; h=from:subject:date:message-id:mime-version: content-transfer-encoding:to:cc; bh=go6W94T7bVzWJfRcg0tjdLa7TppzyTeQot8p3HsrXWc=; b=bTx8w/XOP0Ca9t4i1GN+rD2mCiXA7JBtG/E4m1DWLW3edapOqDBX/UHE EJ3bXwVfw4f71aqw9L9Aw+ouzg8fHbKoi5mhTBe2g8rkdOB9bl0FPNZqb 7IlQxHvSZFTaBS+tYJjBWwsOhve+TgqXRut9BEPHMpCe0nZN4S7/Q3//l FjcR3PLuwOT0qrRmn//iU0O2CXUV3jMDEwS9hSDUYU6/MjUf+gLTivT/u K9yWlW77ndSDa3qglabWfghrWUDqhMS6ak63fPNWsTb09UBGCkJKNGsOA QTCRv9fJ/pK/SJQrG/dygM2I7eiFarsKJqp+H+pVaj2pb6O1WU3CE7kQq g==; X-IronPort-AV: E=McAfee;i="6600,9927,10776"; a="430423989" X-IronPort-AV: E=Sophos;i="6.01,218,1684825200"; d="scan'208";a="430423989" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2023 00:14:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10776"; a="794334960" X-IronPort-AV: E=Sophos;i="6.01,218,1684825200"; d="scan'208";a="794334960" Received: from mfgalan-mobl1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.213.172.204]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2023 00:14:28 -0700 From: Vishal Verma Subject: [PATCH v2 0/3] mm: use memmap_on_memory semantics for dax/kmem Date: Thu, 20 Jul 2023 01:14:21 -0600 Message-Id: <20230720-vv-kmem_memmap-v2-0-88bdaab34993@intel.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAM7euGQC/3WNwQ6CMBBEf4Xs2ZpSsIIn/8MQU8oiG2khLTYaw r+7cvcwhzfJm1khYiCMcMlWCJgo0uQZ1CEDOxj/QEEdMyipCqnzQqQkng7dnePMLE5lVdiqk6U 618BSayKKNhhvB9b8axy5nAP29N5fbg3zQHGZwmc/Tfmv/bufciFFrzusrTa9svpKfsHxaCcHz bZtX2Tn8LzBAAAA To: Andrew Morton , David Hildenbrand , Oscar Salvador , Dan Williams , Dave Jiang Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, Huang Ying , Dave Hansen , "Aneesh Kumar K.V" , Jonathan Cameron , Jeff Moyer , Vishal Verma X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2452; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=go6W94T7bVzWJfRcg0tjdLa7TppzyTeQot8p3HsrXWc=; b=owGbwMvMwCXGf25diOft7jLG02pJDCk77l34kVP6oD5yqjbXvvifH26/OLhsMWeb0oL4vJKSl zMZ/NYJd5SyMIhxMciKKbL83fOR8Zjc9nyewARHmDmsTCBDGLg4BWAiB6wZGRp7DLqke8W52T+n XDx9O8D2iChXRfDU/jLl/+cUlXs3ejMyfOvz/PbKueVXrYKZy2/rNo1bT0vW/5t6PPVEiGvSPyE JBgA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A4618180005 X-Stat-Signature: s5eu45pe6g4wxne1gguk3rpo18y45czb X-Rspam-User: X-HE-Tag: 1689837271-11044 X-HE-Meta: U2FsdGVkX1/p0vBYQDlyby3p5N5024ReAHV0tKchdkBwqWHkFuzlq/Z+UoYcWecPPt74iIMqqKKWyduklLB3btLx4RKio+i9TE2tdD9b2GDH/HoZeeSpoXv4btZB0E7HG/TQTE33yW3GmidFFNAkzUcaDdpE1w/P3lrk3rvTzviuSkUSFZjnjQtm8KBUdoL7c4rbSVYsVVZ8lBqHK8T9rpauRDGDwDCu8WZ33/PxQUj4wcKC1it9I9DDWnBxH4CHvK70dV9S4lWpp3Y10Zw8yxaE0g4yZVm3G0y7ghIKCYolSb6RyC9DetloViZz+q6TSnkoHzB6UpUcb5/C5FGhnXQPED453dITYNJ6nfkiqr5KWaM1NCzDke7/Gdtlu8esCvNArcKKcbBefuC8b2BPRk0V4kVO/ngnHOPHUTzysdJygI2T+aViZM//AoJ5cEa+hT943MoLhc+lWLovgIfj/XzK+P8rsLSN22nLh5hXuP/XYD4gUWZE95U3Jdk+oxWkAciXxco68y8HyUNbAJfyHp2J+OzzlfF2Dh3Lx0IxLlRnjPkWRf4RE1MfPBRAFFYyi7/QuR8dWtf36OrutQejzkFt3jb7df4Cbt8gUyt8xBwJfjakpYJ+buGTsXZryHZL/QHwMdJRH+nkjwk4YMMpBJhQVwIs4kWMLt4p3/KKFLCgKw8BYBVJX02kISo/bxia/VGNHtn4un5L/MQlNZ+r2k+JQiFtXlrcto7yZRoJOIY5zwsNWBzL5QEvCFk2blFoHDeokQPFKt0LeLAlJ3H0dUoOLftLQPzEfYp7XoG/UtSjWtljUrV51CA5GSHec40ajpE+uvp2BasBJRV3Hn8B77MmNORsHGJCw9HqU3j9r4Z69Pzgr3gwXML5p95ImTXe9IWxLQBzfxd7mv2DiomBDubm0ypYoWEPeV4cej1/414D1ByEE/Dqq9+PCRkHe72F+pI1Hxqwllq40yTPrNL HtEylTJv +4XGENFD2TpClVBxXpC1fpg51rAdwqMUUBdZy69mKRLLznwOCl7bKgzXF6LRZQUhme3mp29BRtkZfRBvRRKk/5pU+RMI+bix1II9xBQ/SArgB0UJgl8WVubvA71KG4uTeHK+NPDfNJrcMKzBSjOvZUbYTHB0Gu36p1TaoXEshpVBLN5gzr/+VUWV2dKy0wPJQRNn1a7lOxMfDoxT4WCPdqxElBNxfH4tuHl0hSy0OEKFQB96J0BrrCWJAGByYpkcFImAbp2OEa8jUmnvgIbfrK84dXw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The dax/kmem driver can potentially hot-add large amounts of memory originating from CXL memory expanders, or NVDIMMs, or other 'device memories'. There is a chance there isn't enough regular system memory available to fit the memmap for this new memory. It's therefore desirable, if all other conditions are met, for the kmem managed memory to place its memmap on the newly added memory itself. The main hurdle for accomplishing this for kmem is that memmap_on_memory can only be done if the memory being added is equal to the size of one memblock. To overcome this,allow the hotplug code to split an add_memory() request into memblock-sized chunks, and try_remove_memory() to also expect and handle such a scenario. Patch 1 exports mhp_supports_memmap_on_memory() so it can be used by the kmem driver. Patch 2 teaches the memory_hotplug code to allow for splitting add_memory() and remove_memory() requests over memblock sized chunks. Patch 3 adds a sysfs control for the kmem driver that would allow an opt-out of using memmap_on_memory for the memory being added. Signed-off-by: Vishal Verma --- Changes in v2: - Drop the patch to create an override path for the memmap_on_memory module param (David) - Move the chunking into memory_hotplug.c so that any caller of add_memory() can request this behavior. (David) - Handle remove_memory() too. (David, Ying) - Add a sysfs control in the kmem driver for memmap_on_memory semantics (David, Jonathan) - Add a #else case to define mhp_supports_memmap_on_memory() if CONFIG_MEMORY_HOTPLUG is unset. (0day report) - Link to v1: https://lore.kernel.org/r/20230613-vv-kmem_memmap-v1-0-f6de9c6af2c6@intel.com --- Vishal Verma (3): mm/memory_hotplug: Export symbol mhp_supports_memmap_on_memory() mm/memory_hotplug: split memmap_on_memory requests across memblocks dax/kmem: allow kmem to add memory with memmap_on_memory include/linux/memory_hotplug.h | 5 ++ drivers/dax/dax-private.h | 1 + drivers/dax/bus.c | 48 +++++++++++++ drivers/dax/kmem.c | 7 +- mm/memory_hotplug.c | 155 ++++++++++++++++++++++++----------------- 5 files changed, 152 insertions(+), 64 deletions(-) --- base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5 change-id: 20230613-vv-kmem_memmap-5483c8d04279 Best regards,