diff mbox series

daxctl: Change region input type from INTEGER to STRING.

Message ID 2369E669066F8E42A79A3DF0E43B9E643AC9EB31@pgsmsx114.gar.corp.intel.com (mailing list archive)
State Superseded
Headers show
Series daxctl: Change region input type from INTEGER to STRING. | expand

Commit Message

Li, Redhairer Dec. 4, 2019, 2:33 a.m. UTC
Allow daxctl to accept both <region-id>, and region name as region parameter.
For example:

    daxctl list -r region5
    daxctl list -r 5

Link: https://github.com/pmem/ndctl/issues/109
Signed-off-by: Redhairer Li <redhairer.li@intel.com>
---
 daxctl/device.c | 11 ++++-------
 daxctl/list.c   | 14 ++++++--------
 util/filter.c   | 16 ++++++++++++++++
 util/filter.h   |  2 ++
 4 files changed, 28 insertions(+), 15 deletions(-)

Comments

Dan Williams Dec. 4, 2019, 2:42 a.m. UTC | #1
Nice! You got mail working!

On Tue, Dec 3, 2019 at 6:33 PM Li, Redhairer <redhairer.li@intel.com> wrote:
>
> Allow daxctl to accept both <region-id>, and region name as region parameter.
> For example:
>
>     daxctl list -r region5
>     daxctl list -r 5
>
> Link: https://github.com/pmem/ndctl/issues/109
> Signed-off-by: Redhairer Li <redhairer.li@intel.com>
> ---
>  daxctl/device.c | 11 ++++-------
>  daxctl/list.c   | 14 ++++++--------
>  util/filter.c   | 16 ++++++++++++++++
>  util/filter.h   |  2 ++
>  4 files changed, 28 insertions(+), 15 deletions(-)
>
> diff --git a/daxctl/device.c b/daxctl/device.c
> index 72e506e..d9db2f9 100644
> --- a/daxctl/device.c
> +++ b/daxctl/device.c
> @@ -19,15 +19,13 @@
>  static struct {
>         const char *dev;
>         const char *mode;
> -       int region_id;
> +       const char *region;
>         bool no_online;
>         bool no_movable;
>         bool force;
>         bool human;
>         bool verbose;
> -} param = {
> -       .region_id = -1,
> -};
> +} param;
>
>  enum dev_mode {
>         DAXCTL_DEV_MODE_UNKNOWN,
> @@ -51,7 +49,7 @@ enum device_action {
>  };
>
>  #define BASE_OPTIONS() \
> -OPT_INTEGER('r', "region", &param.region_id, "restrict to the given region"), \
> +OPT_STRING('r', "region", &param.region, "region-id", "filter by region"), \
>  OPT_BOOLEAN('u', "human", &param.human, "use human friendly number formats"), \
>  OPT_BOOLEAN('v', "verbose", &param.verbose, "emit more debug messages")
>
> @@ -484,8 +482,7 @@ static int do_xaction_device(const char *device, enum device_action action,
>         *processed = 0;
>
>         daxctl_region_foreach(ctx, region) {
> -               if (param.region_id >= 0 && param.region_id
> -                               != daxctl_region_get_id(region))
> +               if (!util_daxctl_region_filter(region, device))
>                         continue;

There's a bug here, can you spot it?

This causes:

     make TESTS=daxctl-devices.sh check

...to fail.
Li, Redhairer Dec. 25, 2019, 10:33 a.m. UTC | #2
Hi Dan,

I don't see any failure even apply my patch.
What failure do you observe?

make --no-print-directory check-TESTS
PASS: libndctl
PASS: dsm-fail
PASS: dpa-alloc
PASS: parent-uuid
PASS: multi-pmem
PASS: create.sh
PASS: clear.sh
PASS: pmem-errors.sh
PASS: daxdev-errors.sh
PASS: multi-dax.sh
PASS: btt-check.sh
PASS: label-compat.sh
PASS: blk-exhaust.sh
PASS: sector-mode.sh
PASS: inject-error.sh
PASS: btt-errors.sh
PASS: hugetlb
PASS: btt-pad-compat.sh
PASS: firmware-update.sh
PASS: ack-shutdown-count-set
PASS: rescan-partitions.sh
PASS: inject-smart.sh
PASS: monitor.sh
PASS: max_available_extent_ns.sh
PASS: pfn-meta-errors.sh
============================================================================
Testsuite summary for ndctl 67.dirty
============================================================================
# TOTAL: 25
# PASS:  25
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================

Thanks,

-----Original Message-----
From: Dan Williams <dan.j.williams@intel.com>
Sent: Wednesday, December 4, 2019 10:43 AM
To: Li, Redhairer <redhairer.li@intel.com>
Cc: linux-nvdimm@lists.01.org
Subject: Re: [PATCH] daxctl: Change region input type from INTEGER to STRING.

Nice! You got mail working!

On Tue, Dec 3, 2019 at 6:33 PM Li, Redhairer <redhairer.li@intel.com> wrote:
>
> Allow daxctl to accept both <region-id>, and region name as region parameter.
> For example:
>
>     daxctl list -r region5
>     daxctl list -r 5
>
> Link: https://github.com/pmem/ndctl/issues/109
> Signed-off-by: Redhairer Li <redhairer.li@intel.com>
> ---
>  daxctl/device.c | 11 ++++-------
>  daxctl/list.c   | 14 ++++++--------
>  util/filter.c   | 16 ++++++++++++++++
>  util/filter.h   |  2 ++
>  4 files changed, 28 insertions(+), 15 deletions(-)
>
> diff --git a/daxctl/device.c b/daxctl/device.c index 72e506e..d9db2f9
> 100644
> --- a/daxctl/device.c
> +++ b/daxctl/device.c
> @@ -19,15 +19,13 @@
>  static struct {
>         const char *dev;
>         const char *mode;
> -       int region_id;
> +       const char *region;
>         bool no_online;
>         bool no_movable;
>         bool force;
>         bool human;
>         bool verbose;
> -} param = {
> -       .region_id = -1,
> -};
> +} param;
>
>  enum dev_mode {
>         DAXCTL_DEV_MODE_UNKNOWN,
> @@ -51,7 +49,7 @@ enum device_action {  };
>
>  #define BASE_OPTIONS() \
> -OPT_INTEGER('r', "region", &param.region_id, "restrict to the given
> region"), \
> +OPT_STRING('r', "region", &param.region, "region-id", "filter by
> +region"), \
>  OPT_BOOLEAN('u', "human", &param.human, "use human friendly number
> formats"), \  OPT_BOOLEAN('v', "verbose", &param.verbose, "emit more
> debug messages")
>
> @@ -484,8 +482,7 @@ static int do_xaction_device(const char *device, enum device_action action,
>         *processed = 0;
>
>         daxctl_region_foreach(ctx, region) {
> -               if (param.region_id >= 0 && param.region_id
> -                               != daxctl_region_get_id(region))
> +               if (!util_daxctl_region_filter(region, device))
>                         continue;

There's a bug here, can you spot it?

This causes:

     make TESTS=daxctl-devices.sh check

...to fail.
Dan Williams Dec. 25, 2019, 9:18 p.m. UTC | #3
On Wed, Dec 25, 2019 at 2:33 AM Li, Redhairer <redhairer.li@intel.com> wrote:
>
> Hi Dan,
>
> I don't see any failure even apply my patch.
> What failure do you observe?

I see the failure in the daxctl-devices.sh unit test. That test and
others are included in the "destructive" set of unit tests. They are
classified "destructive" because they write to platform persistent
memory resources instead of the emulated nfit_test resources. You need
to pass "--enable-destructive" to the configure script at build time
to enable the destructive tests.
Li, Redhairer Dec. 26, 2019, 1:48 a.m. UTC | #4
I try "--enable-destructive".
But I always see the following msg when I run "make check" and "make TESTS=daxctl-devices.sh check".
Do I miss anything here?


/usr/bin/ld: blk_namespaces.o: undefined reference to symbol 'uuid_generate@@UUID_1.0'
//lib/x86_64-linux-gnu/libuuid.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:850: recipe for target 'blk-ns' failed
make[3]: *** [blk-ns] Error 1
Makefile:1477: recipe for target 'check-am' failed
make[2]: *** [check-am] Error 2
Makefile:785: recipe for target 'check-recursive' failed
make[1]: *** [check-recursive] Error 1
Makefile:1079: recipe for target 'check' failed
make: *** [check] Error 2

-----Original Message-----
From: Dan Williams <dan.j.williams@intel.com> 
Sent: Thursday, December 26, 2019 5:18 AM
To: Li, Redhairer <redhairer.li@intel.com>
Cc: linux-nvdimm@lists.01.org
Subject: Re: [PATCH] daxctl: Change region input type from INTEGER to STRING.

On Wed, Dec 25, 2019 at 2:33 AM Li, Redhairer <redhairer.li@intel.com> wrote:
>
> Hi Dan,
>
> I don't see any failure even apply my patch.
> What failure do you observe?

I see the failure in the daxctl-devices.sh unit test. That test and others are included in the "destructive" set of unit tests. They are classified "destructive" because they write to platform persistent memory resources instead of the emulated nfit_test resources. You need to pass "--enable-destructive" to the configure script at build time to enable the destructive tests.
Li, Redhairer Dec. 26, 2019, 2:22 a.m. UTC | #5
Build error is solved by following change.

diff --git a/test/Makefile.am b/test/Makefile.am
index 829146d..d764190 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -98,10 +98,10 @@ ack_shutdown_count_set_SOURCES =\
 ack_shutdown_count_set_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)

 blk_ns_SOURCES = blk_namespaces.c $(testcore)
-blk_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
+blk_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS) $(UUID_LIBS)

 pmem_ns_SOURCES = pmem_namespaces.c $(testcore)
-pmem_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
+pmem_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS) $(UUID_LIBS)

 dpa_alloc_SOURCES = dpa-alloc.c $(testcore)
 dpa_alloc_LDADD = $(LIBNDCTL_LIB) $(UUID_LIBS) $(KMOD_LIBS)
@@ -143,6 +143,7 @@ device_dax_LDADD = \
                $(LIBNDCTL_LIB) \
                $(KMOD_LIBS) \
                $(JSON_LIBS) \
+               $(UUID_LIBS) \
                ../libutil.a

 smart_notify_SOURCES = smart-notify.c


-----Original Message-----
From: Li, Redhairer 
Sent: Thursday, December 26, 2019 9:48 AM
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm@lists.01.org
Subject: RE: [PATCH] daxctl: Change region input type from INTEGER to STRING.

I try "--enable-destructive".
But I always see the following msg when I run "make check" and "make TESTS=daxctl-devices.sh check".
Do I miss anything here?


/usr/bin/ld: blk_namespaces.o: undefined reference to symbol 'uuid_generate@@UUID_1.0'
//lib/x86_64-linux-gnu/libuuid.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:850: recipe for target 'blk-ns' failed
make[3]: *** [blk-ns] Error 1
Makefile:1477: recipe for target 'check-am' failed
make[2]: *** [check-am] Error 2
Makefile:785: recipe for target 'check-recursive' failed
make[1]: *** [check-recursive] Error 1
Makefile:1079: recipe for target 'check' failed
make: *** [check] Error 2

-----Original Message-----
From: Dan Williams <dan.j.williams@intel.com> 
Sent: Thursday, December 26, 2019 5:18 AM
To: Li, Redhairer <redhairer.li@intel.com>
Cc: linux-nvdimm@lists.01.org
Subject: Re: [PATCH] daxctl: Change region input type from INTEGER to STRING.

On Wed, Dec 25, 2019 at 2:33 AM Li, Redhairer <redhairer.li@intel.com> wrote:
>
> Hi Dan,
>
> I don't see any failure even apply my patch.
> What failure do you observe?

I see the failure in the daxctl-devices.sh unit test. That test and others are included in the "destructive" set of unit tests. They are classified "destructive" because they write to platform persistent memory resources instead of the emulated nfit_test resources. You need to pass "--enable-destructive" to the configure script at build time to enable the destructive tests.
Li, Redhairer Dec. 26, 2019, 4:01 a.m. UTC | #6
I saw daxctl-devices.sh is still failed before I apply my patch.

root@ubuntu-red:~/git/ndctl# vi test/test-suite.log
=========================================
   ndctl 67.dirty: test/test-suite.log
=========================================

# TOTAL: 1
# PASS:  0
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: daxctl-devices.sh
=======================

+ rc=77
+ . ./common
++ '[' -f ../ndctl/ndctl ']'
++ '[' -x ../ndctl/ndctl ']'
++ export NDCTL=../ndctl/ndctl
++ NDCTL=../ndctl/ndctl
++ '[' -f ../daxctl/daxctl ']'
++ '[' -x ../daxctl/daxctl ']'
++ export DAXCTL=../daxctl/daxctl
++ DAXCTL=../daxctl/daxctl
++ NFIT_TEST_BUS0=nfit_test.0
++ NFIT_TEST_BUS1=nfit_test.1
++ ACPI_BUS=ACPI.NFIT
++ E820_BUS=e820
+ trap 'cleanup $LINENO' ERR
+ find_testdev
+ local rc=77
+ modinfo kmem
filename:       /lib/modules/5.4.0-rc5_red_ndctltest_VM/kernel/drivers/dax/kmem.ko
alias:          dax:t0*
license:        GPL v2
author:         Intel Corporation
srcversion:     A0712EA9D9E63723E6B4CDA
depends:
retpoline:      Y
intree:         Y
name:           kmem
vermagic:       5.4.0-rc5_red_ndctltest_VM SMP mod_unload
signat:         PKCS#7
signer:
sig_key:
sig_hashalgo:   md4
+ testbus=ACPI.NFIT
++ ../ndctl/ndctl list -b ACPI.NFIT -Ni
++ jq -er '.[0].dev | .//""'
+ testdev=namespace0.0
+ [[ ! -n namespace0.0 ]]
+ printf 'Found victim dev: %s on bus: %s\n' namespace0.0 ACPI.NFIT
Found victim dev: namespace0.0 on bus: ACPI.NFIT
+ setup_dev
+ test -n ACPI.NFIT
+ test -n namespace0.0
+ ../ndctl/ndctl destroy-namespace -f -b ACPI.NFIT namespace0.0
destroyed 1 namespace
++ ../ndctl/ndctl create-namespace -b ACPI.NFIT -m devdax -fe namespace0.0 -s 256M
++ jq -er .dev
+ testdev=namespace0.0
+ test -n namespace0.0
+ rc=1
+ daxctl_test
+ local daxdev
++ daxctl_get_dev namespace0.0
++ ../ndctl/ndctl list -n namespace0.0 -X
++ jq -er '.[].daxregion.devices[0].chardev'
+ daxdev=dax0.0
+ test -n dax0.0
+ ../daxctl/daxctl reconfigure-device -N -m system-ram dax0.0
libdaxctl: daxctl_dev_disable: dax0.0: error: device model is dax-class
libdaxctl: daxctl_dev_disable: dax0.0: see man daxctl-migrate-device-model
dax0.0: disable failed: Operation not supported
error reconfiguring devices: Operation not supported
reconfigured 0 devices
++ cleanup 74
++ printf 'Error at line %d\n' 74
Error at line 74
++ [[ -n namespace0.0 ]]
++ reset_dev
++ ../ndctl/ndctl destroy-namespace -f -b ACPI.NFIT namespace0.0
destroyed 1 namespace
++ exit 1
FAIL daxctl-devices.sh (exit status: 1)

-----Original Message-----
From: Li, Redhairer 
Sent: Thursday, December 26, 2019 10:23 AM
To: 'Dan Williams' <dan.j.williams@intel.com>
Cc: 'linux-nvdimm@lists.01.org' <linux-nvdimm@lists.01.org>
Subject: RE: [PATCH] daxctl: Change region input type from INTEGER to STRING.



Build error is solved by following change.

diff --git a/test/Makefile.am b/test/Makefile.am index 829146d..d764190 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -98,10 +98,10 @@ ack_shutdown_count_set_SOURCES =\  ack_shutdown_count_set_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)

 blk_ns_SOURCES = blk_namespaces.c $(testcore) -blk_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
+blk_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS) $(UUID_LIBS)

 pmem_ns_SOURCES = pmem_namespaces.c $(testcore) -pmem_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
+pmem_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS) $(UUID_LIBS)

 dpa_alloc_SOURCES = dpa-alloc.c $(testcore)  dpa_alloc_LDADD = $(LIBNDCTL_LIB) $(UUID_LIBS) $(KMOD_LIBS) @@ -143,6 +143,7 @@ device_dax_LDADD = \
                $(LIBNDCTL_LIB) \
                $(KMOD_LIBS) \
                $(JSON_LIBS) \
+               $(UUID_LIBS) \
                ../libutil.a

 smart_notify_SOURCES = smart-notify.c


-----Original Message-----
From: Li, Redhairer
Sent: Thursday, December 26, 2019 9:48 AM
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm@lists.01.org
Subject: RE: [PATCH] daxctl: Change region input type from INTEGER to STRING.

I try "--enable-destructive".
But I always see the following msg when I run "make check" and "make TESTS=daxctl-devices.sh check".
Do I miss anything here?


/usr/bin/ld: blk_namespaces.o: undefined reference to symbol 'uuid_generate@@UUID_1.0'
//lib/x86_64-linux-gnu/libuuid.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:850: recipe for target 'blk-ns' failed
make[3]: *** [blk-ns] Error 1
Makefile:1477: recipe for target 'check-am' failed
make[2]: *** [check-am] Error 2
Makefile:785: recipe for target 'check-recursive' failed
make[1]: *** [check-recursive] Error 1
Makefile:1079: recipe for target 'check' failed
make: *** [check] Error 2

-----Original Message-----
From: Dan Williams <dan.j.williams@intel.com>
Sent: Thursday, December 26, 2019 5:18 AM
To: Li, Redhairer <redhairer.li@intel.com>
Cc: linux-nvdimm@lists.01.org
Subject: Re: [PATCH] daxctl: Change region input type from INTEGER to STRING.

On Wed, Dec 25, 2019 at 2:33 AM Li, Redhairer <redhairer.li@intel.com> wrote:
>
> Hi Dan,
>
> I don't see any failure even apply my patch.
> What failure do you observe?

I see the failure in the daxctl-devices.sh unit test. That test and others are included in the "destructive" set of unit tests. They are classified "destructive" because they write to platform persistent memory resources instead of the emulated nfit_test resources. You need to pass "--enable-destructive" to the configure script at build time to enable the destructive tests.
Dan Williams Dec. 26, 2019, 5:48 p.m. UTC | #7
On Wed, Dec 25, 2019 at 6:22 PM Li, Redhairer <redhairer.li@intel.com> wrote:
>
>
>
> Build error is solved by following change.
>
> diff --git a/test/Makefile.am b/test/Makefile.am
> index 829146d..d764190 100644
> --- a/test/Makefile.am
> +++ b/test/Makefile.am
> @@ -98,10 +98,10 @@ ack_shutdown_count_set_SOURCES =\
>  ack_shutdown_count_set_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
>
>  blk_ns_SOURCES = blk_namespaces.c $(testcore)
> -blk_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
> +blk_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS) $(UUID_LIBS)
>
>  pmem_ns_SOURCES = pmem_namespaces.c $(testcore)
> -pmem_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
> +pmem_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS) $(UUID_LIBS)
>
>  dpa_alloc_SOURCES = dpa-alloc.c $(testcore)
>  dpa_alloc_LDADD = $(LIBNDCTL_LIB) $(UUID_LIBS) $(KMOD_LIBS)
> @@ -143,6 +143,7 @@ device_dax_LDADD = \
>                 $(LIBNDCTL_LIB) \
>                 $(KMOD_LIBS) \
>                 $(JSON_LIBS) \
> +               $(UUID_LIBS) \
>                 ../libutil.a

Ah, sorry about that.

Hmm, are you running this on top of Ubuntu?

We have had a long standing problem whereby Fedora autoincludes some
library dependencies and Ubuntu does not.

    011fc692270b ndctl, test: add UUID_LIBS for list_smart_dimm

Please send this as a formal fix patch.
Dan Williams Dec. 26, 2019, 5:54 p.m. UTC | #8
The way to fix this is mentioned in the log, see below...

On Wed, Dec 25, 2019 at 8:01 PM Li, Redhairer <redhairer.li@intel.com> wrote:
>
> I saw daxctl-devices.sh is still failed before I apply my patch.
>
> root@ubuntu-red:~/git/ndctl# vi test/test-suite.log
> =========================================
>    ndctl 67.dirty: test/test-suite.log
> =========================================
>
> # TOTAL: 1
> # PASS:  0
> # SKIP:  0
> # XFAIL: 0
> # FAIL:  1
> # XPASS: 0
> # ERROR: 0
>
> .. contents:: :depth: 2
>
> FAIL: daxctl-devices.sh
> =======================
>
> + rc=77
> + . ./common
> ++ '[' -f ../ndctl/ndctl ']'
> ++ '[' -x ../ndctl/ndctl ']'
> ++ export NDCTL=../ndctl/ndctl
> ++ NDCTL=../ndctl/ndctl
> ++ '[' -f ../daxctl/daxctl ']'
> ++ '[' -x ../daxctl/daxctl ']'
> ++ export DAXCTL=../daxctl/daxctl
> ++ DAXCTL=../daxctl/daxctl
> ++ NFIT_TEST_BUS0=nfit_test.0
> ++ NFIT_TEST_BUS1=nfit_test.1
> ++ ACPI_BUS=ACPI.NFIT
> ++ E820_BUS=e820
> + trap 'cleanup $LINENO' ERR
> + find_testdev
> + local rc=77
> + modinfo kmem
> filename:       /lib/modules/5.4.0-rc5_red_ndctltest_VM/kernel/drivers/dax/kmem.ko
> alias:          dax:t0*
> license:        GPL v2
> author:         Intel Corporation
> srcversion:     A0712EA9D9E63723E6B4CDA
> depends:
> retpoline:      Y
> intree:         Y
> name:           kmem
> vermagic:       5.4.0-rc5_red_ndctltest_VM SMP mod_unload
> signat:         PKCS#7
> signer:
> sig_key:
> sig_hashalgo:   md4
> + testbus=ACPI.NFIT
> ++ ../ndctl/ndctl list -b ACPI.NFIT -Ni
> ++ jq -er '.[0].dev | .//""'
> + testdev=namespace0.0
> + [[ ! -n namespace0.0 ]]
> + printf 'Found victim dev: %s on bus: %s\n' namespace0.0 ACPI.NFIT
> Found victim dev: namespace0.0 on bus: ACPI.NFIT
> + setup_dev
> + test -n ACPI.NFIT
> + test -n namespace0.0
> + ../ndctl/ndctl destroy-namespace -f -b ACPI.NFIT namespace0.0
> destroyed 1 namespace
> ++ ../ndctl/ndctl create-namespace -b ACPI.NFIT -m devdax -fe namespace0.0 -s 256M
> ++ jq -er .dev
> + testdev=namespace0.0
> + test -n namespace0.0
> + rc=1
> + daxctl_test
> + local daxdev
> ++ daxctl_get_dev namespace0.0
> ++ ../ndctl/ndctl list -n namespace0.0 -X
> ++ jq -er '.[].daxregion.devices[0].chardev'
> + daxdev=dax0.0
> + test -n dax0.0
> + ../daxctl/daxctl reconfigure-device -N -m system-ram dax0.0
> libdaxctl: daxctl_dev_disable: dax0.0: error: device model is dax-class
> libdaxctl: daxctl_dev_disable: dax0.0: see man daxctl-migrate-device-model

If you run:

    daxctl migrate-device-model

...and reboot the test should start working. The explanation for why
this migrate-device-model step is needed is detailed in the man page.

    daxctl migrate-device-model --help
Li, Redhairer Dec. 28, 2019, 3:08 a.m. UTC | #9
Yes, I am running this on ubuntu.
And I will sent it as a formal fix patch later.

-----Original Message-----
From: Dan Williams <dan.j.williams@intel.com> 
Sent: Friday, December 27, 2019 1:49 AM
To: Li, Redhairer <redhairer.li@intel.com>
Cc: linux-nvdimm@lists.01.org
Subject: Re: [PATCH] daxctl: Change region input type from INTEGER to STRING.

On Wed, Dec 25, 2019 at 6:22 PM Li, Redhairer <redhairer.li@intel.com> wrote:
>
>
>
> Build error is solved by following change.
>
> diff --git a/test/Makefile.am b/test/Makefile.am index 
> 829146d..d764190 100644
> --- a/test/Makefile.am
> +++ b/test/Makefile.am
> @@ -98,10 +98,10 @@ ack_shutdown_count_set_SOURCES =\  
> ack_shutdown_count_set_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
>
>  blk_ns_SOURCES = blk_namespaces.c $(testcore) -blk_ns_LDADD = 
> $(LIBNDCTL_LIB) $(KMOD_LIBS)
> +blk_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS) $(UUID_LIBS)
>
>  pmem_ns_SOURCES = pmem_namespaces.c $(testcore) -pmem_ns_LDADD = 
> $(LIBNDCTL_LIB) $(KMOD_LIBS)
> +pmem_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS) $(UUID_LIBS)
>
>  dpa_alloc_SOURCES = dpa-alloc.c $(testcore)  dpa_alloc_LDADD = 
> $(LIBNDCTL_LIB) $(UUID_LIBS) $(KMOD_LIBS) @@ -143,6 +143,7 @@ 
> device_dax_LDADD = \
>                 $(LIBNDCTL_LIB) \
>                 $(KMOD_LIBS) \
>                 $(JSON_LIBS) \
> +               $(UUID_LIBS) \
>                 ../libutil.a

Ah, sorry about that.

Hmm, are you running this on top of Ubuntu?

We have had a long standing problem whereby Fedora autoincludes some library dependencies and Ubuntu does not.

    011fc692270b ndctl, test: add UUID_LIBS for list_smart_dimm

Please send this as a formal fix patch.
Li, Redhairer Dec. 29, 2019, 7:54 a.m. UTC | #10
OK, got it.
I have figured out the problem.
I pass wrong parameter to util_daxctl_region_filter.

But I found two other problems before I apply my patch.

1. DAX device already online after reconfigure it to system-ram.

"$DAXCTL" reconfigure-device -N -m system-ram "$daxdev"

If daxctl-device.sh do online-memory again,
it makes FAIL daxctl-devices.sh (exit status: 1) even I add --no-online when reconfigure-device

+ ../daxctl/daxctl reconfigure-device -N -m system-ram --no-online dax0.0
libdaxctl: memblock_in_dev: dax0.0: memory0: Unable to determine phys_index: Success
reconfigured 1 device
[
  {
    "chardev":"dax0.0",
    "size":262144000,
    "target_node":0,
    "mode":"system-ram",
    "movable":false
  }
]
++ daxctl_get_mode dax0.0
++ ../daxctl/daxctl list -d dax0.0
++ jq -er '.[].mode'
libdaxctl: memblock_in_dev: dax0.0: memory0: Unable to determine phys_index: Success
+ [[ system-ram == \s\y\s\t\e\m\-\r\a\m ]]
+ ../daxctl/daxctl online-memory dax0.0
libdaxctl: memblock_in_dev: dax0.0: memory0: Unable to determine phys_index: Success
libdaxctl: memblock_in_dev: dax0.0: memory0: Unable to determine phys_index: Success
dax0.0:
  WARNING: detected a race while onlining memory
  Some memory may not be in the expected zone. It is
  recommended to disable any other onlining mechanisms,
  and retry. If onlining is to be left to other agents,
  use the --no-online option to suppress this warning
dax0.0: all memory sections (1) already online
onlined memory for 0 devices
++ cleanup 76
++ printf 'Error at line %d\n' 76
Error at line 76
++ [[ -n namespace0.0 ]]
++ reset_dev
++ ../ndctl/ndctl destroy-namespace -f -b ACPI.NFIT namespace0.0
libndctl: ndctl_namespace_enable: namespace0.0: failed to enable
destroyed 1 namespace
++ exit 1
FAIL daxctl-devices.sh (exit status: 1)


2.  2 nvdimm will make daxctl-devices.sh FAIL
+ testbus=ACPI.NFIT
++ ../ndctl/ndctl list -b ACPI.NFIT -Ni
++ jq -er '.[0].dev | .//""'
+ testdev=namespace1.0
+ [[ ! -n namespace1.0 ]]
+ printf 'Found victim dev: %s on bus: %s\n' namespace1.0 ACPI.NFIT
Found victim dev: namespace1.0 on bus: ACPI.NFIT
+ setup_dev
+ test -n ACPI.NFIT
+ test -n namespace1.0
+ ../ndctl/ndctl destroy-namespace -f -b ACPI.NFIT namespace1.0
destroyed 1 namespace
++ ../ndctl/ndctl create-namespace -b ACPI.NFIT -m devdax -fe namespace1.0 -s 256M
++ jq -er .dev
+ testdev=namespace1.0
+ test -n namespace1.0
+ rc=1
+ daxctl_test
+ local daxdev
++ daxctl_get_dev namespace1.0
++ ../ndctl/ndctl list -n namespace1.0 -X
++ jq -er '.[].daxregion.devices[0].chardev'
+ daxdev=dax1.0
+ test -n dax1.0
+ ../daxctl/daxctl reconfigure-device -N -m system-ram dax1.0
libdaxctl: daxctl_dev_enable: dax1.0: failed to enable
error reconfiguring devices: No such device
reconfigured 0 devices
++ cleanup 74
++ printf 'Error at line %d\n' 74
Error at line 74
++ [[ -n namespace1.0 ]]
++ reset_dev
++ ../ndctl/ndctl destroy-namespace -f -b ACPI.NFIT namespace1.0
destroyed 1 namespace
++ exit 1
FAIL daxctl-devices.sh (exit status: 1)

-----Original Message-----
From: Dan Williams <dan.j.williams@intel.com> 
Sent: Friday, December 27, 2019 1:54 AM
To: Li, Redhairer <redhairer.li@intel.com>
Cc: linux-nvdimm@lists.01.org
Subject: Re: [PATCH] daxctl: Change region input type from INTEGER to STRING.

The way to fix this is mentioned in the log, see below...

On Wed, Dec 25, 2019 at 8:01 PM Li, Redhairer <redhairer.li@intel.com> wrote:
>
> I saw daxctl-devices.sh is still failed before I apply my patch.
>
> root@ubuntu-red:~/git/ndctl# vi test/test-suite.log 
> =========================================
>    ndctl 67.dirty: test/test-suite.log 
> =========================================
>
> # TOTAL: 1
> # PASS:  0
> # SKIP:  0
> # XFAIL: 0
> # FAIL:  1
> # XPASS: 0
> # ERROR: 0
>
> .. contents:: :depth: 2
>
> FAIL: daxctl-devices.sh
> =======================
>
> + rc=77
> + . ./common
> ++ '[' -f ../ndctl/ndctl ']'
> ++ '[' -x ../ndctl/ndctl ']'
> ++ export NDCTL=../ndctl/ndctl
> ++ NDCTL=../ndctl/ndctl
> ++ '[' -f ../daxctl/daxctl ']'
> ++ '[' -x ../daxctl/daxctl ']'
> ++ export DAXCTL=../daxctl/daxctl
> ++ DAXCTL=../daxctl/daxctl
> ++ NFIT_TEST_BUS0=nfit_test.0
> ++ NFIT_TEST_BUS1=nfit_test.1
> ++ ACPI_BUS=ACPI.NFIT
> ++ E820_BUS=e820
> + trap 'cleanup $LINENO' ERR
> + find_testdev
> + local rc=77
> + modinfo kmem
> filename:       /lib/modules/5.4.0-rc5_red_ndctltest_VM/kernel/drivers/dax/kmem.ko
> alias:          dax:t0*
> license:        GPL v2
> author:         Intel Corporation
> srcversion:     A0712EA9D9E63723E6B4CDA
> depends:
> retpoline:      Y
> intree:         Y
> name:           kmem
> vermagic:       5.4.0-rc5_red_ndctltest_VM SMP mod_unload
> signat:         PKCS#7
> signer:
> sig_key:
> sig_hashalgo:   md4
> + testbus=ACPI.NFIT
> ++ ../ndctl/ndctl list -b ACPI.NFIT -Ni jq -er '.[0].dev | .//""'
> + testdev=namespace0.0
> + [[ ! -n namespace0.0 ]]
> + printf 'Found victim dev: %s on bus: %s\n' namespace0.0 ACPI.NFIT
> Found victim dev: namespace0.0 on bus: ACPI.NFIT
> + setup_dev
> + test -n ACPI.NFIT
> + test -n namespace0.0
> + ../ndctl/ndctl destroy-namespace -f -b ACPI.NFIT namespace0.0
> destroyed 1 namespace
> ++ ../ndctl/ndctl create-namespace -b ACPI.NFIT -m devdax -fe 
> ++ namespace0.0 -s 256M jq -er .dev
> + testdev=namespace0.0
> + test -n namespace0.0
> + rc=1
> + daxctl_test
> + local daxdev
> ++ daxctl_get_dev namespace0.0
> ++ ../ndctl/ndctl list -n namespace0.0 -X jq -er 
> ++ '.[].daxregion.devices[0].chardev'
> + daxdev=dax0.0
> + test -n dax0.0
> + ../daxctl/daxctl reconfigure-device -N -m system-ram dax0.0
> libdaxctl: daxctl_dev_disable: dax0.0: error: device model is 
> dax-class
> libdaxctl: daxctl_dev_disable: dax0.0: see man 
> daxctl-migrate-device-model

If you run:

    daxctl migrate-device-model

...and reboot the test should start working. The explanation for why this migrate-device-model step is needed is detailed in the man page.

    daxctl migrate-device-model --help
Dan Williams Dec. 30, 2019, 6:02 a.m. UTC | #11
On Sat, Dec 28, 2019 at 11:54 PM Li, Redhairer <redhairer.li@intel.com> wrote:
>
> OK, got it.
> I have figured out the problem.
> I pass wrong parameter to util_daxctl_region_filter.
>
> But I found two other problems before I apply my patch.
>
> 1. DAX device already online after reconfigure it to system-ram.
>
> "$DAXCTL" reconfigure-device -N -m system-ram "$daxdev"
>
> If daxctl-device.sh do online-memory again,
> it makes FAIL daxctl-devices.sh (exit status: 1) even I add --no-online when reconfigure-device
>
> + ../daxctl/daxctl reconfigure-device -N -m system-ram --no-online dax0.0
> libdaxctl: memblock_in_dev: dax0.0: memory0: Unable to determine phys_index: Success
> reconfigured 1 device
> [
>   {
>     "chardev":"dax0.0",
>     "size":262144000,
>     "target_node":0,
>     "mode":"system-ram",
>     "movable":false
>   }
> ]
> ++ daxctl_get_mode dax0.0
> ++ ../daxctl/daxctl list -d dax0.0
> ++ jq -er '.[].mode'
> libdaxctl: memblock_in_dev: dax0.0: memory0: Unable to determine phys_index: Success
> + [[ system-ram == \s\y\s\t\e\m\-\r\a\m ]]
> + ../daxctl/daxctl online-memory dax0.0
> libdaxctl: memblock_in_dev: dax0.0: memory0: Unable to determine phys_index: Success
> libdaxctl: memblock_in_dev: dax0.0: memory0: Unable to determine phys_index: Success
> dax0.0:
>   WARNING: detected a race while onlining memory
>   Some memory may not be in the expected zone. It is
>   recommended to disable any other onlining mechanisms,
>   and retry. If onlining is to be left to other agents,
>   use the --no-online option to suppress this warning

This is likely because Ubuntu ships a udev rule that automatically
onlines hot-added memory. We've talked about a way to auto-detect when
a distribution ships a udev configuration like this, but for now this
warning message is the best we can do.

[..]>
> 2.  2 nvdimm will make daxctl-devices.sh FAIL

Do you mean a system with real nvdimms makes daxctl-devices.sh fail?
Li, Redhairer Jan. 1, 2020, 1:36 p.m. UTC | #12
> 2.  2 nvdimm will make daxctl-devices.sh FAIL

Do you mean a system with real nvdimms makes daxctl-devices.sh fail?
=>
No, I mean daxctl-devices.sh FAIL happen if I have mem1(nv1) and mem2(nv2) with following cmd.
If ONLY have mem1(nv1), daxctl-devices.sh will PASS.

qemu-system-x86_64 /root/vm/ubuntu-red_ndctltest_VM.img \
-m 16G,slots=4,maxmem=512G \
-smp 40 \
-machine pc,accel=kvm,nvdimm=on \
-enable-kvm \
-cpu kvm64 \
-object memory-backend-file,id=mem1,share,mem-path=/root/vm/tmp/nvdimm0,size=2G \
-device nvdimm,memdev=mem1,id=nv1,label-size=2M \
-object memory-backend-file,id=mem2,share,mem-path=/root/vm/tmp/nvdimm1,size=2G \
-device nvdimm,memdev=mem2,id=nv2,label-size=2M \
-numa node,mem=4G,cpus=0-19,nodeid=0 \
-numa node,mem=4G,cpus=20-39,nodeid=1 \
-numa node,mem=4G,nodeid=2 \
-numa node,mem=4G,nodeid=3 \

-----Original Message-----
From: Dan Williams <dan.j.williams@intel.com> 
Sent: Monday, December 30, 2019 2:03 PM
To: Li, Redhairer <redhairer.li@intel.com>
Cc: linux-nvdimm@lists.01.org
Subject: Re: [PATCH] daxctl: Change region input type from INTEGER to STRING.

On Sat, Dec 28, 2019 at 11:54 PM Li, Redhairer <redhairer.li@intel.com> wrote:
>
> OK, got it.
> I have figured out the problem.
> I pass wrong parameter to util_daxctl_region_filter.
>
> But I found two other problems before I apply my patch.
>
> 1. DAX device already online after reconfigure it to system-ram.
>
> "$DAXCTL" reconfigure-device -N -m system-ram "$daxdev"
>
> If daxctl-device.sh do online-memory again, it makes FAIL 
> daxctl-devices.sh (exit status: 1) even I add --no-online when 
> reconfigure-device
>
> + ../daxctl/daxctl reconfigure-device -N -m system-ram --no-online 
> + dax0.0
> libdaxctl: memblock_in_dev: dax0.0: memory0: Unable to determine 
> phys_index: Success reconfigured 1 device [
>   {
>     "chardev":"dax0.0",
>     "size":262144000,
>     "target_node":0,
>     "mode":"system-ram",
>     "movable":false
>   }
> ]
> ++ daxctl_get_mode dax0.0
> ++ ../daxctl/daxctl list -d dax0.0
> ++ jq -er '.[].mode'
> libdaxctl: memblock_in_dev: dax0.0: memory0: Unable to determine 
> phys_index: Success
> + [[ system-ram == \s\y\s\t\e\m\-\r\a\m ]] ../daxctl/daxctl 
> + online-memory dax0.0
> libdaxctl: memblock_in_dev: dax0.0: memory0: Unable to determine 
> phys_index: Success
> libdaxctl: memblock_in_dev: dax0.0: memory0: Unable to determine 
> phys_index: Success
> dax0.0:
>   WARNING: detected a race while onlining memory
>   Some memory may not be in the expected zone. It is
>   recommended to disable any other onlining mechanisms,
>   and retry. If onlining is to be left to other agents,
>   use the --no-online option to suppress this warning

This is likely because Ubuntu ships a udev rule that automatically onlines hot-added memory. We've talked about a way to auto-detect when a distribution ships a udev configuration like this, but for now this warning message is the best we can do.

[..]>
> 2.  2 nvdimm will make daxctl-devices.sh FAIL

Do you mean a system with real nvdimms makes daxctl-devices.sh fail?
diff mbox series

Patch

diff --git a/daxctl/device.c b/daxctl/device.c
index 72e506e..d9db2f9 100644
--- a/daxctl/device.c
+++ b/daxctl/device.c
@@ -19,15 +19,13 @@ 
 static struct {
 	const char *dev;
 	const char *mode;
-	int region_id;
+	const char *region;
 	bool no_online;
 	bool no_movable;
 	bool force;
 	bool human;
 	bool verbose;
-} param = {
-	.region_id = -1,
-};
+} param;
 
 enum dev_mode {
 	DAXCTL_DEV_MODE_UNKNOWN,
@@ -51,7 +49,7 @@  enum device_action {
 };
 
 #define BASE_OPTIONS() \
-OPT_INTEGER('r', "region", &param.region_id, "restrict to the given region"), \
+OPT_STRING('r', "region", &param.region, "region-id", "filter by region"), \
 OPT_BOOLEAN('u', "human", &param.human, "use human friendly number formats"), \
 OPT_BOOLEAN('v', "verbose", &param.verbose, "emit more debug messages")
 
@@ -484,8 +482,7 @@  static int do_xaction_device(const char *device, enum device_action action,
 	*processed = 0;
 
 	daxctl_region_foreach(ctx, region) {
-		if (param.region_id >= 0 && param.region_id
-				!= daxctl_region_get_id(region))
+		if (!util_daxctl_region_filter(region, device))
 			continue;
 
 		daxctl_dev_foreach(region, dev) {
diff --git a/daxctl/list.c b/daxctl/list.c
index e56300d..6c6251b 100644
--- a/daxctl/list.c
+++ b/daxctl/list.c
@@ -44,10 +44,8 @@  static unsigned long listopts_to_flags(void)
 
 static struct {
 	const char *dev;
-	int region_id;
-} param = {
-	.region_id = -1,
-};
+	const char *region;
+} param;
 
 static int did_fail;
 
@@ -66,7 +64,8 @@  static int num_list_flags(void)
 int cmd_list(int argc, const char **argv, struct daxctl_ctx *ctx)
 {
 	const struct option options[] = {
-		OPT_INTEGER('r', "region", &param.region_id, "filter by region"),
+		OPT_STRING('r', "region", &param.region, "region-id",
+				"filter by region"),
 		OPT_STRING('d', "dev", &param.dev, "dev-id",
 				"filter by dax device instance name"),
 		OPT_BOOLEAN('D', "devices", &list.devs, "include dax device info"),
@@ -94,7 +93,7 @@  int cmd_list(int argc, const char **argv, struct daxctl_ctx *ctx)
 		usage_with_options(u, options);
 
 	if (num_list_flags() == 0) {
-		list.regions = param.region_id >= 0;
+		list.regions = !!param.region;
 		list.devs = !!param.dev;
 	}
 
@@ -106,8 +105,7 @@  int cmd_list(int argc, const char **argv, struct daxctl_ctx *ctx)
 	daxctl_region_foreach(ctx, region) {
 		struct json_object *jregion = NULL;
 
-		if (param.region_id >= 0 && param.region_id
-				!= daxctl_region_get_id(region))
+		if (!util_daxctl_region_filter(region, param.region))
 			continue;
 
 		if (list.regions) {
diff --git a/util/filter.c b/util/filter.c
index 1734bce..877d6c7 100644
--- a/util/filter.c
+++ b/util/filter.c
@@ -335,6 +335,22 @@  struct daxctl_dev *util_daxctl_dev_filter(struct daxctl_dev *dev,
 	return NULL;
 }
 
+struct daxctl_region *util_daxctl_region_filter(struct daxctl_region *region,
+		const char *ident)
+{
+	int region_id;
+
+	if (!ident || strcmp(ident, "all") == 0)
+		return region;
+
+	if ((sscanf(ident, "%d", &region_id) == 1
+       || sscanf(ident, "region%d", &region_id) == 1)
+			&& daxctl_region_get_id(region) == region_id)
+		return region;
+
+	return NULL;
+}
+
 static enum ndctl_namespace_mode mode_to_type(const char *mode)
 {
 	if (!mode)
diff --git a/util/filter.h b/util/filter.h
index c2cdddf..0c12b94 100644
--- a/util/filter.h
+++ b/util/filter.h
@@ -37,6 +37,8 @@  struct ndctl_region *util_region_filter_by_namespace(struct ndctl_region *region
 		const char *ident);
 struct daxctl_dev *util_daxctl_dev_filter(struct daxctl_dev *dev,
 		const char *ident);
+struct daxctl_region *util_daxctl_region_filter(struct daxctl_region *region,
+		const char *ident);
 
 struct json_object;