Message ID | 20231005-vv-kmem_memmap-v5-0-a54d1981f0a3@intel.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp490919vqb; Thu, 5 Oct 2023 11:32:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF81mbWAFQxXFEm6XfIAvvm3Kv+xc66u8h9ra+506yK5TS3L01HS4QttU5XgmH3sfJ7Xi9W X-Received: by 2002:a17:90b:4d91:b0:26b:2538:d717 with SMTP id oj17-20020a17090b4d9100b0026b2538d717mr6119766pjb.25.1696530749927; Thu, 05 Oct 2023 11:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696530749; cv=none; d=google.com; s=arc-20160816; b=HD/MZHLoPYiDMjmj2Tu/qtlcmXXlMXdE3pweIHudfA6YuZOoTud8cjBzjR39vkezXH HF+xO5H0NLIeAWDvWyMJ3ndOeOoIrrx5Egts2r5FX2vGvXcNEtuutyC437adIws35nGp VBt1VQ4JA6AM6M/J2Sdw5Le1uCfhGUbBv4cM3a/B+UVZMEHAJCWPBBF2YtqlzHcV4hEj tNk697NSfusTw9y1tJXjbwkvy6jd3d2nDS9t/u0OIWviiI2g/SDInEFRWsm2PE93DhCb K/PvDRaS5jcC/EUSSFDp9ul7pxBrEmgz5aP0gntalRHD9s0ZK2WK3hQsAMP/Ew+XeVZ8 ySTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:content-transfer-encoding:mime-version :message-id:date:subject:from:dkim-signature; bh=gBwe/WP8fVL8cHTESG8pevEdgJTpw3tZMyZUeECRuBE=; fh=K6XmanfW69WIGlI+l+O18lb+dFEsDiql6DFppOVA05M=; b=HYFIn/r565vsaZwedXdzPtWbMiO7ifJmrhX21/DTXbj++Oh2bkFgHTCnqeNwmwWX7+ dPla8VvZwvS6Uw6jeSKGKCA5Oi2B8QbtCAyAMiRfryDaUvpaVOipKHEgI5uGR8YknvdZ bWAL3+jDd5/6g8Qn7BKs7T+8JmR+SVmV8lM1MDHZkwYvjHHujHlVmS/M1o95lgVCoILK FSwUaj6dXQ87NXWPfMK355dMTBBGw6jz5Ncq6138sN0v1mq/D3phzLf1wAv5YaPhSa9q 4VscTUaTPgIFXe1zJrzvrhf5Snu82h0DTMJhzLgjCu30uafQ4DWOZTGKJqeVlVIQBr7t hF8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LPghufRX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id kw11-20020a170902f90b00b001c73732c1f2si1927425plb.223.2023.10.05.11.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 11:32:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LPghufRX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 45EAE8038FA9; Thu, 5 Oct 2023 11:32:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231726AbjJEScE (ORCPT <rfc822;ezelljr.billy@gmail.com> + 18 others); Thu, 5 Oct 2023 14:32:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231631AbjJEScC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 5 Oct 2023 14:32:02 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E69A9F; Thu, 5 Oct 2023 11:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696530720; x=1728066720; h=from:subject:date:message-id:mime-version: content-transfer-encoding:to:cc; bh=/oSquPe50FjL5XM1xo2u1juCDXoKE0v8k5E8iBZtEIw=; b=LPghufRXgmW+FpkS+XZa3l4lxugkUkTdnijw03C1lR6U0JTV+wXIa6no EFEWvIOVNcWpLWR/mTLybgIR74zYc2cQtGpP89yvZS4w6nAviMjh1bAhR iaPAhOwj2ec/uYNEnlrm8HLy4cZbSCoZ6fv0mvWLaUc/fY/K2/ud3EVMF q9wB7O8sVtb+bgXl5v5lF5UvoUWdaAlceq/aoYOqshHPBP5gLoFVJWurD w3SJBPE94tsM1rUknPPPMuKpsag5YD4/6hiJBhJnvjFDlQXgfJIvIlJec MlahbTJts7hswlqBZNqYE13F8QwDLC9MNouhu9c/eQDLnTIky6CvTHOYd Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="363860723" X-IronPort-AV: E=Sophos;i="6.03,203,1694761200"; d="scan'208";a="363860723" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2023 11:31:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="781342809" X-IronPort-AV: E=Sophos;i="6.03,203,1694761200"; d="scan'208";a="781342809" Received: from amykuo-mobl.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.12.247]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2023 11:31:52 -0700 From: Vishal Verma <vishal.l.verma@intel.com> Subject: [PATCH v5 0/2] mm: use memmap_on_memory semantics for dax/kmem Date: Thu, 05 Oct 2023 12:31:38 -0600 Message-Id: <20231005-vv-kmem_memmap-v5-0-a54d1981f0a3@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAoBH2UC/3XNQW7DIBAF0KtErEuFAWPIqveoomqMhxrVxhEkq FXku3eSjatYXczif+n9ubGCOWJhx8ONZayxxCVRaF8OzI+QPpHHgTKTQiphGsVr5V8zzh90M5x 5q63ydhBado4R6qEg7zMkPxJL12mi8pwxxO/Hl/cT5TGWy5J/Hk9rc2//3a8NFzyYAZ03EKQ3b zFdcHr1y8zuU1VuvJNixyVxa/sBoFfaOfXM1cataHZcEdfCoAMIrbHumeuNO2l3XBM3IXQqoG8 bB3/5uq6/ecPnLX4BAAA= To: Andrew Morton <akpm@linux-foundation.org>, David Hildenbrand <david@redhat.com>, Oscar Salvador <osalvador@suse.de>, Dan Williams <dan.j.williams@intel.com>, Dave Jiang <dave.jiang@intel.com> Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, Huang Ying <ying.huang@intel.com>, Dave Hansen <dave.hansen@linux.intel.com>, "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>, Michal Hocko <mhocko@suse.com>, Jonathan Cameron <Jonathan.Cameron@Huawei.com>, Jeff Moyer <jmoyer@redhat.com>, Vishal Verma <vishal.l.verma@intel.com>, Jonathan Cameron <Jonathan.Cameron@huawei.com> X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3836; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=/oSquPe50FjL5XM1xo2u1juCDXoKE0v8k5E8iBZtEIw=; b=owGbwMvMwCXGf25diOft7jLG02pJDKnyjMLySb8bv+wJd3nTr7TeqNDswTLnqZtspXept0Se3 sM9+1lwRykLgxgXg6yYIsvfPR8Zj8ltz+cJTHCEmcPKBDKEgYtTACZi8p3hf3LZ3uDd+/aeZPnw 4uZs5ow39yy/rQhZpegvfPizImvNhVMMf/j7d/7VfaqYvV1hoXrIRcachTsOW1w/+1DVZFvQnW3 HzDgA X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF 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,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 05 Oct 2023 11:32:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778941427376142739 X-GMAIL-MSGID: 1778941427376142739 |
Series |
mm: use memmap_on_memory semantics for dax/kmem
|
|
Message
Verma, Vishal L
Oct. 5, 2023, 6:31 p.m. UTC
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 <vishal.l.verma@intel.com>
---
Changes in v5:
- Separate out per-memblock operations from per memory block operations
in try_remove_memory(), and rename the inner function appropriately.
This does expand the scope of the memory hotplug lock to include
remove_memory_block_devices(), but the alternative was to drop the
lock in the inner function separately for each iteration, and then
re-acquire it in try_remove_memory() creating a small window where
the lock isn't held. (David Hildenbrand)
- Remove unnecessary rc check from the memmap_on_memory_store sysfs
helper in patch 2 (Dan Carpenter)
- Link to v4: https://lore.kernel.org/r/20230928-vv-kmem_memmap-v4-0-6ff73fec519a@intel.com
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 | 162 ++++++++++++++++++++++++++++------------------
8 files changed, 149 insertions(+), 64 deletions(-)
---
base-commit: 25b5b1a0646c3d39e1d885e27c10be1c9e202bf2
change-id: 20230613-vv-kmem_memmap-5483c8d04279
Best regards,