diff mbox series

[2/2] kselftests: mm: Fail the test if userfaultfd syscall isn't found

Message ID 20240912103151.1520254-2-usama.anjum@collabora.com (mailing list archive)
State New
Headers show
Series [1/2] kselftests: mm: Fix wrong __NR_userfaultfd value | expand

Commit Message

Muhammad Usama Anjum Sept. 12, 2024, 10:31 a.m. UTC
The userfaultfd is enabled in the config fragment of mm selftest suite.
It must always be present. If it isn't present, we should throw error
and not just skip. This would have helped us catch the test breakage.
Adding this now to catch the future breakages.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/mm/pagemap_ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Shuah Khan Sept. 12, 2024, 4:10 p.m. UTC | #1
On 9/12/24 04:31, Muhammad Usama Anjum wrote:
> The userfaultfd is enabled in the config fragment of mm selftest suite.
> It must always be present. If it isn't present, we should throw error
> and not just skip. This would have helped us catch the test breakage.

Please elaborate on this to help understand the what breakage was
missed.

Also this commit log doesn't look right to me. syscall() could
fail for any reason. Do you mean to see skip is incorrect in this
error leg? Please see comments below.

> Adding this now to catch the future breakages.
> 
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
>   tools/testing/selftests/mm/pagemap_ioctl.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/mm/pagemap_ioctl.c b/tools/testing/selftests/mm/pagemap_ioctl.c
> index bcc73b4e805c6..d83dda8edf62c 100644
> --- a/tools/testing/selftests/mm/pagemap_ioctl.c
> +++ b/tools/testing/selftests/mm/pagemap_ioctl.c
> @@ -95,7 +95,7 @@ int init_uffd(void)
>   
>   	uffd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK | UFFD_USER_MODE_ONLY);
>   	if (uffd == -1)
> -		return uffd;
> +		ksft_exit_fail_perror("Userfaultfd syscall failed");

This looks wrong to me - Is missing config the only reason this syscall
would fail?

>   
>   	uffdio_api.api = UFFD_API;
>   	uffdio_api.features = UFFD_FEATURE_WP_UNPOPULATED | UFFD_FEATURE_WP_ASYNC |

thanks,
-- Shuah
Shuah Khan Sept. 12, 2024, 5:28 p.m. UTC | #2
On 9/12/24 10:10, Shuah Khan wrote:
> On 9/12/24 04:31, Muhammad Usama Anjum wrote:
>> The userfaultfd is enabled in the config fragment of mm selftest suite.
>> It must always be present. If it isn't present, we should throw error
>> and not just skip. This would have helped us catch the test breakage.
> 
> Please elaborate on this to help understand the what breakage was
> missed.
> 
> Also this commit log doesn't look right to me. syscall() could
> fail for any reason. Do you mean to see skip is incorrect in this
> error leg? Please see comments below.
> 
>> Adding this now to catch the future breakages.
>>
>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
>> ---
>>   tools/testing/selftests/mm/pagemap_ioctl.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/mm/pagemap_ioctl.c b/tools/testing/selftests/mm/pagemap_ioctl.c
>> index bcc73b4e805c6..d83dda8edf62c 100644
>> --- a/tools/testing/selftests/mm/pagemap_ioctl.c
>> +++ b/tools/testing/selftests/mm/pagemap_ioctl.c
>> @@ -95,7 +95,7 @@ int init_uffd(void)
>>       uffd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK | UFFD_USER_MODE_ONLY);
>>       if (uffd == -1)
>> -        return uffd;
>> +        ksft_exit_fail_perror("Userfaultfd syscall failed");
> 
> This looks wrong to me - Is missing config the only reason this syscall
> would fail?

It should still skip if __NR_userfaultfd isn't supported on a release
or an architecture.

The real problem seems to be in main():

if (init_uffd())
                 ksft_exit_pass();


Why is this ksft_exit_pass()? Looks like further investigation is
necessary to understand the problem and fix.

thanks,
-- Shuah
Muhammad Usama Anjum Sept. 16, 2024, 6:33 a.m. UTC | #3
On 9/12/24 10:28 PM, Shuah Khan wrote:
> On 9/12/24 10:10, Shuah Khan wrote:
>> On 9/12/24 04:31, Muhammad Usama Anjum wrote:
>>> The userfaultfd is enabled in the config fragment of mm selftest suite.
>>> It must always be present. If it isn't present, we should throw error
>>> and not just skip. This would have helped us catch the test breakage.
>>
>> Please elaborate on this to help understand the what breakage was
>> missed.
>>
>> Also this commit log doesn't look right to me. syscall() could
>> fail for any reason. Do you mean to see skip is incorrect in this
>> error leg? Please see comments below.
>>
>>> Adding this now to catch the future breakages.
>>>
>>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
>>> ---
>>>   tools/testing/selftests/mm/pagemap_ioctl.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/tools/testing/selftests/mm/pagemap_ioctl.c
>>> b/tools/testing/selftests/mm/pagemap_ioctl.c
>>> index bcc73b4e805c6..d83dda8edf62c 100644
>>> --- a/tools/testing/selftests/mm/pagemap_ioctl.c
>>> +++ b/tools/testing/selftests/mm/pagemap_ioctl.c
>>> @@ -95,7 +95,7 @@ int init_uffd(void)
>>>       uffd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK |
>>> UFFD_USER_MODE_ONLY);
>>>       if (uffd == -1)
>>> -        return uffd;
>>> +        ksft_exit_fail_perror("Userfaultfd syscall failed");
>>
>> This looks wrong to me - Is missing config the only reason this syscall
>> would fail?
> 
> It should still skip if __NR_userfaultfd isn't supported on a release
> or an architecture.
> 
> The real problem seems to be in main():
> 
> if (init_uffd())
>                 ksft_exit_pass();
> 
> 
> Why is this ksft_exit_pass()? Looks like further investigation is
> necessary to understand the problem and fix.
Let's skip this patch as it'll create more noise on unsupported
architectures than catching failures on supported architectures.

> 
> thanks,
> -- Shuah
diff mbox series

Patch

diff --git a/tools/testing/selftests/mm/pagemap_ioctl.c b/tools/testing/selftests/mm/pagemap_ioctl.c
index bcc73b4e805c6..d83dda8edf62c 100644
--- a/tools/testing/selftests/mm/pagemap_ioctl.c
+++ b/tools/testing/selftests/mm/pagemap_ioctl.c
@@ -95,7 +95,7 @@  int init_uffd(void)
 
 	uffd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK | UFFD_USER_MODE_ONLY);
 	if (uffd == -1)
-		return uffd;
+		ksft_exit_fail_perror("Userfaultfd syscall failed");
 
 	uffdio_api.api = UFFD_API;
 	uffdio_api.features = UFFD_FEATURE_WP_UNPOPULATED | UFFD_FEATURE_WP_ASYNC |