From patchwork Thu Sep 28 20:30:09 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: 13403512 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 955E6E743C0 for ; Thu, 28 Sep 2023 20:30:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 237158D00DC; Thu, 28 Sep 2023 16:30:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E6B48D0053; Thu, 28 Sep 2023 16:30:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0AFE88D00DC; Thu, 28 Sep 2023 16:30:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id F15028D0053 for ; Thu, 28 Sep 2023 16:30:55 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B47DB80F13 for ; Thu, 28 Sep 2023 20:30:55 +0000 (UTC) X-FDA: 81287150070.29.EF9FD77 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by imf01.hostedemail.com (Postfix) with ESMTP id 404D840010 for ; Thu, 28 Sep 2023 20:30:51 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=jdlZp4KD; spf=pass (imf01.hostedemail.com: domain of vishal.l.verma@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695933053; 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=URFJSCzHqGjld6XzhBENM6XjTnSoWNgLaIEhDPhsTpM=; b=fY7kgMHwIv+s1eT9WbXJnq6zmjBvflBYgSVeit5SxtKrMQQnV4Ua+XOF7NREJHY6AwJtwi iBtcd5+mAyPUGvvu04Vo/4+3P8G6N0NcBqqCHez8uwqVoO/0ycU41yWpnRN2RW0E/bSygy wCSSoYaRy553o/E2Ce/tAYXtWZFvW4s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695933053; a=rsa-sha256; cv=none; b=Gka5XeG6Q1AVZSv6QSDsfS3UFamjX6oinoTfJYW+ltpjHmNmveA/LQY8cCyHcJBnZyD83q 7EC/wq9LxgZG6CQlaLrKSFoQd7KAqXGbd50xuKnqq2ckXwASXg7RQUg39X2/azupAXvlsB mjxPu7QRQ0+jULMbYM+977pRWghCamU= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=jdlZp4KD; spf=pass (imf01.hostedemail.com: domain of vishal.l.verma@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695933052; x=1727469052; h=from:subject:date:message-id:mime-version: content-transfer-encoding:to:cc; bh=cAy0mCyyU34BrYjzihAk6QBEdSFRsmrEsY5ivGjaggs=; b=jdlZp4KDorHnbKkdfpcqGLB8npvP+epPQHS2DH0NYmp4wor00XAQJZqm npZlpiILkJ2+gKiA5bHVITCzf/3FO7svl7ZdBqLr6jQpQdNc+rlv+bkKq EQ8BsJlHUJKiThU89ajp229kacBL8TY96gQxckclY0USgwE8ZQUFaEdBO H7ue87jak3/NGlteRI/jodsVP6Mm5OvQfQEocrhsUi6EPsIcF+mfAUrJF mq9LTLq+0O9IlTSeaF42Le0p8e6NOW3NlXSUjnrImMFK3e2FU1n2OkcD7 /qp+ZizMEUA3X6objbrvfVT1V0WBvZbYXjemjolXkHszGJvYGhNp89eVH A==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="367229663" X-IronPort-AV: E=Sophos;i="6.03,185,1694761200"; d="scan'208";a="367229663" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2023 13:30:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="815374351" X-IronPort-AV: E=Sophos;i="6.03,185,1694761200"; d="scan'208";a="815374351" Received: from bdsebast-mobl1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.125.211]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2023 13:30:30 -0700 From: Vishal Verma Subject: [PATCH v4 0/2] mm: use memmap_on_memory semantics for dax/kmem Date: Thu, 28 Sep 2023 14:30:09 -0600 Message-Id: <20230928-vv-kmem_memmap-v4-0-6ff73fec519a@intel.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAFHiFWUC/3XNQQ7CIBAF0KsY1mIoIIIr72GMmdKpJbbUgBKN6 d0d3Wg0Lmbxf/L+3FnGFDCz9ezOEpaQwxgp6PmM+Q7iAXloKDMppBKmUrwUfhxw2NMNcOJLbZW 3jdBy5RihGjLyOkH0HbF46XsqTwnbcH192e4odyGfx3R7PS3Vs/27XyoueGsadN5AK73ZhHjGf uHHgT2ninzzlRQ/XBK3tm4AaqWdU99cvbkV1Q9XxLUw6ADapbHuk0/T9ACKqImFPwEAAA== 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" , Michal Hocko , Jonathan Cameron , Jeff Moyer , Vishal Verma , Jonathan Cameron X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3152; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=cAy0mCyyU34BrYjzihAk6QBEdSFRsmrEsY5ivGjaggs=; b=owGbwMvMwCXGf25diOft7jLG02pJDKmij4Itwm6bPF8XxpAX828Kx6+++ga1a8WXpk/iy1n0q 9o+Vd+po5SFQYyLQVZMkeXvno+Mx+S25/MEJjjCzGFlAhnCwMUpABOpamFk2HH85zqnqsfuZSuE s9LX79q9c3Vz0pKJW9756Ng/MWt568LI8C+Uf5KPdvLpIs+jV226St8k1mfPY7Ker2L8XCI48fN xDgA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Stat-Signature: 4gxw394ij1fptr6m7xf5uij36d4ac8jd X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 404D840010 X-Rspam-User: X-HE-Tag: 1695933051-944983 X-HE-Meta: U2FsdGVkX19hsdkcNkM+iIhD06xN+FOhuthdmfdx/eo8016Xe9yps90yEm8A8EeGQz78PuYmMMF6fNco8lXVfG9elUUd5RwrrhCTvvsmBGeEekdK5G/G5r57X8XVcn4JmzEhYTxNuwvm/pXmeztAl/w8aBABTYE0v9/Kr6o+NPbqQgT+ShCTUeJjiYfqHhcfk2kWo5R5m1oJtgQ0WLcZ+YTph8Q4jk1VdSy2+hH++DgDAtjjvirRzIl13yjYyHSw6J9oJDgF0Qj8ujlQsFOsiwzrpT+Qw/UaMTrsE1w1U1bki7tO7Nij1Y0aHsPeEUJ+SMMqq1M+iwmBMErLBdnJWljQz6QFRfNMipHjxAtroDA/hJSvowrjxYpCWD3Ty75Svb4tjUYCyPIYs8/uZQIwgsgYU/Du381m3E7Pni8p3TftKQ/p7FBlzx/woNaSnXDUl808wQigM6gSYIJ5T2K7B8FbSnHc9UHwyl3f26ieR7UbA0bhHLOPm88QiFfIvO1kpxRsLO0JV6OuUeSvA8cN9vmTJSiYPvBmqQHltzmOeMB7YD1YrQHKD5XcTNsfa5MDDe6NGsOL789mvYKNrJNG86r6laXavi+AlgAo6E2nnO/9f45w218VK9XrkiDA2Hg8NWey90Dmo4RWM8kHmCHZqxVw1dFfX3iuRVyLe092xDsaIInZyt6h6fLo59S4PgzKNpusJ28D0cht4jHb1phRouDcs57axX2vY1R9SgAW+BwbYV1pxNTPZKNHtQ4WC7m/oUCeW+O0ViEk43ztj5A1JPevo2fqB/XUOmk8rx7oVOb0eO+yBKL4yDZAiVMuIx5JpDVQDixHkxEEphn6OtVv/Da3zisWg50aGwH7IirZ2ANK3ybH43g9RfNJoPSBSPBcq+01MwVP4H/9JN7KAC2eUr40Es6H8t4PXR2DTmzVqa2jno49et5bzKnayCQDVFSDvTGVCGkStH2UP3NDGsn txIOYxCy RCbGVYlE1BX8CNINcCAfdS12OefhVvA1wXycViNPsDI4t2HvKOdzPYmdtXVX9GfSogA4rWtoLA0uDL1hGu2pD2Uxf6+V0uAKB5tbdIKl7MiEwlpUzhQMzF0U2FIkCoPCPFJ+ta/2b0xoJ6g7ooewnj2GYONI1BmYhNr5I71eWWsiv9pT7uICtOgeFnq8q9+iHmLZDTQUzghz0pNMCgYN3SodenTvrCNRezLEUNCb3CqemuGyRPM0sdWPu0kjdP0qG2CM/LfCL5IRtXi9QjBtIee4q2fa1Py9WiYaLJYbrIXHm0wo= 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 teaches the memory_hotplug code to allow for splitting add_memory() and remove_memory() requests over memblock sized chunks. Patch 2 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 v4: - Rebase to Aneesh's PPC64 memmap_on_memory series v8 [2]. - Tweak a goto / error path in add_memory_create_devices() (Jonathan) - Retain the old behavior for dax devices, only default to memmap_on_memory for CXL (Jonathan) - Link to v3: https://lore.kernel.org/r/20230801-vv-kmem_memmap-v3-0-406e9aaf5689@intel.com [2]: https://lore.kernel.org/linux-mm/20230808091501.287660-1-aneesh.kumar@linux.ibm.com Changes in v3: - Rebase on Aneesh's patches [1] - Drop Patch 1 - it is not needed since [1] allows for dynamic setting of the memmap_on_memory param (David) - Link to v2: https://lore.kernel.org/r/20230720-vv-kmem_memmap-v2-0-88bdaab34993@intel.com [1]: https://lore.kernel.org/r/20230801044116.10674-1-aneesh.kumar@linux.ibm.com 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 (2): mm/memory_hotplug: split memmap_on_memory requests across memblocks dax/kmem: allow kmem to add memory with memmap_on_memory drivers/dax/bus.h | 1 + drivers/dax/dax-private.h | 1 + drivers/dax/bus.c | 38 +++++++++++ drivers/dax/cxl.c | 1 + drivers/dax/hmem/hmem.c | 1 + drivers/dax/kmem.c | 8 ++- drivers/dax/pmem.c | 1 + mm/memory_hotplug.c | 165 ++++++++++++++++++++++++++++------------------ 8 files changed, 150 insertions(+), 66 deletions(-) --- base-commit: 25b5b1a0646c3d39e1d885e27c10be1c9e202bf2 change-id: 20230613-vv-kmem_memmap-5483c8d04279 Best regards,