public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] tst-process_madvise: Check process_madvise-syscall support.
@ 2022-08-11  7:47 Stefan Liebler
  2022-08-11  8:37 ` Florian Weimer
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Liebler @ 2022-08-11  7:47 UTC (permalink / raw)
  To: libc-alpha; +Cc: Stefan Liebler

So far this test checks if pidfd_open-syscall is supported,
which was introduced with linux 5.3.

The process_madvise-syscall was introduced with linux 5.10.
Thus you'll get FAILs if you are running a kernel in between.

This patch adds a check if the first process_madvise-syscall
returns ENOSYS and in this case will fail with UNSUPPORTED.
---
 sysdeps/unix/sysv/linux/tst-process_madvise.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/tst-process_madvise.c b/sysdeps/unix/sysv/linux/tst-process_madvise.c
index a674e80b76..6fe5a79b1d 100644
--- a/sysdeps/unix/sysv/linux/tst-process_madvise.c
+++ b/sysdeps/unix/sysv/linux/tst-process_madvise.c
@@ -101,8 +101,12 @@ do_test (void)
 
     /* We expect this to succeed in the target process because the mapping
        is valid.  */
-    TEST_COMPARE (process_madvise (pidfd, &iv, 1, MADV_COLD, 0),
-		  2 * page_size);
+    errno = 0;
+    ssize_t ret = process_madvise (pidfd, &iv, 1, MADV_COLD, 0);
+    if (ret == -1 && errno == ENOSYS)
+      FAIL_UNSUPPORTED ("kernel does not support process_madvise, skipping"
+			"test");
+    TEST_COMPARE (ret, 2 * page_size);
   }
 
   {
-- 
2.35.3


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

* Re: [PATCH] tst-process_madvise: Check process_madvise-syscall support.
  2022-08-11  7:47 [PATCH] tst-process_madvise: Check process_madvise-syscall support Stefan Liebler
@ 2022-08-11  8:37 ` Florian Weimer
  2022-08-11 10:23   ` Stefan Liebler
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2022-08-11  8:37 UTC (permalink / raw)
  To: Stefan Liebler via Libc-alpha; +Cc: Stefan Liebler

* Stefan Liebler via Libc-alpha:

> So far this test checks if pidfd_open-syscall is supported,
> which was introduced with linux 5.3.
>
> The process_madvise-syscall was introduced with linux 5.10.
> Thus you'll get FAILs if you are running a kernel in between.
>
> This patch adds a check if the first process_madvise-syscall
> returns ENOSYS and in this case will fail with UNSUPPORTED.
> ---
>  sysdeps/unix/sysv/linux/tst-process_madvise.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/tst-process_madvise.c b/sysdeps/unix/sysv/linux/tst-process_madvise.c
> index a674e80b76..6fe5a79b1d 100644
> --- a/sysdeps/unix/sysv/linux/tst-process_madvise.c
> +++ b/sysdeps/unix/sysv/linux/tst-process_madvise.c
> @@ -101,8 +101,12 @@ do_test (void)
>  
>      /* We expect this to succeed in the target process because the mapping
>         is valid.  */
> -    TEST_COMPARE (process_madvise (pidfd, &iv, 1, MADV_COLD, 0),
> -		  2 * page_size);
> +    errno = 0;
> +    ssize_t ret = process_madvise (pidfd, &iv, 1, MADV_COLD, 0);
> +    if (ret == -1 && errno == ENOSYS)
> +      FAIL_UNSUPPORTED ("kernel does not support process_madvise, skipping"
> +			"test");
> +    TEST_COMPARE (ret, 2 * page_size);
>    }
>  
>    {

Assigning 0 to errno should not be necessary here.  But the patch looks
good otherwise.

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Thanks,
Florian


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

* Re: [PATCH] tst-process_madvise: Check process_madvise-syscall support.
  2022-08-11  8:37 ` Florian Weimer
@ 2022-08-11 10:23   ` Stefan Liebler
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Liebler @ 2022-08-11 10:23 UTC (permalink / raw)
  To: Florian Weimer, Stefan Liebler via Libc-alpha

On 11/08/2022 10:37, Florian Weimer wrote:
> * Stefan Liebler via Libc-alpha:
> 
>> So far this test checks if pidfd_open-syscall is supported,
>> which was introduced with linux 5.3.
>>
>> The process_madvise-syscall was introduced with linux 5.10.
>> Thus you'll get FAILs if you are running a kernel in between.
>>
>> This patch adds a check if the first process_madvise-syscall
>> returns ENOSYS and in this case will fail with UNSUPPORTED.
>> ---
>>  sysdeps/unix/sysv/linux/tst-process_madvise.c | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/sysdeps/unix/sysv/linux/tst-process_madvise.c b/sysdeps/unix/sysv/linux/tst-process_madvise.c
>> index a674e80b76..6fe5a79b1d 100644
>> --- a/sysdeps/unix/sysv/linux/tst-process_madvise.c
>> +++ b/sysdeps/unix/sysv/linux/tst-process_madvise.c
>> @@ -101,8 +101,12 @@ do_test (void)
>>  
>>      /* We expect this to succeed in the target process because the mapping
>>         is valid.  */
>> -    TEST_COMPARE (process_madvise (pidfd, &iv, 1, MADV_COLD, 0),
>> -		  2 * page_size);
>> +    errno = 0;
>> +    ssize_t ret = process_madvise (pidfd, &iv, 1, MADV_COLD, 0);
>> +    if (ret == -1 && errno == ENOSYS)
>> +      FAIL_UNSUPPORTED ("kernel does not support process_madvise, skipping"
>> +			"test");
>> +    TEST_COMPARE (ret, 2 * page_size);
>>    }
>>  
>>    {
> 
> Assigning 0 to errno should not be necessary here.  But the patch looks
> good otherwise.
> 
> Reviewed-by: Florian Weimer <fweimer@redhat.com>
> 
> Thanks,
> Florian
> 
Hi Florian,

yes you are right. I've just committed it without the assignment.

Thanks,
Stefan

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

end of thread, other threads:[~2022-08-11 10:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-11  7:47 [PATCH] tst-process_madvise: Check process_madvise-syscall support Stefan Liebler
2022-08-11  8:37 ` Florian Weimer
2022-08-11 10:23   ` Stefan Liebler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).