From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vs1-f52.google.com (mail-vs1-f52.google.com [209.85.217.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 872BA28B7DA for ; Sat, 21 Mar 2026 15:04:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774105451; cv=none; b=Re1v+DTYJlxyTZZtPHQzKh6HI+NkcWxcXhANTN/mVyltaplAGug+dbUlzgDcgc5ndK8X3F34Lc9l6PMPa1PdyGqroYhzY+gchEKa3Pqxva0p+hVveTUjq24IeGdGsoTl1mXqqAGMfUWzDmAYkgm2aw/lWDwqV6qx7BQg1ooqJ7s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774105451; c=relaxed/simple; bh=aDELlooxNdwnVkBOav2pG7nLNFo7hMZ9D//B2Ne87+I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tullXGR7mWHVUo+f6bhZowzVZ7gDGQ9TVpbqCIR5CSpTstM2bk3KJbipStJ0whhlZouMxlTUK8nMrNYsxWGbbfj0uC6ZV4rDLIyK+8Vy2HtyIaUJ43KNyMrloJAsO/zJs0RgyUMmoPXpYhrsRyqh975Ebano+yhIvnK8HzL6yCY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=DEu/f8k4; arc=none smtp.client-ip=209.85.217.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="DEu/f8k4" Received: by mail-vs1-f52.google.com with SMTP id ada2fe7eead31-5fff18d44fbso1750795137.1 for ; Sat, 21 Mar 2026 08:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1774105448; x=1774710248; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=81HYMZ3vgCAeT6eFRo3fsP2FLDXA0ujBDRYZ8Ob/cJk=; b=DEu/f8k4q++Fv9YwpZE/Tv5ZfqM1WenYwre39Ghq4c0iL41utjSEwJBgz3onCy0ApA F2VbVz3b/XYSp5lFJDjSq0OIv79zNp/WS5GOv6JC4saPfpqbZCzprGPWTw5oNT0v+vs8 Tad9e6yQbs6n/+j8rCjnBW7OqPys/07r/oEuR+EB9S8V5Vofs/JMexzm3ZW5vbP310BT PsdHBthiH8R+f5c09n4CmWbTcgiYkgvibmiRRPOXOUE9dKcZBcLGZ0mt+feR/tHdkiix xkLb2VdnuVupfcjUEUjLVRS/ihTYyT1XjiSfso0lMrvxlZqY77v7HaPDJKZsuR4T5dp/ JqTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774105448; x=1774710248; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=81HYMZ3vgCAeT6eFRo3fsP2FLDXA0ujBDRYZ8Ob/cJk=; b=HhRMTaUvTYaDiMPjlruZn2B6Ef3etpvPjmZ90IAoUwApqOswMEdxReCAOhKRgrn+QG v1ohFqw4PtF6nLBihlEaUzA+ocdG4nasWa0UZFmhKXsOeK0zXCfq0wFgcttjYsUS5+6n UDTwlnc1KxOEA5nk8sN1vgU30lvRaEheK0OIvLpmSLBLY/gHqfhTigDJ8iuJAxz43wpP ui7mFP+aaFbJTW8ajtAdq/NcbxCb28iDHdDUSiMNC/uUeISRRj1wnIELhpxT8DG9kpzq sEh8T6iotle3AyaNgf6O96YmbkEXyQpwqnMKVmV9ii9Zku9aIV4O+nCHf+RTgzFMRBfr XiZQ== X-Forwarded-Encrypted: i=1; AJvYcCXtCX7ZhSy7R8WLBM01c9OxsTB0L+T0ltjqwScliOyPwAOLS2K24rBju8Xu0YmUtkuaVSIvegMEf/cN0ns=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+rrqQANwWBpWXTkSLU31FnbLRyaM4Q7Z3kzcCjKzKwrx1di95 30L4QDnaZdx0K8uGCvJ7pq2x7/T/viqGkfgwg2DNSa/qQa86yMVHRGlb6zZOqh7cn1w= X-Gm-Gg: ATEYQzwrlUTrqDh5yFdAAM/R7hTcIHCj0QpJ97HD8//tL4KZLkMHgTs3g/G2g6GS4DD 1hhvnlc4nuvXE1faG5BpGuePLWEjoC+fAmOU94libQ6m5TTxuSpGasOvnIT7mbOubKya2W4BG+A gWCB20NiIFSX89WTTSx5e1aBK4ek6+nzE67eLRCfDyKnkHhZu2nhk+0j+lD9rOam4cZeMxU/IST O7s9x4Q3ZW20nWR+WzW8L2z0GmTH4AI24NXMTkNyeIuVSD78OhRp+penzMUbBRzlEQRaBg3Pr8Z AQV/DM1PlH+j8opshtmK8YGFAwvXd0nuXta4812O//r5Ko7PETImZQUTXWYj4ju/FFpZnD5DYdR UQ/AAnQil5dCPhwBPiPwdg015SdIv68L8zmo378/QKsLc3oE4rgmXZLRBGZH+Kd7xuoE+wsGoCi FMjOnWLZVo30FDVAYJT5jUiBplv7KRSqxSe+w6hOHIBtTM0NwOWLWA5aJ4p4t6fWGEhU7tInmv8 KULi35aEkhmzkU9WDHPYcX5mQ== X-Received: by 2002:a05:6102:5989:b0:602:79ed:643c with SMTP id ada2fe7eead31-602aea8cc48mr3376178137.7.1774105448304; Sat, 21 Mar 2026 08:04:08 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F.lan (pool-96-255-20-138.washdc.ftas.verizon.net. [96.255.20.138]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8cfc90ba89fsm391979885a.40.2026.03.21.08.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2026 08:04:07 -0700 (PDT) From: Gregory Price To: linux-mm@kvack.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, david@kernel.org, osalvador@suse.de Cc: dan.j.williams@intel.com, ljs@kernel.org, Liam.Howlett@oracle.com, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, kernel-team@meta.com Subject: [PATCH 0/8] dax/kmem: atomic whole-device hotplug via sysfs Date: Sat, 21 Mar 2026 11:03:56 -0400 Message-ID: <20260321150404.3288786-1-gourry@gourry.net> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The dax kmem driver currently onlines memory during probe using the system default policy, with no way to control or query the region state at runtime - other than by inspecting the state of individual blocks. Offlining and removing an entire region requires operating on individual memory blocks, creating race conditions where external entities can interfere between the offline and remove steps. The problem was discussed specifically in the LPC2025 device memory sessions - https://lpc.events/event/19/contributions/2016/ - where it was discussed how the non-atomic interface for dax hotplug is causing issues in some distributions which have competing userland controllers that interfere with each other. This series adds a sysfs "hotplug" attribute for atomic whole-device hotplug control, along with the mm and dax plumbing to support it. The first five patches prepare the mm and dax layers: 1. Consolidate memory-tier type deduplication into mt_get_memory_type(), removing redundant per-driver infrastructure. 2. Add a memory_block_align_range() helper for hotplug range alignment. 3-5. Thread an explicit online_type through the memory hotplug and dax paths, allowing drivers to specify a preferred auto-online policy (ZONE_NORMAL vs ZONE_MOVABLE) instead of being forced to the system default. The last three patches build the dax/kmem feature: 6. Plumb online_type through the dax device creation path. 7. Extract hotplug/hotremove into helper functions to separate resource lifecycle from memory onlining. 8. Add the "hotplug" sysfs attribute supporting three states: - "unplug": memory blocks removed - "online": online as normal system RAM - "online_movable": online in ZONE_MOVABLE Transitions are atomic across all ranges in the device. Backward compatibility is preserved: probe still auto-onlines when the configured policy matches the system default. Specific notes for maintainers: I downgraded a BUG() to a WARN() when unbind is called while the dax device is not un an UNPLUGGED state. This is because the old pattern of toggling individual memory blocks is still used by userland tools, and will disconnect the `hotplug` value from the actual state of the overall memory region. Unless we move to deprecate per-block controls, we should just WARN() instead of BUG() as an indicator that userland tools need to be updated to use the new pattern (the old pattern is subject to race conditions). The first two commits are semi-unrelated cleanups that conflict with the changes made in the refactoring commits. (memory-tier dedup and align_range helper). These are intended to be used for future cxl region extensions, but if you prefer them to be dropped or submitted separately let me know. This is technically v3, but the patch line has diverged considerably and I've reworked the cover letter, apologies for prior obtuseness Link: https://lore.kernel.org/all/20260114235022.3437787-1-gourry@gourry.net/ Gregory Price (8): mm/memory-tiers: consolidate memory type dedup into mt_get_memory_type() mm/memory: add memory_block_align_range() helper mm/memory_hotplug: pass online_type to online_memory_block() via arg mm/memory_hotplug: export mhp_get_default_online_type mm/memory_hotplug: add __add_memory_driver_managed() with online_type arg dax: plumb hotplug online_type through dax dax/kmem: extract hotplug/hotremove helper functions dax/kmem: add sysfs interface for atomic whole-device hotplug Documentation/ABI/testing/sysfs-bus-dax | 17 + drivers/dax/bus.c | 3 + drivers/dax/bus.h | 2 + drivers/dax/cxl.c | 1 + drivers/dax/dax-private.h | 3 + drivers/dax/hmem/hmem.c | 1 + drivers/dax/kmem.c | 457 ++++++++++++++++++------ include/linux/memory-tiers.h | 34 +- include/linux/memory.h | 22 ++ include/linux/memory_hotplug.h | 32 ++ mm/memory-tiers.c | 29 +- mm/memory_hotplug.c | 67 +++- 12 files changed, 501 insertions(+), 167 deletions(-) -- 2.53.0