Skip to contentSkip to conversation

libdaxctl: fix the system-ram capability check

PATCH In review Vishal Verma 2 participants 3 messages Sep 5, 2019 2 messages not in the archive libnvdimm: non-volatile memory device

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 libdaxctl: fix the system-ram capability check

When checking a daxctl device for system-ram capability, we needn't look at the symlink resolution for /sys/bus/dax.../driver/module since the driver in question may not always have an associated module, and could be builtin instead.

Change the symlink we resolve to simply '/sys/bus/dax.../driver' and since that too resolves to '.../kmem' in the system-ram case, the rest of the check remains unchanged.

This is a pre-requisite to making daxctl-reconfigure-device work correctly when the target mode's driver might be builtin.

---

v2: Collect Reviewed-by tags

 daxctl/lib/libdaxctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
daxctl/lib/libdaxctl.c +1 -1
index c0a859c..d9f2c33 100644
@@ -406,7 +406,7 @@ static int dev_is_system_ram_capable(struct daxctl_dev *dev)
 	if (!daxctl_dev_is_enabled(dev))
 		return false;
 
-	if (snprintf(path, len, "%s/driver/module", dev->dev_path) >= len) {
+	if (snprintf(path, len, "%s/driver", dev->dev_path) >= len) {
 		err(ctx, "%s: buffer too small!\n", devname);
 		return false;
 	}
Signature · 1 line
2.20.1

A message that is not in the archive (sent off-list or not yet received): 20190905011314.18610-1-vishal.l.verma-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH v2 2/2 libdaxctl: fix device reconfiguration with builtin drivers

When the driver of a given reconfiguration mode is builtin, libdaxctl isn't able to build a module lookup list using kmod. However, it doesn't need to fail in this case, as it is acceptable for a driver to be builtin.

Indeed, since even with a modalias lookup list, we still have to resolve the target driver based on the mode using the module name, so relying on the modalias lookup to keep us impervious to module name changes is already flawed.

Simplify module loading greatly by removing the modalias lookups, and directly getting the module from a named lookup. This transparently fixes the problem when the driver may be builtin instead of being a module.

---

v2:
- Remove modalias lookup lists entirely, and perform a simple name based lookup (Dan)
- Fix the module expectation in the daxctl-devices unit test.

 daxctl/lib/libdaxctl-private.h |  1 -
 daxctl/lib/libdaxctl.c         | 75 ++++++++--------------------------
 test/daxctl-devices.sh         |  7 +++-
 3 files changed, 23 insertions(+), 60 deletions(-)
daxctl/lib/libdaxctl-private.h +0 -1
index 01091de..7ba3c46 100644
@@ -75,7 +75,6 @@ struct daxctl_dev {
 	unsigned long long resource;
 	unsigned long long size;
 	struct kmod_module *module;
-	struct kmod_list *kmod_list;
 	struct daxctl_region *region;
 	struct daxctl_memory *mem;
 	int target_node;
daxctl/lib/libdaxctl.c +18 -57

111 lines not on this page · raw message

test/daxctl-devices.sh +5 -2
index e236854..00f4715 100755
@@ -21,8 +21,11 @@ find_testdev()
 	# The kmem driver is needed to change the device mode, only
 	# kernels >= v5.1 might have it available. Skip if not.
 	if ! modinfo kmem; then
-		printf "Unable to find kmem module\n"
-		exit $rc
+		# check if kmem is builtin
+		if ! grep -qF "kmem" "/lib/modules/$(uname -r)/modules.builtin"; then
+			printf "Unable to find kmem module\n"
+			exit $rc
+		fi
 	fi
 
 	# find a victim device
Signature · 1 line
2.20.1

A message that is not in the archive (sent off-list or not yet received): 20190905011314.18610-2-vishal.l.verma-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

Reviewed-by
#4 lore raw

Re: [ndctl PATCH v2 2/2] libdaxctl: fix device reconfiguration with builtin drivers

Quoted 28 lines · Vishal Verma

When the driver of a given reconfiguration mode is builtin, libdaxctl isn't able to build a module lookup list using kmod. However, it doesn't need to fail in this case, as it is acceptable for a driver to be builtin.

Indeed, since even with a modalias lookup list, we still have to resolve the target driver based on the mode using the module name, so relying on the modalias lookup to keep us impervious to module name changes is already flawed.

Simplify module loading greatly by removing the modalias lookups, and directly getting the module from a named lookup. This transparently fixes the problem when the driver may be builtin instead of being a module.

---

v2:
- Remove modalias lookup lists entirely, and perform a simple name based lookup (Dan)
- Fix the module expectation in the daxctl-devices unit test.

Quoted 4 lines
 daxctl/lib/libdaxctl-private.h |  1 -
 daxctl/lib/libdaxctl.c         | 75 ++++++++--------------------------
 test/daxctl-devices.sh         |  7 +++-
 3 files changed, 23 insertions(+), 60 deletions(-)

Mmm, that's nice.