Skip to content

Commit

Permalink
linux/io: remove support for /sys/class/dax
Browse files Browse the repository at this point in the history
DAX devices moved to /sys/bus/dax soon after their support were added
in Linux, distributions disabled it and now it's removed from latest kernels.
Also /sys/class/dax misses many features, such as kmem driver for exposing
as NUMA nodes, and hmem driver for special-purpose memory.
So don't bother supporting it.

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Jun 20, 2022
1 parent e7aea83 commit c413eb1
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions hwloc/topology-linux.c
Expand Up @@ -6080,11 +6080,10 @@ hwloc_linuxfs_lookup_dax_class(struct hwloc_backend *backend, unsigned osdev_fla
DIR *dir;
struct dirent *dirent;

/* depending on the kernel config, dax devices may appear either in /sys/bus/dax or /sys/class/dax */
/* old kernels with /sys/class/dax aren't supported anymore */

dir = hwloc_opendir("/sys/bus/dax/devices", root_fd);
if (dir) {
int found = 0;
while ((dirent = readdir(dir)) != NULL) {
char path[300];
char driver[256];
Expand All @@ -6093,7 +6092,6 @@ hwloc_linuxfs_lookup_dax_class(struct hwloc_backend *backend, unsigned osdev_fla

if (!strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, ".."))
continue;
found++;

/* ignore kmem-device, those appear as additional NUMA nodes */
err = snprintf(path, sizeof(path), "/sys/bus/dax/devices/%s/driver", dirent->d_name);
Expand All @@ -6116,36 +6114,6 @@ hwloc_linuxfs_lookup_dax_class(struct hwloc_backend *backend, unsigned osdev_fla
hwloc_linuxfs_block_class_fillinfos(backend, root_fd, obj, path, osdev_flags | HWLOC_LINUXFS_OSDEV_FLAG_UNDER_BUS);
}
closedir(dir);

/* don't look in /sys/class/dax if we found something in /sys/bus/dax */
if (found)
return 0;
}

dir = hwloc_opendir("/sys/class/dax", root_fd);
if (dir) {
while ((dirent = readdir(dir)) != NULL) {
char path[256];
hwloc_obj_t obj, parent;
int err;

if (!strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, ".."))
continue;

/* kmem not supported in class mode, driver may only be changed under bus */

err = snprintf(path, sizeof(path), "/sys/class/dax/%s", dirent->d_name);
if ((size_t) err >= sizeof(path))
continue;
parent = hwloc_linuxfs_find_osdev_parent(backend, root_fd, path, osdev_flags);
if (!parent)
continue;

obj = hwloc_linux_add_os_device(backend, parent, HWLOC_OBJ_OSDEV_BLOCK, dirent->d_name);

hwloc_linuxfs_block_class_fillinfos(backend, root_fd, obj, path, osdev_flags);
}
closedir(dir);
}

return 0;
Expand Down

0 comments on commit c413eb1

Please sign in to comment.