diff mbox series

daxctl: phys_index value 0 is valid

Message ID 20201020052704.331557-1-aneesh.kumar@linux.ibm.com (mailing list archive)
State Accepted
Commit c7d6e4e94e45d686318f3a0cd3cd4cb00b87bd5d
Headers show
Series daxctl: phys_index value 0 is valid | expand

Commit Message

Aneesh Kumar K.V Oct. 20, 2020, 5:27 a.m. UTC
On power platforms we can find
 # cat /sys/devices/system/memory/memory0/phys_index
00000000

This results in

libdaxctl: memblock_in_dev: dax1.0: memory0: Unable to determine phys_index: Success

Avoid considering phys_index == 0 as error.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
 daxctl/lib/libdaxctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Aneesh Kumar K.V Nov. 9, 2020, 5:11 a.m. UTC | #1
Hi All,

"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> writes:

> On power platforms we can find
>  # cat /sys/devices/system/memory/memory0/phys_index
> 00000000
>
> This results in
>
> libdaxctl: memblock_in_dev: dax1.0: memory0: Unable to determine phys_index: Success
>
> Avoid considering phys_index == 0 as error.


 A gentle ping for this patch. Will appreciate a feedback on this

>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> ---
>  daxctl/lib/libdaxctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
> index ee4a069eb463..3cb89c755978 100644
> --- a/daxctl/lib/libdaxctl.c
> +++ b/daxctl/lib/libdaxctl.c
> @@ -1229,7 +1229,7 @@ static int memblock_in_dev(struct daxctl_memory *mem, const char *memblock)
>  	rc = sysfs_read_attr(ctx, path, buf);
>  	if (rc == 0) {
>  		phys_index = strtoul(buf, NULL, 16);
> -		if (phys_index == 0 || phys_index == ULONG_MAX) {
> +		if (phys_index == ULONG_MAX) {
>  			rc = -errno;
>  			err(ctx, "%s: %s: Unable to determine phys_index: %s\n",
>  				devname, memblock, strerror(-rc));
> -- 
> 2.26.2
Dan Williams Nov. 9, 2020, 7:08 p.m. UTC | #2
On Sun, Nov 8, 2020 at 9:11 PM Aneesh Kumar K.V
<aneesh.kumar@linux.ibm.com> wrote:
>
>
> Hi All,
>
> "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> writes:
>
> > On power platforms we can find
> >  # cat /sys/devices/system/memory/memory0/phys_index
> > 00000000
> >
> > This results in
> >
> > libdaxctl: memblock_in_dev: dax1.0: memory0: Unable to determine phys_index: Success
> >
> > Avoid considering phys_index == 0 as error.
>
>
>  A gentle ping for this patch. Will appreciate a feedback on this

Looks good to me. Apologies for the delay.

Reviewed-by: Dan Williams <dan.j.williams@intel.com>
diff mbox series

Patch

diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index ee4a069eb463..3cb89c755978 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -1229,7 +1229,7 @@  static int memblock_in_dev(struct daxctl_memory *mem, const char *memblock)
 	rc = sysfs_read_attr(ctx, path, buf);
 	if (rc == 0) {
 		phys_index = strtoul(buf, NULL, 16);
-		if (phys_index == 0 || phys_index == ULONG_MAX) {
+		if (phys_index == ULONG_MAX) {
 			rc = -errno;
 			err(ctx, "%s: %s: Unable to determine phys_index: %s\n",
 				devname, memblock, strerror(-rc));