daxctl: Add support for famfs mode
A message that is not in the archive (sent off-list or not yet received): [email protected]
v6 cover daxctl: Add support for famfs mode
From: John Groves <[email protected]>
This series adds famfs mode support to daxctl, alongside the existing devdax and system-ram modes. A daxdev is in famfs mode when it is bound to fsdev_dax.ko (drivers/dax/fsdev.c). famfs is a shared, memory-mappable filesystem for disaggregated and CXL memory; see
https://famfs.org for more information.
Patch 1 adds the library plumbing: mode detection helpers, an enable function, and the device.c reconfigure-device wiring. Patch 2 adds a test that exercises mode transitions on the nfit_test emulated backend.
This series depends on the fsdev_dax kernel driver (which provides famfs mode) and on the famfs kernel patch series.
Changes since V5 (addressing Alison's review):
Patch 1 (daxctl: Add support for famfs mode):
- Commit message: add an intro paragraph describing what famfs is, with a link to https://famfs.org.
- Documentation: document famfs mode in Documentation/daxctl/daxctl-reconfigure-device.txt (DESCRIPTION, the -m/--mode option list, and a reconfigure example).
- Rename the local 'enum dev_mode' to 'enum reconfig_mode' (RECONFIG_MODE_*) so it no longer shares member names with enum daxctl_dev_mode.
- Add daxctl_dev_get_mode(), which reports a device's current mode; the three reconfig_mode_*() functions and json.c now switch on it instead of repeating an if-else mode chain. enum daxctl_dev_mode moves to the public header and gains a DAXCTL_DEV_MODE_UNKNOWN sentinel; daxctl_dev_get_mode() is exported.
- Collapse disable_devdax_device() and disable_famfs_device() into a single disable_mode_device() (the caller has already matched the mode).
- Add daxctl_dev_is_system_ram_mode() as the preferred name for the consistency with daxctl_dev_is_{famfs,devdax}_mode(); daxctl_dev_is_system_ram_capable() becomes a compatibility wrapper so the existing ABI is preserved.
- Move the "returns false for a disabled device" note onto the shared daxctl_dev_bound_to_module() helper and drop the redundant per-predicate comments.
- Fix daxctl_dev_enable() to range-check mode before indexing dax_modules[]; the lookup previously ran before the bounds check.
- Remove the stray double space in the --mode=famfs parse branch.
- Drop the Reviewed-by: Dave Jiang tag, given the amount of rework since V5.
Patch 2 (test):
- Replace the V5 device-scanning test with test/daxctl-famfs-nfit.sh, which builds its own dax device from the emulated ACPI.NFIT bus (nfit_test) so it runs in the ndctl unit-test model. Real DRAM backing means kmem onlining works and the full devdax/famfs/system-ram matrix runs end-to-end, including the system-ram -> famfs rejection. Follows the existing test style (set -x logging, err/cleanup traps, check_dmesg, fixture teardown). Based on a rewrite from Alison Schofield.
- Per Alison's "pick a lane to start" feedback, only the nfit_test backend is upstreamed here; a cxl_test-backed variant is held for a later revision.
John Groves (2):
daxctl: Add support for famfs mode
Add nfit_test famfs mode-transition test
.../daxctl/daxctl-reconfigure-device.txt | 22 +- daxctl/device.c | 113 ++++++--- daxctl/json.c | 18 +- daxctl/lib/libdaxctl-private.h | 9 +- daxctl/lib/libdaxctl.c | 73 +++++- daxctl/lib/libdaxctl.sym | 9 + daxctl/libdaxctl.h | 14 ++ test/daxctl-famfs-nfit.sh | 215 ++++++++++++++++++ test/meson.build | 2 + 9 files changed, 432 insertions(+), 43 deletions(-) create mode 100755 test/daxctl-famfs-nfit.sh
Signature · 1 line
2.53.0
PATCH v6 1/2 daxctl: Add support for famfs mode
From: John Groves <[email protected]>
famfs is a shared, memory-mappable filesystem for disaggregated and fabric-attached memory such as CXL. Files map directly to dax memory without page-cache buffering, which lets multiple hosts share the same memory through per-host file mappings. See https://famfs.org for more information.
Putting a daxdev in famfs mode means binding it to fsdev_dax.ko (drivers/dax/fsdev.c). Finding a daxdev bound to fsdev_dax means it is in famfs mode.
A test for this functionality is added in the next commit.
With devdax, famfs, and system-ram modes, the previous logic that assumed 'not in mode X means in mode Y' needed to get slightly more complicated.
Add explicit mode detection to libdaxctl:
- daxctl_dev_is_famfs_mode(): check if bound to the fsdev_dax driver
- daxctl_dev_is_devdax_mode(): check if bound to the device_dax driver
- daxctl_dev_is_system_ram_mode(): check if bound to the kmem driver All three delegate to a shared static helper daxctl_dev_bound_to_module() to avoid duplicating the driver-symlink lookup. daxctl_dev_is_system_ram_mode() is the consistent name for the pre-existing daxctl_dev_is_system_ram_capable(), which becomes a thin compatibility wrapper so the existing ABI is preserved.
Add daxctl_dev_get_mode(), which reports the current mode of a device (system-ram, devdax, famfs, or unknown) so callers can dispatch on a single value rather than chaining the predicates above. enum daxctl_dev_mode moves to the public header and gains a DAXCTL_DEV_MODE_UNKNOWN sentinel, and daxctl_dev_get_mode() is exported.
Update mode transition logic in device.c:
- the reconfig_mode_*() functions switch on daxctl_dev_get_mode() rather than repeating an if-else mode chain
- disable_devdax_device() and disable_famfs_device() collapse into a single disable_mode_device(); the caller has already matched the mode
- rename the local 'enum dev_mode' to 'enum reconfig_mode' (RECONFIG_MODE_*) so it no longer shares member names with enum daxctl_dev_mode
- handle an unrecognized mode with an error instead of a wrong assumption
While here, fix daxctl_dev_enable() to range-check mode before using it to index the dax_modules[] array: the mod_name lookup previously happened before the bounds check, allowing an out-of-bounds read for a negative or out-of-range mode. The lookup now runs only after mode is validated.
Update json.c to report fsdev_dax-bound devices as 'famfs' mode. An unbound device continues to be reported as 'devdax' (the legacy default when no driver is bound), to preserve existing behavior.
Document the famfs mode in Documentation/daxctl/daxctl-reconfigure-device.txt.
--- .../daxctl/daxctl-reconfigure-device.txt | 22 +++- daxctl/device.c | 113 +++++++++++++----- daxctl/json.c | 18 ++- daxctl/lib/libdaxctl-private.h | 9 +- daxctl/lib/libdaxctl.c | 73 +++++++++-- daxctl/lib/libdaxctl.sym | 9 ++ daxctl/libdaxctl.h | 14 +++ 7 files changed, 215 insertions(+), 43 deletions(-)
Documentation/daxctl/daxctl-reconfigure-device.txt +21 -1
@@ -17,7 +17,9 @@ DESCRIPTION Reconfigure the operational mode of a dax device. This can be used to convert a regular 'devdax' mode device to the 'system-ram' mode which arranges for the -dax range to be hot-plugged into the system as regular memory. +dax range to be hot-plugged into the system as regular memory. A 'devdax' mode +device can also be converted to 'famfs' mode, which binds it to the fsdev_dax +driver for use by the famfs shared-memory filesystem (see https://famfs.org). NOTE: This is a destructive operation. Any data on the dax device *will* be lost.
@@ -127,6 +129,19 @@ EXAMPLES } ---- +* Reconfigure dax0.0 (currently in devdax mode) to famfs mode +---- +# daxctl reconfigure-device --mode=famfs dax0.0 +[ + { + "chardev":"dax0.0", + "size":16777216000, + "target_node":2, + "mode":"famfs" + } +] +---- + * Reconfigure all dax devices on region0 to system-ram mode ---- # daxctl reconfigure-device --mode=system-ram --region=0 all
@@ -205,6 +220,11 @@ include::region-option.txt[] kernel to support hot-unplugging 'kmem' based memory. If this is not available, a reboot is the only way to switch back to 'devdax' mode. + - "famfs": bind the device to the fsdev_dax driver for use by the famfs + shared-memory filesystem (https://famfs.org). The device must + currently be in "devdax" mode; converting directly from "system-ram" + is rejected. + -N:: --no-online:: By default, memory sections provided by system-ram devices will be
daxctl/device.c +86 -27
188 lines not on this page · raw message
daxctl/json.c +16 -2
@@ -46,10 +46,24 @@ struct json_object *util_daxctl_dev_to_json(struct daxctl_dev *dev,json_object_object_add (jdev,"align" , jobj); } -if (mem) +switch (daxctl_dev_get_mode (dev)) { +case DAXCTL_DEV_MODE_RAM : jobj =json_object_new_string ("system-ram" ); -else +break ; +case DAXCTL_DEV_MODE_FAMFS : + jobj =json_object_new_string ("famfs" ); +break ; +case DAXCTL_DEV_MODE_DEVDAX : +default : +/* A device bound to device_dax is in devdax mode. A device with +* no driver bound (DAXCTL_DEV_MODE_UNKNOWN) is reported as devdax +* too, the legacy default (the disabled modifier is added later +* in this function if applicable). +*/ jobj =json_object_new_string ("devdax" ); +break ; + } +if (jobj)json_object_object_add (jdev,"mode" , jobj);
daxctl/lib/libdaxctl-private.h +3 -6
@@ -5,6 +5,8 @@#include <libkmod.h> +#include <daxctl/libdaxctl.h> +#define DAXCTL_EXPORT __attribute__ ((visibility("default")))enum dax_subsystem {
@@ -18,15 +20,10 @@ static const char *dax_subsystems[] = { [DAX_BUS] = "/sys/bus/dax/devices", }; -enum daxctl_dev_mode { -DAXCTL_DEV_MODE_DEVDAX =0 , -DAXCTL_DEV_MODE_RAM , -DAXCTL_DEV_MODE_END , -}; -static const char *dax_modules[] = { [DAXCTL_DEV_MODE_DEVDAX ] ="device_dax" , [DAXCTL_DEV_MODE_RAM ] ="kmem" , + [DAXCTL_DEV_MODE_FAMFS ] ="fsdev_dax" , };enum memory_op {
daxctl/lib/libdaxctl.c +66 -7
123 lines not on this page · raw message
daxctl/lib/libdaxctl.sym +9 -0
@@ -104,3 +104,12 @@ LIBDAXCTL_10 { global: daxctl_dev_is_system_ram_capable; } LIBDAXCTL_9; + +LIBDAXCTL_11 { +global: + daxctl_dev_enable_famfs; + daxctl_dev_is_famfs_mode; + daxctl_dev_is_devdax_mode; + daxctl_dev_get_mode; + daxctl_dev_is_system_ram_mode; +} LIBDAXCTL_10;
daxctl/libdaxctl.h +14 -0
@@ -72,12 +72,26 @@ int daxctl_dev_is_enabled(struct daxctl_dev *dev);int daxctl_dev_disable (struct daxctl_dev *dev);int daxctl_dev_enable_devdax (struct daxctl_dev *dev);int daxctl_dev_enable_ram (struct daxctl_dev *dev); +int daxctl_dev_enable_famfs (struct daxctl_dev *dev);int daxctl_dev_get_target_node (struct daxctl_dev *dev);int daxctl_dev_will_auto_online_memory (struct daxctl_dev *dev);int daxctl_dev_has_online_memory (struct daxctl_dev *dev);struct daxctl_memory ; + +enum daxctl_dev_mode { +DAXCTL_DEV_MODE_UNKNOWN =-1 , +DAXCTL_DEV_MODE_DEVDAX =0 , +DAXCTL_DEV_MODE_RAM , +DAXCTL_DEV_MODE_FAMFS , +DAXCTL_DEV_MODE_END , +}; + +int daxctl_dev_is_system_ram_mode (struct daxctl_dev *dev);int daxctl_dev_is_system_ram_capable (struct daxctl_dev *dev); +int daxctl_dev_is_famfs_mode (struct daxctl_dev *dev); +int daxctl_dev_is_devdax_mode (struct daxctl_dev *dev); +enum daxctl_dev_mode daxctl_dev_get_mode (struct daxctl_dev *dev);struct daxctl_memory *daxctl_dev_get_memory (struct daxctl_dev *dev);struct daxctl_dev *daxctl_memory_get_dev (struct daxctl_memory *mem);const char *daxctl_memory_get_node_path (struct daxctl_memory *mem);
Signature · 1 line
2.53.0
PATCH v6 2/2 Add nfit_test famfs mode-transition test
In reply to John GrovesFrom: John Groves <[email protected]>
Add test/daxctl-famfs-nfit.sh, which builds its own dax device from the emulated ACPI.NFIT bus (nfit_test) so it runs in the ndctl unit-test model rather than scanning for a pre-existing dax device.
nfit_test ranges have real DRAM backing, so kmem onlining works and the full transition matrix runs end-to-end:
- devdax <-> famfs switches, including same-mode re-enable
- system-ram <-> devdax <-> famfs, with real memory online/offline
- system-ram -> famfs is rejected (the conversion must go via devdax)
- JSON output reports the correct mode
- invalid modes are rejected
The test follows the existing ndctl test style: 'set -x' command logging, err/cleanup traps, check_dmesg at completion, and fixture teardown rather than restore-to-original cleanup.
--- test/daxctl-famfs-nfit.sh | 215 ++++++++++++++++++++++++++++++++++++++ test/meson.build | 2 + 2 files changed, 217 insertions(+) create mode 100755 test/daxctl-famfs-nfit.sh
test/daxctl-famfs-nfit.sh new file +215 -0
@@ -0,0 +1,215 @@ +#!/bin/bash -Ex +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 Micron Technology, Inc. All rights reserved. +# +# Test daxctl famfs mode transitions and mode detection, targeting a +# nfit_test-backed dax device. +# +# nfit_test-backed dax devices have real DRAM backing, so kmem onlining +# works normally. This test exercises the full matrix of transitions +# between devdax, famfs, and system-ram. + +rc=77 +. $(dirname $0)/common + +trap 'cleanup $LINENO' ERR + +testbus="" +testdev="" +daxdev="" + +cleanup() +{ + # Best-effort return to devdax so destroy-namespace can succeed. + if [[ -n $daxdev ]]; then + "$DAXCTL" reconfigure-device -f -m devdax "$daxdev" 2>/dev/null || true + fi + [[ -n $testdev ]] && reset_dev + err "$1" +} + +check_fsdev_dax() +{ + modinfo fsdev_dax &>/dev/null && return 0 + grep -qF "fsdev_dax" "/lib/modules/$(uname -r)/modules.builtin" 2>/dev/null && return 0 + do_skip "fsdev_dax module not available" +} + +check_kmem() +{ + modinfo kmem &>/dev/null && return 0 + grep -qF "kmem" "/lib/modules/$(uname -r)/modules.builtin" 2>/dev/null && return 0 + do_skip "kmem module not available" +} + +find_testdev() +{ + testbus="$ACPI_BUS" + + # Ensure the bus has labels, like align.sh / daxctl-devices.sh rely on. + "$NDCTL" disable-region -b "$testbus" all + "$NDCTL" init-labels -f -b "$testbus" all + "$NDCTL" enable-region -b "$testbus" all + + testdev=$("$NDCTL" list -b "$testbus" -Ni | jq -er '.[0].dev | .//""') + [[ $testdev ]] || do_skip "no victim device on $testbus" +} + +setup_dev() +{ + test -n "$testbus" + test -n "$testdev" + + "$NDCTL" destroy-namespace -f -b "$testbus" "$testdev" + # x86_64 memory hotplug can require up to a 2GiB-aligned chunk of + # memory. Create a 4GiB namespace, so enough space is left after + # alignment for kmem + online. + testdev=$("$NDCTL" create-namespace -b "$testbus" -m devdax -fe "$testdev" -s 4G | \ + jq -er '.dev') + test -n "$testdev" + + daxdev=$("$NDCTL" list -n "$testdev" -X | jq -er '.[].daxregion.devices[0].chardev') + test -n "$daxdev" +} + +reset_dev() +{ + "$NDCTL" destroy-namespace -f -b "$testbus" "$testdev" +} + +daxctl_get_mode() +{ + "$DAXCTL" list -d "$1" | jq -er '.[].mode' +} + +save_online_policy() +{ + saved_policy="$(cat /sys/devices/system/memory/auto_online_blocks)" +} + +restore_online_policy() +{ + echo "$saved_policy" > /sys/devices/system/memory/auto_online_blocks +} + +unset_online_policy() +{ + echo "offline" > /sys/devices/system/memory/auto_online_blocks +} + +ensure_devdax_mode() +{ + local mode + mode=$(daxctl_get_mode "$daxdev") + + case "$mode" in + devdax) return 0 ;; + famfs) "$DAXCTL" reconfigure-device -m devdax "$daxdev" >/dev/null ;; + system-ram) "$DAXCTL" reconfigure-device -f -m devdax "$daxdev" >/dev/null ;; + *) + echo "unexpected starting mode: $mode" + return 1 + ;; + esac + + [[ $(daxctl_get_mode "$daxdev") == "devdax" ]] +} + +test_famfs_mode_transitions() +{ + ensure_devdax_mode + + # devdax -> famfs + "$DAXCTL" reconfigure-device -m famfs "$daxdev" >/dev/null + [[ $(daxctl_get_mode "$daxdev") == "famfs" ]] + + # famfs -> famfs (re-enable in same mode) + "$DAXCTL" reconfigure-device -m famfs "$daxdev" >/dev/null + [[ $(daxctl_get_mode "$daxdev") == "famfs" ]] + + # famfs -> devdax + "$DAXCTL" reconfigure-device -m devdax "$daxdev" >/dev/null + [[ $(daxctl_get_mode "$daxdev") == "devdax" ]] + + # devdax -> devdax (re-enable in same mode) + "$DAXCTL" reconfigure-device -m devdax "$daxdev" >/dev/null + [[ $(daxctl_get_mode "$daxdev") == "devdax" ]] +} + +test_json_output() +{ + ensure_devdax_mode + [[ $("$DAXCTL" list -d "$daxdev" | jq -er '.[].mode') == "devdax" ]] + + "$DAXCTL" reconfigure-device -m famfs "$daxdev" >/dev/null + [[ $("$DAXCTL" list -d "$daxdev" | jq -er '.[].mode') == "famfs" ]] + + "$DAXCTL" reconfigure-device -m devdax "$daxdev" >/dev/null +} + +test_error_handling() +{ + "$DAXCTL" reconfigure-device -m famfs "$daxdev" >/dev/null + + # Invalid mode must be rejected + if "$DAXCTL" reconfigure-device -m invalidmode "$daxdev" &>/dev/null; then + echo "FAIL: invalid mode should be rejected" + return 1 + fi + + "$DAXCTL" reconfigure-device -m devdax "$daxdev" >/dev/null +} + +# Full system-ram transitions (real backing, so online_pages() works). +# Turns auto-online off so daxctl drives onlining explicitly. +test_system_ram_transitions() +{ + save_online_policy + unset_online_policy + + ensure_devdax_mode + + # devdax -> system-ram (no-online) + "$DAXCTL" reconfigure-device -N -m system-ram "$daxdev" >/dev/null + [[ $(daxctl_get_mode "$daxdev") == "system-ram" ]] + + # system-ram -> famfs must be rejected + if "$DAXCTL" reconfigure-device -m famfs "$daxdev" &>/dev/null; then + echo "FAIL: system-ram -> famfs should be rejected" + restore_online_policy + return 1 + fi + + # system-ram -> devdax -> famfs + "$DAXCTL" reconfigure-device -f -m devdax "$daxdev" >/dev/null + [[ $(daxctl_get_mode "$daxdev") == "devdax" ]] + "$DAXCTL" reconfigure-device -m famfs "$daxdev" >/dev/null + [[ $(daxctl_get_mode "$daxdev") == "famfs" ]] + + # Full online cycle: devdax -> system-ram (with online) -> devdax. + "$DAXCTL" reconfigure-device -m devdax "$daxdev" >/dev/null + "$DAXCTL" reconfigure-device -m system-ram "$daxdev" >/dev/null + [[ $(daxctl_get_mode "$daxdev") == "system-ram" ]] + "$DAXCTL" reconfigure-device -f -m devdax "$daxdev" >/dev/null + [[ $(daxctl_get_mode "$daxdev") == "devdax" ]] + + restore_online_policy +} + +check_fsdev_dax +check_kmem + +rc=1 + +find_testdev +setup_dev + +test_famfs_mode_transitions +test_json_output +test_error_handling +test_system_ram_transitions + +ensure_devdax_mode +reset_dev + +check_dmesg "$LINENO"
test/meson.build +2 -0
@@ -213,6 +213,7 @@ if get_option('destructive').enabled() device_dax_fio = find_program('device-dax-fio.sh') daxctl_devices = find_program('daxctl-devices.sh') daxctl_create = find_program('daxctl-create.sh') + daxctl_famfs_nfit = find_program('daxctl-famfs-nfit.sh') dm = find_program('dm.sh') mmap_test = find_program('mmap.sh')
@@ -230,6 +231,7 @@ if get_option('destructive').enabled() [ 'device-dax-fio.sh', device_dax_fio, 'dax' ], [ 'daxctl-devices.sh', daxctl_devices, 'dax' ], [ 'daxctl-create.sh', daxctl_create, 'dax' ], + [ 'daxctl-famfs-nfit.sh', daxctl_famfs_nfit, 'dax' ], [ 'dm.sh', dm, 'dax' ], [ 'mmap.sh', mmap_test, 'dax' ], ]
Signature · 1 line
2.53.0
Alison Schofield
maintainerQuoted 8 lines · John Groves
From: John Groves <[email protected]>
This series adds famfs mode support to daxctl, alongside the existing devdax and system-ram modes. A daxdev is in famfs mode when it is bound to fsdev_dax.ko (
drivers/dax/fsdev.c). famfs is a shared, memory-mappable filesystem for disaggregated and CXL memory; see
https://famfs.org for more information.
Quoted 6 lines
Patch 1 adds the library plumbing: mode detection helpers, an enable function, and the
device.creconfigure-device wiring. Patch 2 adds a test that exercises mode transitions on thenfit_testemulated backend.This series depends on the
fsdev_daxkernel driver (which provides famfs mode) and on the famfs kernel patch series.
Thanks!
Applied to: https://github.com/pmem/ndctl/tree/pending
with minor touchup to the unit test patch:
[ as: drop -nfit suffix on test name, wrap commit lines at 70 columns ]
Quoted 13 lines · Alison Schofield
Quoted 12 lines · John Groves
From: John Groves <[email protected]>
This series adds famfs mode support to daxctl, alongside the existing devdax and system-ram modes. A daxdev is in famfs mode when it is bound to fsdev_dax.ko (
drivers/dax/fsdev.c). famfs is a shared, memory-mappable filesystem for disaggregated and CXL memory; see
https://famfs.org for more information.Patch 1 adds the library plumbing: mode detection helpers, an enable function, and the
device.creconfigure-device wiring. Patch 2 adds a test that exercises mode transitions on thenfit_testemulated backend.
Quoted 10 lines
Quoted 2 lines
This series depends on the
fsdev_daxkernel driver (which provides famfs mode) and on the famfs kernel patch series.Thanks!
Applied to: https://github.com/pmem/ndctl/tree/pendingwith minor touchup to the unit test patch:
[ as: drop -nfit suffix on test name, wrap commit lines at 70 columns ]
Thanks Alison!
John