All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] madvise11: ignore EBUSY for MADV_SOFT_OFFLINE
@ 2024-05-09 10:28 Li Wang
  2024-05-09 13:40 ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2024-05-09 10:28 UTC (permalink / raw)
  To: ltp; +Cc: Luis Goncalves

The EBUSY error could be easily triggered on small system with
kernel-debug. By not treating EBUSY as a failure, the test can
avoid false positives where the test environment itself might
frequently cause resource contention.

Test output:
  madvise11.c:409: TINFO: Spawning 4 threads, with a total of 640 memory pages
  madvise11.c:163: TINFO: Thread [0] returned 0, succeeded.
  madvise11.c:163: TINFO: Thread [2] returned 0, succeeded.
  madvise11.c:163: TINFO: Thread [1] returned 0, succeeded.
  madvise11.c:163: TINFO: Thread [3] returned 0, succeeded.
  madvise11.c:198: TPASS: soft-offline / mmap race still clean     <--- end of 1st test
  madvise11.c:132: TFAIL: madvise failed: EBUSY (16)               <--- ERROR!
  ...

From kernel log:
  [ 431.590511] soft offline: 0xbfa8f: page migration failed 1, type
  0x800000008002e(referenced|uptodate|dirty|active|swapbacked|node=0|zone=1)
  ...
  [ 435.510819] soft offline: 0x98fb6: page migration failed 1, type
  0x800000008000e(referenced|uptodate|dirty|swapbacked|node=0|zone=1)
  ...

Kernel callpath:
  do_madvise()
  ---
  #ifdef CONFIG_MEMORY_FAILURE
      if (behavior == MADV_HWPOISON || behavior == MADV_SOFT_OFFLINE)
          return madvise_inject_error(behavior, start, start + len_in);
  #endif
  ---
    madvise_inject_error()
      soft_offline_page()
        soft_offline_in_use_page()
 	  ...
           2727	pr_info("soft offline: %#lx: %s migration failed %ld, type %pGp\n",
           2728		pfn, msg_page[huge], ret, &page->flags);
           2729	if (ret > 0)
           2730		ret = -EBUSY;   <--- Here

Debugged-by: Luis Goncalves <lgoncalv@redhat.com>
Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/syscalls/madvise/madvise11.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/testcases/kernel/syscalls/madvise/madvise11.c b/testcases/kernel/syscalls/madvise/madvise11.c
index 7a12abf20..fe27a18d8 100644
--- a/testcases/kernel/syscalls/madvise/madvise11.c
+++ b/testcases/kernel/syscalls/madvise/madvise11.c
@@ -128,6 +128,8 @@ static int allocate_offline(int tnum)
 				return -1;
 
 			if (madvise(ptrs[num_alloc], pagesize, MADV_SOFT_OFFLINE) == -1) {
+				if (errno == EBUSY)
+					continue;
 				if (errno != EINVAL)
 					tst_res(TFAIL | TERRNO, "madvise failed");
 				if (errno == EINVAL)
-- 
2.45.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH] madvise11: ignore EBUSY for MADV_SOFT_OFFLINE
  2024-05-09 10:28 [LTP] [PATCH] madvise11: ignore EBUSY for MADV_SOFT_OFFLINE Li Wang
@ 2024-05-09 13:40 ` Petr Vorel
  2024-05-10  2:36   ` Li Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2024-05-09 13:40 UTC (permalink / raw)
  To: Li Wang; +Cc: Luis Goncalves, ltp

Hi Li,

...
> +++ b/testcases/kernel/syscalls/madvise/madvise11.c
> @@ -128,6 +128,8 @@ static int allocate_offline(int tnum)
>  				return -1;

>  			if (madvise(ptrs[num_alloc], pagesize, MADV_SOFT_OFFLINE) == -1) {
> +				if (errno == EBUSY)
> +					continue;

LGTM
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr
>  				if (errno != EINVAL)
>  					tst_res(TFAIL | TERRNO, "madvise failed");
>  				if (errno == EINVAL)

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH] madvise11: ignore EBUSY for MADV_SOFT_OFFLINE
  2024-05-09 13:40 ` Petr Vorel
@ 2024-05-10  2:36   ` Li Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Li Wang @ 2024-05-10  2:36 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Luis Goncalves, ltp

Patch merged, thank you.

On Thu, May 9, 2024 at 9:40 PM Petr Vorel <pvorel@suse.cz> wrote:

> Hi Li,
>
> ...
> > +++ b/testcases/kernel/syscalls/madvise/madvise11.c
> > @@ -128,6 +128,8 @@ static int allocate_offline(int tnum)
> >                               return -1;
>
> >                       if (madvise(ptrs[num_alloc], pagesize,
> MADV_SOFT_OFFLINE) == -1) {
> > +                             if (errno == EBUSY)
> > +                                     continue;
>
> LGTM
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> Kind regards,
> Petr
> >                               if (errno != EINVAL)
> >                                       tst_res(TFAIL | TERRNO, "madvise
> failed");
> >                               if (errno == EINVAL)
>
>

-- 
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-10  2:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-09 10:28 [LTP] [PATCH] madvise11: ignore EBUSY for MADV_SOFT_OFFLINE Li Wang
2024-05-09 13:40 ` Petr Vorel
2024-05-10  2:36   ` Li Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.