diff mbox series

[ndctl] daxctl: Skip over memory failure node status

Message ID 20230213213853.436788-1-a.manzanares@samsung.com
State Accepted
Commit 9b81c4af4b862b4fdc43e8057ec4c132253dbae2
Headers show
Series [ndctl] daxctl: Skip over memory failure node status | expand

Commit Message

Adam Manzanares Feb. 13, 2023, 9:39 p.m. UTC
When trying to match a dax device to a memblock physical address
memblock_in_dev will fail if the the phys_index sysfs file does
not exist in the memblock. Currently the memory failure directory
associated with a node is currently interpreted as a memblock.
Skip over the memory_failure directory within the node directory.

Signed-off-by: Adam Manzanares <a.manzanares@samsung.com>
---
 daxctl/lib/libdaxctl.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Dan Williams Feb. 13, 2023, 11:26 p.m. UTC | #1
Adam Manzanares wrote:
> When trying to match a dax device to a memblock physical address
> memblock_in_dev will fail if the the phys_index sysfs file does
> not exist in the memblock. Currently the memory failure directory
> associated with a node is currently interpreted as a memblock.
> Skip over the memory_failure directory within the node directory.

Oh, interesting, I did not know memory_failure() added entries to sysfs.
My grep-fu is failing me though... I only found node_init_cache_dev()
that creates a file named "memory_side_cache" under a node. This fix
will work for that as well, but I am still curious where the memory
failure file originates.
Adam Manzanares Feb. 14, 2023, 6:57 a.m. UTC | #2
On Mon, Feb 13, 2023 at 03:26:58PM -0800, Dan Williams wrote:
> Adam Manzanares wrote:
> > When trying to match a dax device to a memblock physical address
> > memblock_in_dev will fail if the the phys_index sysfs file does
> > not exist in the memblock. Currently the memory failure directory
> > associated with a node is currently interpreted as a memblock.
> > Skip over the memory_failure directory within the node directory.
> 
> Oh, interesting, I did not know memory_failure() added entries to sysfs.
> My grep-fu is failing me though... I only found node_init_cache_dev()
> that creates a file named "memory_side_cache" under a node. This fix
> will work for that as well, but I am still curious where the memory
> failure file originates.

I found the issue on next-20230119, I have a suspicion your grep-fu will
work fine there.
Dan Williams Feb. 14, 2023, 9:52 p.m. UTC | #3
Adam Manzanares wrote:
> On Mon, Feb 13, 2023 at 03:26:58PM -0800, Dan Williams wrote:
> > Adam Manzanares wrote:
> > > When trying to match a dax device to a memblock physical address
> > > memblock_in_dev will fail if the the phys_index sysfs file does
> > > not exist in the memblock. Currently the memory failure directory
> > > associated with a node is currently interpreted as a memblock.
> > > Skip over the memory_failure directory within the node directory.
> > 
> > Oh, interesting, I did not know memory_failure() added entries to sysfs.
> > My grep-fu is failing me though... I only found node_init_cache_dev()
> > that creates a file named "memory_side_cache" under a node. This fix
> > will work for that as well, but I am still curious where the memory
> > failure file originates.
> 
> I found the issue on next-20230119, I have a suspicion your grep-fu will
> work fine there. 

Yup, thanks. For those following along at home, it's these patches:

https://lore.kernel.org/all/20230120034622.2698268-1-jiaqiyan@google.com

...which has some implications for interoperating with CXL Scan Media
which is distinct from a hardware patrol scrubber, but that's a
discussion for a different patch set.

For this patch though:

Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Verma, Vishal L Feb. 15, 2023, 12:36 a.m. UTC | #4
On Mon, 2023-02-13 at 21:39 +0000, Adam Manzanares wrote:
> When trying to match a dax device to a memblock physical address
> memblock_in_dev will fail if the the phys_index sysfs file does
> not exist in the memblock. Currently the memory failure directory
> associated with a node is currently interpreted as a memblock.
> Skip over the memory_failure directory within the node directory.
> 
> Signed-off-by: Adam Manzanares <a.manzanares@samsung.com>
> ---
>  daxctl/lib/libdaxctl.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
> index d990479..b27a8af 100644
> --- a/daxctl/lib/libdaxctl.c
> +++ b/daxctl/lib/libdaxctl.c
> @@ -1552,6 +1552,8 @@ static int daxctl_memory_op(struct daxctl_memory *mem, enum memory_op op)
>         errno = 0;
>         while ((de = readdir(node_dir)) != NULL) {
>                 if (strncmp(de->d_name, "memory", 6) == 0) {
> +                       if (strncmp(de->d_name, "memory_", 7) == 0)
> +                               continue;
>                         rc = memblock_in_dev(mem, de->d_name);
>                         if (rc < 0)
>                                 goto out_dir;

Applied, thanks Adam and Dan!
diff mbox series

Patch

diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index d990479..b27a8af 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -1552,6 +1552,8 @@  static int daxctl_memory_op(struct daxctl_memory *mem, enum memory_op op)
 	errno = 0;
 	while ((de = readdir(node_dir)) != NULL) {
 		if (strncmp(de->d_name, "memory", 6) == 0) {
+			if (strncmp(de->d_name, "memory_", 7) == 0)
+				continue;
 			rc = memblock_in_dev(mem, de->d_name);
 			if (rc < 0)
 				goto out_dir;