Re: [PATCH bpf-next v1 2/3] bpf: btf: Ensure natural alignment of .BTF_ids section

2024-09-23 Thread Eduard Zingerman
On Mon, 2024-09-23 at 12:54 +0200, Jiri Olsa wrote:

[...]

> > > diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h
> > > index c0e3e1426a82..c10b163dc340 100644
> > > --- a/include/linux/btf_ids.h
> > > +++ b/include/linux/btf_ids.h
> > > @@ -89,6 +89,7 @@ word
> > > \
> > >  #define __BTF_ID_LIST(name, scope)   \
> > >  asm( \
> > >  ".pushsection " BTF_IDS_SECTION ",\"a\";   \n"   \
> > > +".balign 4, 0; \n"   \
> > >  "." #scope " " #name ";\n"   \
> > >  #name ":;  \n"   \
> > >  ".popsection;  \n");
> > 
> > This forces all id list symbols to be aligned on 4 bytes.
> > Should the same be done for __BTF_SET_START?
> 
> it seems all the set macros use __BTF_ID_LIST, so it should be taken
> care of by that

Apologies, I don't know how I missed __BTF_ID_LIST invocation in
the __BTF_SET_START definition :(

> > Also, is it guaranteed that all btf ids are organized in lists and sets?
> > Grepping through the code it seems they are, but it looks like 
> > resolve_btfids
> > does not really enforce this, simply looking for symbols matching a special 
> > name
> > __BTF_ID[__] .
> 
> yes, you need the BTF_ID to be part of list or set to be able to access it
> 
> resolve_btfids does not enforce some loose BTF_ID definition without list/set,
> but that does not seem to be a problem

Understood, thank you.




Re: [PATCH bpf-next v1 2/3] bpf: btf: Ensure natural alignment of .BTF_ids section

2024-09-23 Thread Jiri Olsa
On Sat, Sep 21, 2024 at 02:46:17AM -0700, Eduard Zingerman wrote:
> On Fri, 2024-09-20 at 00:49 -0700, Tony Ambardar wrote:
> > While building of vmlinux employs a linker script to align the .BTF_ids
> > section to 4 bytes, other usage leaves .BTF_ids unaligned and may lead to
> > problems (e.g. [1]). Post-processing and libelf-based endian translation by
> > resolve_btfids may also potentially suffer from misalignment.
> > 
> > Update encoding macros in btf_ids.h to always align BTF ID data to 4 bytes.
> > 
> > [1]: 3effc06a4dde ("selftests/bpf: Fix alignment of .BTF_ids")
> > 
> > Signed-off-by: Tony Ambardar 
> > ---
> >  include/linux/btf_ids.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h
> > index c0e3e1426a82..c10b163dc340 100644
> > --- a/include/linux/btf_ids.h
> > +++ b/include/linux/btf_ids.h
> > @@ -89,6 +89,7 @@ word  
> > \
> >  #define __BTF_ID_LIST(name, scope) \
> >  asm(   \
> >  ".pushsection " BTF_IDS_SECTION ",\"a\";   \n" \
> > +".balign 4, 0; \n" \
> >  "." #scope " " #name ";\n" \
> >  #name ":;  \n" \
> >  ".popsection;  \n");
> 
> This forces all id list symbols to be aligned on 4 bytes.
> Should the same be done for __BTF_SET_START?

it seems all the set macros use __BTF_ID_LIST, so it should be taken
care of by that

> 
> Also, is it guaranteed that all btf ids are organized in lists and sets?
> Grepping through the code it seems they are, but it looks like resolve_btfids
> does not really enforce this, simply looking for symbols matching a special 
> name
> __BTF_ID[__] .

yes, you need the BTF_ID to be part of list or set to be able to access it

resolve_btfids does not enforce some loose BTF_ID definition without list/set,
but that does not seem to be a problem

thanks,
jirka



Re: [PATCH bpf-next v1 1/3] tools/resolve_btfids: Simplify handling cross-endian compilation

2024-09-23 Thread Jiri Olsa
On Fri, Sep 20, 2024 at 12:49:11AM -0700, Tony Ambardar wrote:

SNIP

> +static int btfids_endian_fix(struct object *obj)
> +{
> + Elf_Data *btfids = obj->efile.idlist;
> + Elf *elf = obj->efile.elf;
> + int file_byteorder;
> +
> + /* This should always succeed due to prior ELF checks */
> + file_byteorder = elf_getident(elf, NULL)[EI_DATA];
> +
> + /* Set type to ensure endian translation occurs, and manually invoke
> +  * translation on input since .BTF_ids section as created disables it.
> +  */
> + btfids->d_type = ELF_T_WORD;
> + if (gelf_xlatetom(elf, btfids, btfids, file_byteorder) == NULL) {
> + pr_err("FAILED xlatetom .BTF_ids data: %s\n", elf_errmsg(-1));
> + return -1;
> + }
> + return 0;
> +}
> +
>  static int elf_collect(struct object *obj)
>  {
>   Elf_Scn *scn = NULL;
>   size_t shdrstrndx;
> - GElf_Ehdr ehdr;
>   int idx = 0;
>   Elf *elf;
>   int fd;
> @@ -361,13 +371,6 @@ static int elf_collect(struct object *obj)
>   return -1;
>   }
>  
> - if (gelf_getehdr(obj->efile.elf, &ehdr) == NULL) {
> - pr_err("FAILED cannot get ELF header: %s\n",
> - elf_errmsg(-1));
> - return -1;
> - }
> - obj->efile.encoding = ehdr.e_ident[EI_DATA];
> -
>   /*
>* Scan all the elf sections and look for save data
>* from .BTF_ids section and symbols.
> @@ -409,6 +412,8 @@ static int elf_collect(struct object *obj)
>   obj->efile.idlist   = data;
>   obj->efile.idlist_shndx = idx;
>   obj->efile.idlist_addr  = sh.sh_addr;
> + if (btfids_endian_fix(obj))
> + return -1;

nit, it'd be bit more clear to me without using the btfids_endian_fix
function and just unwind it in here.. but anyway lgtm

Acked-by: Jiri Olsa 

jirka

>   } else if (!strcmp(name, BTF_BASE_ELF_SEC)) {
>   /* If a .BTF.base section is found, do not resolve
>* BTF ids relative to vmlinux; resolve relative
> @@ -706,24 +711,6 @@ static int sets_patch(struct object *obj)
>*/
>   BUILD_BUG_ON((u32 *)set8->pairs != &set8->pairs[0].id);
>   qsort(set8->pairs, set8->cnt, sizeof(set8->pairs[0]), 
> cmp_id);
> -
> - /*
> -  * When ELF endianness does not match endianness of the
> -  * host, libelf will do the translation when updating
> -  * the ELF. This, however, corrupts SET8 flags which are
> -  * already in the target endianness. So, let's bswap
> -  * them to the host endianness and libelf will then
> -  * correctly translate everything.
> -  */
> - if (obj->efile.encoding != ELFDATANATIVE) {
> - int i;
> -
> - set8->flags = bswap_32(set8->flags);
> - for (i = 0; i < set8->cnt; i++) {
> - set8->pairs[i].flags =
> - bswap_32(set8->pairs[i].flags);
> - }
> - }
>   }
>  
>   pr_debug("sorting  addr %5lu: cnt %6d [%s]\n",
> @@ -748,9 +735,6 @@ static int symbols_patch(struct object *obj)
>   if (sets_patch(obj))
>   return -1;
>  
> - /* Set type to ensure endian translation occurs. */
> - obj->efile.idlist->d_type = ELF_T_WORD;
> -
>   elf_flagdata(obj->efile.idlist, ELF_C_SET, ELF_F_DIRTY);
>  
>   err = elf_update(obj->efile.elf, ELF_C_WRITE);
> -- 
> 2.34.1
> 



Re: [PATCH bpf-next v1 0/3] Improve .BTF_ids patching and alignment

2024-09-23 Thread Jiri Olsa
On Fri, Sep 20, 2024 at 12:49:10AM -0700, Tony Ambardar wrote:
> Hello all,
> 
> This patch series offers improvements to the way .BTF_ids section data is
> created and later patched by resolve_btfids.
> 
> Patch #1 simplifies the byte-order translation in resolve_btfids while
> making it more resilient to future .BTF_ids encoding updates.
> 
> Patch #2 makes sure all BTF ID data is 4-byte aligned, and not only the
> .BTF_ids used for vmlinux.
> 
> Patch #3 syncs the above changes in btf_ids.h to tools/include, obviating
> a previous alignment fix in selftests/bpf.
> 
> Feedback and suggestions are welcome!
> 
> Best regards,
> Tony

nice, thanks for the fix

Jean-Philippe, Viktor,
any chance you could check/test this patchset? it changes your recent
cross building fixes

thanks,
jirka

> 
> 
> Tony Ambardar (3):
>   tools/resolve_btfids: Simplify handling cross-endian compilation
>   bpf: btf: Ensure natural alignment of .BTF_ids section
>   tools/bpf, selftests/bpf : Sync btf_ids.h to tools
> 
>  include/linux/btf_ids.h   |  1 +
>  tools/bpf/resolve_btfids/main.c   | 60 +-
>  tools/include/linux/btf_ids.h | 80 +--
>  .../selftests/bpf/prog_tests/resolve_btfids.c |  6 --
>  4 files changed, 97 insertions(+), 50 deletions(-)
> 
> -- 
> 2.34.1
> 



Re: [PATCH] selftests: vDSO: fix compile error for vdso_test_getrandom

2024-09-23 Thread Shuah Khan

On 9/20/24 09:31, Jason A. Donenfeld wrote:

Indeed probably  is what's wanted here.



Yu Liao, Please send v2 as per the review comments.


Shuah - I was taking patches for this code during the 6.12 development
cycle, because it all interacted with the dev work I was doing. But I
think that's died down now and things can return to normal. Do you
want to take these like you usually do now? Or is that annoying
because your tree won't be based on them for another cycle, so I
should still do it? I'm okay with doing whatever you want.

Jason


I can take this through my tree - I rebase as soon as rc1 comes out.
We can also handshake as needed if there are conflicts still.

thanks,
-- Shuah



Re: [External] : Re: [PATCH v6.11 v5.15 v5.4 v4.19 1/1] selftests: breakpoints: use time passed to check if suspend succeed

2024-09-23 Thread Yifei Liu
Hi Shuah, 
Thanks for the review. I will send a v2 soon. 
Yifei

> On Sep 23, 2024, at 8:37 AM, Shuah Khan  wrote:
> 
> On 9/20/24 11:52, Yifei Liu wrote:
>> Hi Shuah,
>>> On Sep 20, 2024, at 8:07 AM, Shuah Khan  wrote:
>>> 
>>> On 9/19/24 17:09, Yifei Liu wrote:
 Hi Shuah,
> On Sep 19, 2024, at 11:36 AM, Shuah Khan  
> wrote:
> 
> On 9/17/24 16:48, Yifei Liu wrote:
>> We recently notice that the step_after_suspend_test would
>> fail on our plenty devices.  The test believesit failed to
> 
> What are "plenty devices"
> recently noticed?
 We have seen this issue on more than one platforms, including bare metal 
 device and virtual machine.
> Typo - believesit?
 Yes, missing a space here. It should be
 The test believes itself ffailed to enter suspend state.
 Thank you for pointing out.
> 
>> enter suspend state with
>> $ sudo ./step_after_suspend_test
>> TAP version 13
>> Bail out! Failed to enter Suspend state
>> However, in the kernel message, I indeed see the system get
>> suspended and then wake up later.
>> [611172.033108] PM: suspend entry (s2idle)
>> [611172.044940] Filesystems sync: 0.006 seconds
>> [611172.052254] Freezing user space processes
>> [611172.059319] Freezing user space processes completed (elapsed 0.001 
>> seconds)
>> [611172.067920] OOM killer disabled.
>> [611172.072465] Freezing remaining freezable tasks
>> [611172.080332] Freezing remaining freezable tasks completed (elapsed 
>> 0.001 seconds)
>> [611172.089724] printk: Suspending console(s) (use no_console_suspend to 
>> debug)
>> [611172.117126] serial 00:03: disabled
>> --- some other hardware get reconnected ---
>> [611203.136277] OOM killer enabled.
>> [611203.140637] Restarting tasks ...
>> [611203.141135] usb 1-8.1: USB disconnect, device number 7
>> [611203.141755] done.
>> [611203.155268] random: crng reseeded on system resumption
>> [611203.162059] PM: suspend exit
>> After investigation, I notice that for the code block
>> if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
>> ksft_exit_fail_msg("Failed to enter Suspend state\n");
>> The write will return -1 and errno is set to 16 (device busy).
>> It should be caused by the write function is not successfully returned
>> before the system suspend and the return value get messed when waking up.
>> As a result, It may be better to check the time passed of those few 
>> instructions
>> to determine whether the suspend is executed correctly for it is pretty 
>> hard to
>> execute those few lines for 4 seconds, or even more if it is not long 
>> enough.
> 
> I don't think this is the right fix. Can you change this to do echo 
> instead.
> It does the same thing, but it goes through sysfs interface instead of 
> direct
> write:
> 
> ret = system("echo mem > /sys/power/state”);
 Sure, I can do that.
> 
>> Fixes: bfd092b8c2728 ("selftests: breakpoint: add 
>> step_after_suspend_test")
>> Reported-by: Sinadin Shan 
>> Signed-off-by: Yifei Liu 
>> ---
>>  .../selftests/breakpoints/step_after_suspend_test.c  | 9 +++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>> diff --git 
>> a/tools/testing/selftests/breakpoints/step_after_suspend_test.c 
>> b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
>> index dfec31fb9b30d..d615f091e5bae 100644
>> --- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
>> +++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
>> @@ -18,6 +18,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>#include "../kselftest.h"
>>  @@ -133,6 +134,7 @@ void suspend(void)
>>   int timerfd;
>>   int err;
>>   struct itimerspec spec = {};
>> + clock_t t;
>> if (getuid() != 0)
>>   ksft_exit_skip("Please run the test as root - Exiting.\n");
>> @@ -152,8 +154,11 @@ void suspend(void)
>>   if (err < 0)
>>   ksft_exit_fail_msg("timerfd_settime() failed\n");
> 
> I don't think you will need to add clock() code. timerfd_settime()
> sets the time for 5 seconds and you can simply extend the alarm
> time.
> 
> There needs to be some logic to check timer elapse and poll the
> timer_fd
 Yes, it is also a choice to check the remaining time of the timer. We 
 could use timerfd_gettime() to get the remaining time. The timer would not 
 rearm because the it_interval value is not set (set to 0). Then if the 
 remaining time has both 0 or seconds and nano-seconds (tv_sec and 
 tv_nsec), it should point out the time goes for at least 5 seconds. If the 
 system fails to enter suspend state and waked up by the timer, it should 
 not take 5 whole seconds or more to get to the check

Re: [External] : Re: [PATCH v6.11 v5.15 v5.4 v4.19 1/1] selftests: breakpoints: use time passed to check if suspend succeed

2024-09-23 Thread Shuah Khan

On 9/20/24 11:52, Yifei Liu wrote:

Hi Shuah,


On Sep 20, 2024, at 8:07 AM, Shuah Khan  wrote:

On 9/19/24 17:09, Yifei Liu wrote:

Hi Shuah,

On Sep 19, 2024, at 11:36 AM, Shuah Khan  wrote:

On 9/17/24 16:48, Yifei Liu wrote:

We recently notice that the step_after_suspend_test would
fail on our plenty devices.  The test believesit failed to


What are "plenty devices"
recently noticed?

We have seen this issue on more than one platforms, including bare metal device 
and virtual machine.

Typo - believesit?

Yes, missing a space here. It should be
The test believes itself ffailed to enter suspend state.
Thank you for pointing out.



enter suspend state with
$ sudo ./step_after_suspend_test
TAP version 13
Bail out! Failed to enter Suspend state
However, in the kernel message, I indeed see the system get
suspended and then wake up later.
[611172.033108] PM: suspend entry (s2idle)
[611172.044940] Filesystems sync: 0.006 seconds
[611172.052254] Freezing user space processes
[611172.059319] Freezing user space processes completed (elapsed 0.001 seconds)
[611172.067920] OOM killer disabled.
[611172.072465] Freezing remaining freezable tasks
[611172.080332] Freezing remaining freezable tasks completed (elapsed 0.001 
seconds)
[611172.089724] printk: Suspending console(s) (use no_console_suspend to debug)
[611172.117126] serial 00:03: disabled
--- some other hardware get reconnected ---
[611203.136277] OOM killer enabled.
[611203.140637] Restarting tasks ...
[611203.141135] usb 1-8.1: USB disconnect, device number 7
[611203.141755] done.
[611203.155268] random: crng reseeded on system resumption
[611203.162059] PM: suspend exit
After investigation, I notice that for the code block
if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
ksft_exit_fail_msg("Failed to enter Suspend state\n");
The write will return -1 and errno is set to 16 (device busy).
It should be caused by the write function is not successfully returned
before the system suspend and the return value get messed when waking up.
As a result, It may be better to check the time passed of those few instructions
to determine whether the suspend is executed correctly for it is pretty hard to
execute those few lines for 4 seconds, or even more if it is not long enough.


I don't think this is the right fix. Can you change this to do echo instead.
It does the same thing, but it goes through sysfs interface instead of direct
write:

ret = system("echo mem > /sys/power/state”);

Sure, I can do that.



Fixes: bfd092b8c2728 ("selftests: breakpoint: add step_after_suspend_test")
Reported-by: Sinadin Shan 
Signed-off-by: Yifei Liu 
---
  .../selftests/breakpoints/step_after_suspend_test.c  | 9 +++--
  1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c 
b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
index dfec31fb9b30d..d615f091e5bae 100644
--- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
+++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
@@ -18,6 +18,7 @@
  #include 
  #include 
  #include 
+#include 
#include "../kselftest.h"
  @@ -133,6 +134,7 @@ void suspend(void)
   int timerfd;
   int err;
   struct itimerspec spec = {};
+ clock_t t;
 if (getuid() != 0)
   ksft_exit_skip("Please run the test as root - Exiting.\n");
@@ -152,8 +154,11 @@ void suspend(void)
   if (err < 0)
   ksft_exit_fail_msg("timerfd_settime() failed\n");


I don't think you will need to add clock() code. timerfd_settime()
sets the time for 5 seconds and you can simply extend the alarm
time.

There needs to be some logic to check timer elapse and poll the
timer_fd

Yes, it is also a choice to check the remaining time of the timer. We could use 
timerfd_gettime() to get the remaining time. The timer would not rearm because 
the it_interval value is not set (set to 0). Then if the remaining time has 
both 0 or seconds and nano-seconds (tv_sec and tv_nsec), it should point out 
the time goes for at least 5 seconds. If the system fails to enter suspend 
state and waked up by the timer, it should not take 5 whole seconds or more to 
get to the check line.


Right, You will have to check the remaining time. There is an example in
tools/testing/selftests/timers/alarmtimer-suspend.c you can refer to.

I checked the remaining value, if the suspend succeed, it would be all 0 (0s 
and 0 ns). If it failed to enter suspend by any chance, it would be a non-zero 
value.



Would you prefer this methods?


I am curious what happens with starting suspend with sysfs first and then
explore checking elapsed timer.

system("echo mem > /sys/power/state”);

I checked this, and find that it will give a similar failure.

sh: line 1: echo: write error: Device or resource busy

The console command will get its return result after the suspend and wake up. 
Maybe we could do

system("echo mem > /sys/power/state >/dev/nul”);


Yes. The idea is that we go through the

[PATCH 2/2] unicode: kunit: change tests filename and path

2024-09-23 Thread Gabriela Bittencourt
Change utf8 kunit test filename and path to follow the style
convention on Documentation/dev-tools/kunit/style.rst

Co-developed-by: Pedro Orlando 
Signed-off-by: Pedro Orlando 
Co-developed-by: Danilo Pereira 
Signed-off-by: Danilo Pereira 
Signed-off-by: Gabriela Bittencourt 
---
 fs/unicode/Makefile| 2 +-
 fs/unicode/{ => tests}/.kunitconfig| 0
 fs/unicode/{utf8-selftest.c => tests/utf8_kunit.c} | 0
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename fs/unicode/{ => tests}/.kunitconfig (100%)
 rename fs/unicode/{utf8-selftest.c => tests/utf8_kunit.c} (100%)

diff --git a/fs/unicode/Makefile b/fs/unicode/Makefile
index 37bbcbc628a1..d95be7fb9f6b 100644
--- a/fs/unicode/Makefile
+++ b/fs/unicode/Makefile
@@ -4,7 +4,7 @@ ifneq ($(CONFIG_UNICODE),)
 obj-y  += unicode.o
 endif
 obj-$(CONFIG_UNICODE)  += utf8data.o
-obj-$(CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST) += utf8-selftest.o
+obj-$(CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST) += tests/utf8_kunit.o
 
 unicode-y := utf8-norm.o utf8-core.o
 
diff --git a/fs/unicode/.kunitconfig b/fs/unicode/tests/.kunitconfig
similarity index 100%
rename from fs/unicode/.kunitconfig
rename to fs/unicode/tests/.kunitconfig
diff --git a/fs/unicode/utf8-selftest.c b/fs/unicode/tests/utf8_kunit.c
similarity index 100%
rename from fs/unicode/utf8-selftest.c
rename to fs/unicode/tests/utf8_kunit.c
-- 
2.46.1




[PATCH 1/2] unicode: kunit: refactor selftest to kunit tests

2024-09-23 Thread Gabriela Bittencourt
Instead of creating 'test' functions, use kunit functions to test
utf-8 support in unicode subsystem.

Co-developed-by: Pedro Orlando 
Signed-off-by: Pedro Orlando 
Co-developed-by: Danilo Pereira 
Signed-off-by: Danilo Pereira 
Signed-off-by: Gabriela Bittencourt 
---
 fs/unicode/.kunitconfig|   3 +
 fs/unicode/Kconfig |   5 +-
 fs/unicode/Makefile|   2 +-
 fs/unicode/utf8-selftest.c | 152 +
 4 files changed, 76 insertions(+), 86 deletions(-)
 create mode 100644 fs/unicode/.kunitconfig

diff --git a/fs/unicode/.kunitconfig b/fs/unicode/.kunitconfig
new file mode 100644
index ..62dd5c171f9c
--- /dev/null
+++ b/fs/unicode/.kunitconfig
@@ -0,0 +1,3 @@
+CONFIG_KUNIT=y
+CONFIG_UNICODE=y
+CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST=y
diff --git a/fs/unicode/Kconfig b/fs/unicode/Kconfig
index da786a687fdc..4ad2c36550f1 100644
--- a/fs/unicode/Kconfig
+++ b/fs/unicode/Kconfig
@@ -10,6 +10,7 @@ config UNICODE
  be a separate loadable module that gets requested only when a file
  system actually use it.
 
-config UNICODE_NORMALIZATION_SELFTEST
+config UNICODE_NORMALIZATION_KUNIT_TEST
tristate "Test UTF-8 normalization support"
-   depends on UNICODE
+   depends on UNICODE && KUNIT
+   default KUNIT_ALL_TESTS
diff --git a/fs/unicode/Makefile b/fs/unicode/Makefile
index e309afe2b2bb..37bbcbc628a1 100644
--- a/fs/unicode/Makefile
+++ b/fs/unicode/Makefile
@@ -4,7 +4,7 @@ ifneq ($(CONFIG_UNICODE),)
 obj-y  += unicode.o
 endif
 obj-$(CONFIG_UNICODE)  += utf8data.o
-obj-$(CONFIG_UNICODE_NORMALIZATION_SELFTEST) += utf8-selftest.o
+obj-$(CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST) += utf8-selftest.o
 
 unicode-y := utf8-norm.o utf8-core.o
 
diff --git a/fs/unicode/utf8-selftest.c b/fs/unicode/utf8-selftest.c
index 600e15efe9ed..54ded8db6b1c 100644
--- a/fs/unicode/utf8-selftest.c
+++ b/fs/unicode/utf8-selftest.c
@@ -1,38 +1,18 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Kernel module for testing utf-8 support.
+ * KUnit tests for utf-8 support
  *
  * Copyright 2017 Collabora Ltd.
  */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include 
-#include 
 #include 
-#include 
+#include 
 
 #include "utf8n.h"
 
-static unsigned int failed_tests;
-static unsigned int total_tests;
-
 /* Tests will be based on this version. */
 #define UTF8_LATESTUNICODE_AGE(12, 1, 0)
 
-#define _test(cond, func, line, fmt, ...) do { \
-   total_tests++;  \
-   if (!cond) {\
-   failed_tests++; \
-   pr_err("test %s:%d Failed: %s%s",   \
-  func, line, #cond, (fmt?":":"."));   \
-   if (fmt)\
-   pr_err(fmt, ##__VA_ARGS__); \
-   }   \
-   } while (0)
-#define test_f(cond, fmt, ...) _test(cond, __func__, __LINE__, fmt, 
##__VA_ARGS__)
-#define test(cond) _test(cond, __func__, __LINE__, "")
-
 static const struct {
/* UTF-8 strings in this vector _must_ be NULL-terminated. */
unsigned char str[10];
@@ -158,22 +138,22 @@ static const struct {
}
 };
 
-static ssize_t utf8len(const struct unicode_map *um, enum utf8_normalization n,
-   const char *s)
+static ssize_t utf8len(const struct unicode_map *um, enum utf8_normalization 
n, const char *s)
 {
return utf8nlen(um, n, s, (size_t)-1);
 }
 
 static int utf8cursor(struct utf8cursor *u8c, const struct unicode_map *um,
-   enum utf8_normalization n, const char *s)
+ enum utf8_normalization n, const char *s)
 {
return utf8ncursor(u8c, um, n, s, (unsigned int)-1);
 }
 
-static void check_utf8_nfdi(struct unicode_map *um)
+static void check_utf8_nfdi(struct kunit *test)
 {
int i;
struct utf8cursor u8c;
+   struct unicode_map *um = test->priv;
 
for (i = 0; i < ARRAY_SIZE(nfdi_test_data); i++) {
int len = strlen(nfdi_test_data[i].str);
@@ -181,28 +161,29 @@ static void check_utf8_nfdi(struct unicode_map *um)
int j = 0;
unsigned char c;
 
-   test((utf8len(um, UTF8_NFDI, nfdi_test_data[i].str) == nlen));
-   test((utf8nlen(um, UTF8_NFDI, nfdi_test_data[i].str, len) ==
-   nlen));
+   KUNIT_EXPECT_EQ(test, utf8len(um, UTF8_NFDI, 
nfdi_test_data[i].str), nlen);
+   KUNIT_EXPECT_EQ(test, utf8nlen(um, UTF8_NFDI, 
nfdi_test_data[i].str, len),
+   nlen);
 
-   if (utf8cursor(&u8c, um, UTF8_NFDI, nfdi_test_data[i].str) < 0)
-   pr_err("can't create cursor\n");
+   KUNIT_EXPECT_GE_MSG(

[PATCH 0/2] unicode: kunit: refactor selftest to kunit tests

2024-09-23 Thread Gabriela Bittencourt
Hey all,

We are making these changes as part of a KUnit Hackathon at LKCamp [1].

This patch sets out to refactor fs/unicode/utf8-selftest.c to KUnit tests.

The first commit is the refactoring itself from self test into KUnit, while
the second one applies the naming style conventions.

We appreciate any feedback and suggestions. :)

(Resending patch series with the right lists on cc: kselftest and
 kunit-dev).

[1] https://lkcamp.dev/about/

Co-developed-by: Pedro Orlando 
Co-developed-by: Danilo Pereira 
Signed-off-by: Pedro Orlando 
Signed-off-by: Danilo Pereira 
Signed-off-by: Gabriela Bittencourt 

Gabriela Bittencourt (2):
  unicode: kunit: refactor selftest to kunit tests
  unicode: kunit: change tests filename and path

 fs/unicode/Kconfig|   5 +-
 fs/unicode/Makefile   |   2 +-
 fs/unicode/tests/.kunitconfig |   3 +
 .../{utf8-selftest.c => tests/utf8_kunit.c}   | 152 --
 4 files changed, 76 insertions(+), 86 deletions(-)
 create mode 100644 fs/unicode/tests/.kunitconfig
 rename fs/unicode/{utf8-selftest.c => tests/utf8_kunit.c} (63%)

-- 
2.46.1




[PATCH v6.11 v5.15 v5.4 v4.19 1/1] selftests: breakpoints: use remaining time to check if suspend succeed

2024-09-23 Thread Yifei Liu
We recently notice that the step_after_suspend_test would
fail on our plenty devices.  The test believesit failed to
enter suspend state with

$ sudo ./step_after_suspend_test
TAP version 13
Bail out! Failed to enter Suspend state

However, in the kernel message, I indeed see the system get
suspended and then wake up later.

[611172.033108] PM: suspend entry (s2idle)
[611172.044940] Filesystems sync: 0.006 seconds
[611172.052254] Freezing user space processes
[611172.059319] Freezing user space processes completed (elapsed 0.001 seconds)
[611172.067920] OOM killer disabled.
[611172.072465] Freezing remaining freezable tasks
[611172.080332] Freezing remaining freezable tasks completed (elapsed 0.001 
seconds)
[611172.089724] printk: Suspending console(s) (use no_console_suspend to debug)
[611172.117126] serial 00:03: disabled
--- some other hardware get reconnected ---
[611203.136277] OOM killer enabled.
[611203.140637] Restarting tasks ...
[611203.141135] usb 1-8.1: USB disconnect, device number 7
[611203.141755] done.
[611203.155268] random: crng reseeded on system resumption
[611203.162059] PM: suspend exit

After investigation, I notice that for the code block
if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
ksft_exit_fail_msg("Failed to enter Suspend state\n");

The write will return -1 and errno is set to 16 (device busy).
It should be caused by the write function is not successfully returned
before the system suspend and the return value get messed when waking up.
As a result, It may be better to check the time passed of those few instructions
to determine whether the suspend is executed correctly for it is pretty hard to
execute those few lines for 5 seconds.

The timer to wake up the system is set to expired after 5 seconds and no-rearm.
If the timer remaining time is 0 second and 0 nano secomd, it means the timer
expired and wake the system up. Otherwise, the system could be considered to
enter the suspend state failed if there is any remaining time.

Fixes: bfd092b8c2728 ("selftests: breakpoint: add step_after_suspend_test")
Reported-by: Sinadin Shan 
Signed-off-by: Yifei Liu 
---
 .../testing/selftests/breakpoints/step_after_suspend_test.c  | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c 
b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
index dfec31fb9b30d..33f5542bf741d 100644
--- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
+++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
@@ -152,7 +152,10 @@ void suspend(void)
if (err < 0)
ksft_exit_fail_msg("timerfd_settime() failed\n");
 
-   if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
+   system("(echo mem > /sys/power/state) 2> /dev/null");
+
+   timerfd_gettime(timerfd,&spec);
+   if (spec.it_value.tv_sec != 0 || spec.it_value.tv_nsec != 0)
ksft_exit_fail_msg("Failed to enter Suspend state\n");
 
close(timerfd);
-- 
2.46.0




Re: [External] : Re: [PATCH v6.11 v5.15 v5.4 v4.19 1/1] selftests: breakpoints: use remaining time to check if suspend succeed

2024-09-23 Thread Shuah Khan

On 9/23/24 15:18, Yifei Liu wrote:




On Sep 23, 2024, at 1:56 PM, Shuah Khan  wrote:

On 9/23/24 14:47, Yifei Liu wrote:

We recently notice that the step_after_suspend_test would


noticed

How about change this to find?


Either is fine - it would found instead of find - or you could write
it as below:

"step_after_suspend_test fails with device busy error while
writing to /sys/power/state to start suspend."




fail on our plenty devices.  The test believesit failed to


"several of our devices"  believes it

enter suspend state with


Please do fix the above as pointed out earlier on v1.

Apologies, forget to fix. Will fix that.

$ sudo ./step_after_suspend_test
TAP version 13
Bail out! Failed to enter Suspend state
However, in the kernel message, I indeed see the system get
suspended and then wake up later.
[611172.033108] PM: suspend entry (s2idle)
[611172.044940] Filesystems sync: 0.006 seconds
[611172.052254] Freezing user space processes
[611172.059319] Freezing user space processes completed (elapsed 0.001 seconds)
[611172.067920] OOM killer disabled.
[611172.072465] Freezing remaining freezable tasks
[611172.080332] Freezing remaining freezable tasks completed (elapsed 0.001 
seconds)
[611172.089724] printk: Suspending console(s) (use no_console_suspend to debug)
[611172.117126] serial 00:03: disabled
--- some other hardware get reconnected ---
[611203.136277] OOM killer enabled.
[611203.140637] Restarting tasks ...
[611203.141135] usb 1-8.1: USB disconnect, device number 7
[611203.141755] done.
[611203.155268] random: crng reseeded on system resumption
[611203.162059] PM: suspend exit
After investigation, I notice that for the code block


noticed?

How about use find here?


It is the tense issue - found or noticed would work.



if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
ksft_exit_fail_msg("Failed to enter Suspend state\n");
The write will return -1 and errno is set to 16 (device busy).
It should be caused by the write function is not successfully returned
before the system suspend and the return value get messed when waking up.
As a result, It may be better to check the time passed of those few instructions
to determine whether the suspend is executed correctly for it is pretty hard to
execute those few lines for 5 seconds.
The timer to wake up the system is set to expired after 5 seconds and no-rearm.
If the timer remaining time is 0 second and 0 nano secomd, it means the timer
expired and wake the system up. Otherwise, the system could be considered to
enter the suspend state failed if there is any remaining time.


What would you get if you were to cat /sys/power/state at this point?

According to file kernel/power/suspend, the cat will always return freeze mem 
disk.


Does this fix the problem you are seeing? What is the outcome?

Yes, it fixes. The test would not fail for it believes the system does not went 
to suspend by mistake. It now could continue to the rest part of the test after 
suspend.


Can you add this to the change log.


Fixes: bfd092b8c2728 ("selftests: breakpoint: add step_after_suspend_test")
Reported-by: Sinadin Shan 
Signed-off-by: Yifei Liu 
---
  .../testing/selftests/breakpoints/step_after_suspend_test.c  | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c 
b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
index dfec31fb9b30d..33f5542bf741d 100644
--- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
+++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
@@ -152,7 +152,10 @@ void suspend(void)
   if (err < 0)
   ksft_exit_fail_msg("timerfd_settime() failed\n");
  - if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
+ system("(echo mem > /sys/power/state) 2> /dev/null");
+
+ timerfd_gettime(timerfd,&spec);
+ if (spec.it_value.tv_sec != 0 || spec.it_value.tv_nsec != 0)
   ksft_exit_fail_msg("Failed to enter Suspend state\n");
 close(timerfd);




thanks,
-- Shuah




Re: [External] : Re: [PATCH v6.11 v5.15 v5.4 v4.19 1/1] selftests: breakpoints: use remaining time to check if suspend succeed

2024-09-23 Thread Yifei Liu


> On Sep 23, 2024, at 2:46 PM, Shuah Khan  wrote:
> 
> On 9/23/24 15:18, Yifei Liu wrote:
>>> On Sep 23, 2024, at 1:56 PM, Shuah Khan  wrote:
>>> 
>>> On 9/23/24 14:47, Yifei Liu wrote:
 We recently notice that the step_after_suspend_test would
>>> 
>>> noticed
>> How about change this to find?
> 
> Either is fine - it would found instead of find - or you could write
> it as below:
> 
> "step_after_suspend_test fails with device busy error while
> writing to /sys/power/state to start suspend.”
Thanks
> 
>>> 
 fail on our plenty devices.  The test believesit failed to
>>> 
>>> "several of our devices"  believes it
 enter suspend state with
>>> 
>>> Please do fix the above as pointed out earlier on v1.
>> Apologies, forget to fix. Will fix that.
 $ sudo ./step_after_suspend_test
 TAP version 13
 Bail out! Failed to enter Suspend state
 However, in the kernel message, I indeed see the system get
 suspended and then wake up later.
 [611172.033108] PM: suspend entry (s2idle)
 [611172.044940] Filesystems sync: 0.006 seconds
 [611172.052254] Freezing user space processes
 [611172.059319] Freezing user space processes completed (elapsed 0.001 
 seconds)
 [611172.067920] OOM killer disabled.
 [611172.072465] Freezing remaining freezable tasks
 [611172.080332] Freezing remaining freezable tasks completed (elapsed 
 0.001 seconds)
 [611172.089724] printk: Suspending console(s) (use no_console_suspend to 
 debug)
 [611172.117126] serial 00:03: disabled
 --- some other hardware get reconnected ---
 [611203.136277] OOM killer enabled.
 [611203.140637] Restarting tasks ...
 [611203.141135] usb 1-8.1: USB disconnect, device number 7
 [611203.141755] done.
 [611203.155268] random: crng reseeded on system resumption
 [611203.162059] PM: suspend exit
 After investigation, I notice that for the code block
>>> 
>>> noticed?
>> How about use find here?
> 
> It is the tense issue - found or noticed would work.
Thanks
>>> 
 if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
 ksft_exit_fail_msg("Failed to enter Suspend state\n");
 The write will return -1 and errno is set to 16 (device busy).
 It should be caused by the write function is not successfully returned
 before the system suspend and the return value get messed when waking up.
 As a result, It may be better to check the time passed of those few 
 instructions
 to determine whether the suspend is executed correctly for it is pretty 
 hard to
 execute those few lines for 5 seconds.
 The timer to wake up the system is set to expired after 5 seconds and 
 no-rearm.
 If the timer remaining time is 0 second and 0 nano secomd, it means the 
 timer
 expired and wake the system up. Otherwise, the system could be considered 
 to
 enter the suspend state failed if there is any remaining time.
>>> 
>>> What would you get if you were to cat /sys/power/state at this point?
>> According to file kernel/power/suspend, the cat will always return freeze 
>> mem disk.
>>> Does this fix the problem you are seeing? What is the outcome?
>> Yes, it fixes. The test would not fail for it believes the system does not 
>> went to suspend by mistake. It now could continue to the rest part of the 
>> test after suspend.
> 
> Can you add this to the change log.
Sure. I will send a v3 later. 
> 
 Fixes: bfd092b8c2728 ("selftests: breakpoint: add step_after_suspend_test")
 Reported-by: Sinadin Shan 
 Signed-off-by: Yifei Liu 
 ---
  .../testing/selftests/breakpoints/step_after_suspend_test.c  | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)
 diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c 
 b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
 index dfec31fb9b30d..33f5542bf741d 100644
 --- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
 +++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
 @@ -152,7 +152,10 @@ void suspend(void)
   if (err < 0)
   ksft_exit_fail_msg("timerfd_settime() failed\n");
  - if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
 + system("(echo mem > /sys/power/state) 2> /dev/null");
 +
 + timerfd_gettime(timerfd,&spec);
 + if (spec.it_value.tv_sec != 0 || spec.it_value.tv_nsec != 0)
   ksft_exit_fail_msg("Failed to enter Suspend state\n");
 close(timerfd);
>>> 
> 
> thanks,
> — Shuah
Yifei




Re: [PATCH 1/2] unicode: kunit: refactor selftest to kunit tests

2024-09-23 Thread Gabriel Krisman Bertazi
Gabriela Bittencourt  writes:

>
> -static ssize_t utf8len(const struct unicode_map *um, enum utf8_normalization 
> n,
> - const char *s)
> +static ssize_t utf8len(const struct unicode_map *um, enum utf8_normalization 
> n, const char *s)
>  {

Please, do not make indentation-only changes, specially as part of a larger
change.  It makes the patch much harder to review.


>   return utf8nlen(um, n, s, (size_t)-1);
>  }
>  
>  static int utf8cursor(struct utf8cursor *u8c, const struct unicode_map *um,
> - enum utf8_normalization n, const char *s)
> +   enum utf8_normalization n, const char *s)

likewise.

>  {
>   return utf8ncursor(u8c, um, n, s, (unsigned int)-1);
>  }
>  
> -static void check_utf8_nfdi(struct unicode_map *um)
> +static void check_utf8_nfdi(struct kunit *test)
>  {
>   int i;
>   struct utf8cursor u8c;
> + struct unicode_map *um = test->priv;
>  
>   for (i = 0; i < ARRAY_SIZE(nfdi_test_data); i++) {
>   int len = strlen(nfdi_test_data[i].str);
> @@ -181,28 +161,29 @@ static void check_utf8_nfdi(struct unicode_map *um)
>   int j = 0;
>   unsigned char c;
>  
> - test((utf8len(um, UTF8_NFDI, nfdi_test_data[i].str) == nlen));
> - test((utf8nlen(um, UTF8_NFDI, nfdi_test_data[i].str, len) ==
> - nlen));
> + KUNIT_EXPECT_EQ(test, utf8len(um, UTF8_NFDI, 
> nfdi_test_data[i].str), nlen);
> + KUNIT_EXPECT_EQ(test, utf8nlen(um, UTF8_NFDI, 
> nfdi_test_data[i].str, len),
> + nlen);
> - if (utf8cursor(&u8c, um, UTF8_NFDI, nfdi_test_data[i].str) < 0)
> - pr_err("can't create cursor\n");
> + KUNIT_EXPECT_GE_MSG(test, utf8cursor(&u8c, um, UTF8_NFDI, 
> nfdi_test_data[i].str),
> + 0, "Can't create cursor\n");

These KUNIT_ macros are way less readable than the existing code,
IMO. the old macro makes it obvious what we are checking, without having
to dig into the definition.  But, meh, I can live with it.



>  
>   while ((c = utf8byte(&u8c)) > 0) {
> - test_f((c == nfdi_test_data[i].dec[j]),
> -"Unexpected byte 0x%x should be 0x%x\n",
> -c, nfdi_test_data[i].dec[j]);
> + KUNIT_EXPECT_EQ_MSG(test, c, nfdi_test_data[i].dec[j],
> + "Unexpected byte 0x%x should be 
> 0x%x\n",
> + c, nfdi_test_data[i].dec[j]);
>   j++;
>   }
>  
> - test((j == nlen));
> + KUNIT_EXPECT_EQ(test, j, nlen);
>   }
>  }
>  
> -static void check_utf8_nfdicf(struct unicode_map *um)
> +static void check_utf8_nfdicf(struct kunit *test)
>  {
>   int i;
>   struct utf8cursor u8c;
> + struct unicode_map *um = test->priv;
>  
>   for (i = 0; i < ARRAY_SIZE(nfdicf_test_data); i++) {
>   int len = strlen(nfdicf_test_data[i].str);
> @@ -210,29 +191,30 @@ static void check_utf8_nfdicf(struct unicode_map *um)
>   int j = 0;
>   unsigned char c;
>  
> - test((utf8len(um, UTF8_NFDICF, nfdicf_test_data[i].str) ==
> - nlen));
> - test((utf8nlen(um, UTF8_NFDICF, nfdicf_test_data[i].str, len) ==
> - nlen));
> + KUNIT_EXPECT_EQ(test, utf8len(um, UTF8_NFDICF, 
> nfdicf_test_data[i].str),
> + nlen);
> + KUNIT_EXPECT_EQ(test, utf8nlen(um, UTF8_NFDICF, 
> nfdicf_test_data[i].str, len),
> + nlen);
>  
> - if (utf8cursor(&u8c, um, UTF8_NFDICF,
> - nfdicf_test_data[i].str) < 0)
> - pr_err("can't create cursor\n");
> + KUNIT_EXPECT_GE_MSG(test,
> + utf8cursor(&u8c, um, UTF8_NFDICF, 
> nfdicf_test_data[i].str),
> + 0, "Can't create cursor\n");
>  
>   while ((c = utf8byte(&u8c)) > 0) {
> - test_f((c == nfdicf_test_data[i].ncf[j]),
> -"Unexpected byte 0x%x should be 0x%x\n",
> -c, nfdicf_test_data[i].ncf[j]);
> + KUNIT_EXPECT_EQ_MSG(test, c, nfdicf_test_data[i].ncf[j],
> + "Unexpected byte 0x%x should be 
> 0x%x\n",
> + c, nfdicf_test_data[i].ncf[j]);
>   j++;
>   }
>  
> - test((j == nlen));
> + KUNIT_EXPECT_EQ(test, j, nlen);
>   }
>  }
>  
> -static void check_utf8_comparisons(struct unicode_map *table)
> +static void check_utf8_comparisons(struct kunit *test)
>  {
>   int i;
> + struct unicode_map *um = test->priv;
>  
>   for (i = 0; i < ARRAY_SIZE(

Re: [External] : Re: [PATCH v6.11 v5.15 v5.4 v4.19 1/1] selftests: breakpoints: use remaining time to check if suspend succeed

2024-09-23 Thread Yifei Liu


> On Sep 23, 2024, at 1:56 PM, Shuah Khan  wrote:
> 
> On 9/23/24 14:47, Yifei Liu wrote:
>> We recently notice that the step_after_suspend_test would
> 
> noticed
How about change this to find?
> 
>> fail on our plenty devices.  The test believesit failed to
> 
> "several of our devices"  believes it
>> enter suspend state with
> 
> Please do fix the above as pointed out earlier on v1.
Apologies, forget to fix. Will fix that. 
>> $ sudo ./step_after_suspend_test
>> TAP version 13
>> Bail out! Failed to enter Suspend state
>> However, in the kernel message, I indeed see the system get
>> suspended and then wake up later.
>> [611172.033108] PM: suspend entry (s2idle)
>> [611172.044940] Filesystems sync: 0.006 seconds
>> [611172.052254] Freezing user space processes
>> [611172.059319] Freezing user space processes completed (elapsed 0.001 
>> seconds)
>> [611172.067920] OOM killer disabled.
>> [611172.072465] Freezing remaining freezable tasks
>> [611172.080332] Freezing remaining freezable tasks completed (elapsed 0.001 
>> seconds)
>> [611172.089724] printk: Suspending console(s) (use no_console_suspend to 
>> debug)
>> [611172.117126] serial 00:03: disabled
>> --- some other hardware get reconnected ---
>> [611203.136277] OOM killer enabled.
>> [611203.140637] Restarting tasks ...
>> [611203.141135] usb 1-8.1: USB disconnect, device number 7
>> [611203.141755] done.
>> [611203.155268] random: crng reseeded on system resumption
>> [611203.162059] PM: suspend exit
>> After investigation, I notice that for the code block
> 
> noticed?
How about use find here?
> 
>> if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
>> ksft_exit_fail_msg("Failed to enter Suspend state\n");
>> The write will return -1 and errno is set to 16 (device busy).
>> It should be caused by the write function is not successfully returned
>> before the system suspend and the return value get messed when waking up.
>> As a result, It may be better to check the time passed of those few 
>> instructions
>> to determine whether the suspend is executed correctly for it is pretty hard 
>> to
>> execute those few lines for 5 seconds.
>> The timer to wake up the system is set to expired after 5 seconds and 
>> no-rearm.
>> If the timer remaining time is 0 second and 0 nano secomd, it means the timer
>> expired and wake the system up. Otherwise, the system could be considered to
>> enter the suspend state failed if there is any remaining time.
> 
> What would you get if you were to cat /sys/power/state at this point?
According to file kernel/power/suspend, the cat will always return freeze mem 
disk. 

> Does this fix the problem you are seeing? What is the outcome?
Yes, it fixes. The test would not fail for it believes the system does not went 
to suspend by mistake. It now could continue to the rest part of the test after 
suspend. 
>> Fixes: bfd092b8c2728 ("selftests: breakpoint: add step_after_suspend_test")
>> Reported-by: Sinadin Shan 
>> Signed-off-by: Yifei Liu 
>> ---
>>  .../testing/selftests/breakpoints/step_after_suspend_test.c  | 5 -
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>> diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c 
>> b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
>> index dfec31fb9b30d..33f5542bf741d 100644
>> --- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
>> +++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
>> @@ -152,7 +152,10 @@ void suspend(void)
>>   if (err < 0)
>>   ksft_exit_fail_msg("timerfd_settime() failed\n");
>>  - if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
>> + system("(echo mem > /sys/power/state) 2> /dev/null");
>> +
>> + timerfd_gettime(timerfd,&spec);
>> + if (spec.it_value.tv_sec != 0 || spec.it_value.tv_nsec != 0)
>>   ksft_exit_fail_msg("Failed to enter Suspend state\n");
>> close(timerfd);
> 
> thanks,
> -- Shuah



Re: [PATCH 2/2] unicode: kunit: change tests filename and path

2024-09-23 Thread Shuah Khan

On 9/23/24 11:34, Gabriela Bittencourt wrote:

Change utf8 kunit test filename and path to follow the style
convention on Documentation/dev-tools/kunit/style.rst

Co-developed-by: Pedro Orlando 
Signed-off-by: Pedro Orlando 
Co-developed-by: Danilo Pereira 
Signed-off-by: Danilo Pereira 
Signed-off-by: Gabriela Bittencourt 
---
  fs/unicode/Makefile| 2 +-
  fs/unicode/{ => tests}/.kunitconfig| 0
  fs/unicode/{utf8-selftest.c => tests/utf8_kunit.c} | 0
  3 files changed, 1 insertion(+), 1 deletion(-)
  rename fs/unicode/{ => tests}/.kunitconfig (100%)
  rename fs/unicode/{utf8-selftest.c => tests/utf8_kunit.c} (100%)

diff --git a/fs/unicode/Makefile b/fs/unicode/Makefile
index 37bbcbc628a1..d95be7fb9f6b 100644
--- a/fs/unicode/Makefile
+++ b/fs/unicode/Makefile
@@ -4,7 +4,7 @@ ifneq ($(CONFIG_UNICODE),)
  obj-y += unicode.o
  endif
  obj-$(CONFIG_UNICODE) += utf8data.o
-obj-$(CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST) += utf8-selftest.o
+obj-$(CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST) += tests/utf8_kunit.o
  
  unicode-y := utf8-norm.o utf8-core.o
  
diff --git a/fs/unicode/.kunitconfig b/fs/unicode/tests/.kunitconfig

similarity index 100%
rename from fs/unicode/.kunitconfig
rename to fs/unicode/tests/.kunitconfig
diff --git a/fs/unicode/utf8-selftest.c b/fs/unicode/tests/utf8_kunit.c
similarity index 100%
rename from fs/unicode/utf8-selftest.c
rename to fs/unicode/tests/utf8_kunit.c


Looks good to me.

Reviewed-by: Shuah Khan 

thanks,
-- Shuah



Re: [PATCH v6.11 v5.15 v5.4 v4.19 1/1] selftests: breakpoints: use remaining time to check if suspend succeed

2024-09-23 Thread Shuah Khan

On 9/23/24 14:47, Yifei Liu wrote:

We recently notice that the step_after_suspend_test would


noticed


fail on our plenty devices.  The test believesit failed to


"several of our devices"  believes it

enter suspend state with


Please do fix the above as pointed out earlier on v1.


$ sudo ./step_after_suspend_test
TAP version 13
Bail out! Failed to enter Suspend state

However, in the kernel message, I indeed see the system get
suspended and then wake up later.

[611172.033108] PM: suspend entry (s2idle)
[611172.044940] Filesystems sync: 0.006 seconds
[611172.052254] Freezing user space processes
[611172.059319] Freezing user space processes completed (elapsed 0.001 seconds)
[611172.067920] OOM killer disabled.
[611172.072465] Freezing remaining freezable tasks
[611172.080332] Freezing remaining freezable tasks completed (elapsed 0.001 
seconds)
[611172.089724] printk: Suspending console(s) (use no_console_suspend to debug)
[611172.117126] serial 00:03: disabled
--- some other hardware get reconnected ---
[611203.136277] OOM killer enabled.
[611203.140637] Restarting tasks ...
[611203.141135] usb 1-8.1: USB disconnect, device number 7
[611203.141755] done.
[611203.155268] random: crng reseeded on system resumption
[611203.162059] PM: suspend exit

After investigation, I notice that for the code block


noticed?


if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
ksft_exit_fail_msg("Failed to enter Suspend state\n");

The write will return -1 and errno is set to 16 (device busy).
It should be caused by the write function is not successfully returned
before the system suspend and the return value get messed when waking up.
As a result, It may be better to check the time passed of those few instructions
to determine whether the suspend is executed correctly for it is pretty hard to
execute those few lines for 5 seconds.

The timer to wake up the system is set to expired after 5 seconds and no-rearm.
If the timer remaining time is 0 second and 0 nano secomd, it means the timer
expired and wake the system up. Otherwise, the system could be considered to
enter the suspend state failed if there is any remaining time.


What would you get if you were to cat /sys/power/state at this point?

Does this fix the problem you are seeing? What is the outcome?


Fixes: bfd092b8c2728 ("selftests: breakpoint: add step_after_suspend_test")
Reported-by: Sinadin Shan 
Signed-off-by: Yifei Liu 
---
  .../testing/selftests/breakpoints/step_after_suspend_test.c  | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c 
b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
index dfec31fb9b30d..33f5542bf741d 100644
--- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
+++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
@@ -152,7 +152,10 @@ void suspend(void)
if (err < 0)
ksft_exit_fail_msg("timerfd_settime() failed\n");
  
-	if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))

+   system("(echo mem > /sys/power/state) 2> /dev/null");
+
+   timerfd_gettime(timerfd,&spec);
+   if (spec.it_value.tv_sec != 0 || spec.it_value.tv_nsec != 0)
ksft_exit_fail_msg("Failed to enter Suspend state\n");
  
  	close(timerfd);


thanks,
-- Shuah



Re: [PATCH 1/2] unicode: kunit: refactor selftest to kunit tests

2024-09-23 Thread Shuah Khan

On 9/23/24 11:34, Gabriela Bittencourt wrote:

Instead of creating 'test' functions, use kunit functions to test
utf-8 support in unicode subsystem.


Can you elaborate on the reefactoring changes. This will help
others who would want to take on such refactoring in the future.



Co-developed-by: Pedro Orlando 
Signed-off-by: Pedro Orlando 
Co-developed-by: Danilo Pereira 
Signed-off-by: Danilo Pereira 
Signed-off-by: Gabriela Bittencourt 
---
  fs/unicode/.kunitconfig|   3 +
  fs/unicode/Kconfig |   5 +-
  fs/unicode/Makefile|   2 +-
  fs/unicode/utf8-selftest.c | 152 +
  4 files changed, 76 insertions(+), 86 deletions(-)
  create mode 100644 fs/unicode/.kunitconfig

diff --git a/fs/unicode/.kunitconfig b/fs/unicode/.kunitconfig
new file mode 100644
index ..62dd5c171f9c
--- /dev/null
+++ b/fs/unicode/.kunitconfig
@@ -0,0 +1,3 @@
+CONFIG_KUNIT=y
+CONFIG_UNICODE=y
+CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST=y
diff --git a/fs/unicode/Kconfig b/fs/unicode/Kconfig
index da786a687fdc..4ad2c36550f1 100644
--- a/fs/unicode/Kconfig
+++ b/fs/unicode/Kconfig
@@ -10,6 +10,7 @@ config UNICODE
  be a separate loadable module that gets requested only when a file
  system actually use it.
  
-config UNICODE_NORMALIZATION_SELFTEST

+config UNICODE_NORMALIZATION_KUNIT_TEST
tristate "Test UTF-8 normalization support"
-   depends on UNICODE
+   depends on UNICODE && KUNIT
+   default KUNIT_ALL_TESTS
diff --git a/fs/unicode/Makefile b/fs/unicode/Makefile
index e309afe2b2bb..37bbcbc628a1 100644
--- a/fs/unicode/Makefile
+++ b/fs/unicode/Makefile
@@ -4,7 +4,7 @@ ifneq ($(CONFIG_UNICODE),)
  obj-y += unicode.o
  endif
  obj-$(CONFIG_UNICODE) += utf8data.o
-obj-$(CONFIG_UNICODE_NORMALIZATION_SELFTEST) += utf8-selftest.o
+obj-$(CONFIG_UNICODE_NORMALIZATION_KUNIT_TEST) += utf8-selftest.o
  
  unicode-y := utf8-norm.o utf8-core.o
  
diff --git a/fs/unicode/utf8-selftest.c b/fs/unicode/utf8-selftest.c

index 600e15efe9ed..54ded8db6b1c 100644
--- a/fs/unicode/utf8-selftest.c
+++ b/fs/unicode/utf8-selftest.c
@@ -1,38 +1,18 @@
  // SPDX-License-Identifier: GPL-2.0-only
  /*
- * Kernel module for testing utf-8 support.
+ * KUnit tests for utf-8 support
   *
   * Copyright 2017 Collabora Ltd.
   */
  
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

-
-#include 
-#include 
  #include 
-#include 
+#include 
  
  #include "utf8n.h"
  
-static unsigned int failed_tests;

-static unsigned int total_tests;
-
  /* Tests will be based on this version. */
  #define UTF8_LATEST   UNICODE_AGE(12, 1, 0)
  
-#define _test(cond, func, line, fmt, ...) do {\

-   total_tests++;  \
-   if (!cond) {\
-   failed_tests++; \
-   pr_err("test %s:%d Failed: %s%s", \
-  func, line, #cond, (fmt?":":"."));   \
-   if (fmt)\
-   pr_err(fmt, ##__VA_ARGS__); \
-   }   \
-   } while (0)
-#define test_f(cond, fmt, ...) _test(cond, __func__, __LINE__, fmt, 
##__VA_ARGS__)
-#define test(cond) _test(cond, __func__, __LINE__, "")
-
  static const struct {
/* UTF-8 strings in this vector _must_ be NULL-terminated. */
unsigned char str[10];
@@ -158,22 +138,22 @@ static const struct {
}
  };
  
-static ssize_t utf8len(const struct unicode_map *um, enum utf8_normalization n,

-   const char *s)
+static ssize_t utf8len(const struct unicode_map *um, enum utf8_normalization 
n, const char *s)


Keep "const char *s" on the second line.


  {
return utf8nlen(um, n, s, (size_t)-1);
  }
  


Rest looks good to me.

thanks,
-- Shuah




[PATCH v3 v6.11 v5.15 v5.4 v4.19 1/1] selftests: breakpoints: use remaining time to check if suspend succeed

2024-09-23 Thread Yifei Liu
"step_after_suspend_test fails with device busy error while
writing to /sys/power/state to start suspend."  The test believes
it failed to enter suspend state with

$ sudo ./step_after_suspend_test
TAP version 13
Bail out! Failed to enter Suspend state

However, in the kernel message, I indeed see the system get
suspended and then wake up later.

[611172.033108] PM: suspend entry (s2idle)
[611172.044940] Filesystems sync: 0.006 seconds
[611172.052254] Freezing user space processes
[611172.059319] Freezing user space processes completed (elapsed 0.001 seconds)
[611172.067920] OOM killer disabled.
[611172.072465] Freezing remaining freezable tasks
[611172.080332] Freezing remaining freezable tasks completed (elapsed 0.001 
seconds)
[611172.089724] printk: Suspending console(s) (use no_console_suspend to debug)
[611172.117126] serial 00:03: disabled
--- some other hardware get reconnected ---
[611203.136277] OOM killer enabled.
[611203.140637] Restarting tasks ...
[611203.141135] usb 1-8.1: USB disconnect, device number 7
[611203.141755] done.
[611203.155268] random: crng reseeded on system resumption
[611203.162059] PM: suspend exit

After investigation, I noticed that for the code block
if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
ksft_exit_fail_msg("Failed to enter Suspend state\n");

The write will return -1 and errno is set to 16 (device busy).
It should be caused by the write function is not successfully returned
before the system suspend and the return value get messed when waking up.
As a result, It may be better to check the time passed of those few instructions
to determine whether the suspend is executed correctly for it is pretty hard to
execute those few lines for 5 seconds.

The timer to wake up the system is set to expire after 5 seconds and no re-arm.
If the timer remaining time is 0 second and 0 nano secomd, it means the timer
expired and wake the system up. Otherwise, the system could be considered to
enter the suspend state failed if there is any remaining time.

After appling this patch, the test would not fail for it believes the system 
does
not go to suspend by mistake. It now could continue to the rest part of the 
test after suspend.

Fixes: bfd092b8c2728 ("selftests: breakpoint: add step_after_suspend_test")
Reported-by: Sinadin Shan 
Signed-off-by: Yifei Liu 
---
 .../testing/selftests/breakpoints/step_after_suspend_test.c  | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c 
b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
index dfec31fb9b30d..33f5542bf741d 100644
--- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
+++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
@@ -152,7 +152,10 @@ void suspend(void)
if (err < 0)
ksft_exit_fail_msg("timerfd_settime() failed\n");
 
-   if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
+   system("(echo mem > /sys/power/state) 2> /dev/null");
+
+   timerfd_gettime(timerfd,&spec);
+   if (spec.it_value.tv_sec != 0 || spec.it_value.tv_nsec != 0)
ksft_exit_fail_msg("Failed to enter Suspend state\n");
 
close(timerfd);
-- 
2.46.0




[PATCH] lib: math: Move kunit tests into tests/ subdir

2024-09-23 Thread Luis Felipe Hernandez
Cc: linux-kselftest@vger.kernel.org,
kunit-...@googlegroups.com,
sk...@linuxfoundation.org,
rica...@marliere.net,
linux-kernel-ment...@lists.linuxfoundation.org

This patch is a follow-up task from a discussion stemming from point 3
in a recent patch introducing the int_pow kunit test [1] and
documentation regarding kunit test style and nomenclature [2].

Colocate all kunit test suites in lib/math/tests/ and
follow the recommended naming convention for files _kunit.c
and kconfig entries CONFIG__KUNIT_TEST.

Link: 
https://lore.kernel.org/all/CABVgOS=-vh5TqHFCq_jo=ffq8v_nggr6jspnozag3e6+19y...@mail.gmail.com/
 [1]
Link: https://docs.kernel.org/dev-tools/kunit/style.html [2]

Signed-off-by: Luis Felipe Hernandez 
---
 arch/m68k/configs/amiga_defconfig   | 2 +-
 arch/m68k/configs/apollo_defconfig  | 2 +-
 arch/m68k/configs/atari_defconfig   | 2 +-
 arch/m68k/configs/bvme6000_defconfig| 2 +-
 arch/m68k/configs/hp300_defconfig   | 2 +-
 arch/m68k/configs/mac_defconfig | 2 +-
 arch/m68k/configs/multi_defconfig   | 2 +-
 arch/m68k/configs/mvme147_defconfig | 2 +-
 arch/m68k/configs/mvme16x_defconfig | 2 +-
 arch/m68k/configs/q40_defconfig | 2 +-
 arch/m68k/configs/sun3_defconfig| 2 +-
 arch/m68k/configs/sun3x_defconfig   | 2 +-
 arch/powerpc/configs/ppc64_defconfig| 2 +-
 lib/Kconfig.debug   | 6 +++---
 lib/math/Makefile   | 5 +
 lib/math/tests/Makefile | 5 -
 lib/math/{test_div64.c => tests/div64_kunit.c}  | 0
 .../mul_u64_u64_div_u64_kunit.c}| 0
 lib/math/{rational-test.c => tests/rational_kunit.c}| 0
 19 files changed, 21 insertions(+), 21 deletions(-)
 rename lib/math/{test_div64.c => tests/div64_kunit.c} (100%)
 rename lib/math/{test_mul_u64_u64_div_u64.c => 
tests/mul_u64_u64_div_u64_kunit.c} (100%)
 rename lib/math/{rational-test.c => tests/rational_kunit.c} (100%)

diff --git a/arch/m68k/configs/amiga_defconfig 
b/arch/m68k/configs/amiga_defconfig
index d01dc47d52ea..7ba9311c084c 100644
--- a/arch/m68k/configs/amiga_defconfig
+++ b/arch/m68k/configs/amiga_defconfig
@@ -619,7 +619,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
diff --git a/arch/m68k/configs/apollo_defconfig 
b/arch/m68k/configs/apollo_defconfig
index 46808e581d7b..273fe4032b85 100644
--- a/arch/m68k/configs/apollo_defconfig
+++ b/arch/m68k/configs/apollo_defconfig
@@ -576,7 +576,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
diff --git a/arch/m68k/configs/atari_defconfig 
b/arch/m68k/configs/atari_defconfig
index 4469a7839c9d..9976cda99fc1 100644
--- a/arch/m68k/configs/atari_defconfig
+++ b/arch/m68k/configs/atari_defconfig
@@ -596,7 +596,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
diff --git a/arch/m68k/configs/bvme6000_defconfig 
b/arch/m68k/configs/bvme6000_defconfig
index c0719322c028..f59082c8fe06 100644
--- a/arch/m68k/configs/bvme6000_defconfig
+++ b/arch/m68k/configs/bvme6000_defconfig
@@ -568,7 +568,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
diff --git a/arch/m68k/configs/hp300_defconfig 
b/arch/m68k/configs/hp300_defconfig
index 8d429e63f8f2..6db3556da9ac 100644
--- a/arch/m68k/configs/hp300_defconfig
+++ b/arch/m68k/configs/hp300_defconfig
@@ -578,7 +578,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
diff --git a/arch/m68k/configs/mac_defconfig b/arch/m68k/configs/mac_defconfig
index bafd33da27c1..25c06b5c83ee 100644
--- a/arch/m68k/configs/mac_defconfig
+++ b/arch/m68k/configs/mac_defconfig
@@ -595,7 +595,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
diff --git a/arch/m68k/configs/multi_de

Re: [PATCH] selftests: vDSO: fix compile error for vdso_test_getrandom

2024-09-23 Thread Yu Liao
Hi,
On 2024/9/23 23:30, Shuah Khan wrote:
> On 9/20/24 09:31, Jason A. Donenfeld wrote:
>> Indeed probably  is what's wanted here.
>>
> 
> Yu Liao, Please send v2 as per the review comments.
> 

CLONE_NEWTIME was introduced in glibc-2.36, which was released in August 2022.
As Christophe mentioned,  is already indirectly included by
, so this issue does not exist if glibc version higher than 2.36.

Additionally, CLONE_NEWTIME was introduced in Linux 5.6 in March 2020, the
CLONE_ macros are also defined in , which is part of the
kernel-header package.

My environment is Ubuntu 22.04 (Linux 5.15 + glibc 2.35), after upgrading to a
newer version of glibc, the issue appears to be resolved.
It seems to me that including  might be unnecessary. I would greatly
appreciate your guidance on how best to handle this situation.

Best regards,
Yu



[PATCH v2] lib: math: Move kunit tests into tests/ subdir

2024-09-23 Thread Luis Felipe Hernandez
This patch is a follow-up task from a discussion stemming from point 3
in a recent patch introducing the int_pow kunit test [1] and
documentation regarding kunit test style and nomenclature [2].

Colocate all kunit test suites in lib/math/tests/ and
follow recommended naming convention for files _kunit.c
and kconfig entries CONFIG__KUNIT_TEST.

Link: 
https://lore.kernel.org/all/CABVgOS=-vh5TqHFCq_jo=ffq8v_nggr6jspnozag3e6+19y...@mail.gmail.com/
 [1]
Link: https://docs.kernel.org/dev-tools/kunit/style.html [2]

Signed-off-by: Luis Felipe Hernandez 
---
Changes in v2: Fix cc recipient list inclusion in cover letter
---
 arch/m68k/configs/amiga_defconfig   | 2 +-
 arch/m68k/configs/apollo_defconfig  | 2 +-
 arch/m68k/configs/atari_defconfig   | 2 +-
 arch/m68k/configs/bvme6000_defconfig| 2 +-
 arch/m68k/configs/hp300_defconfig   | 2 +-
 arch/m68k/configs/mac_defconfig | 2 +-
 arch/m68k/configs/multi_defconfig   | 2 +-
 arch/m68k/configs/mvme147_defconfig | 2 +-
 arch/m68k/configs/mvme16x_defconfig | 2 +-
 arch/m68k/configs/q40_defconfig | 2 +-
 arch/m68k/configs/sun3_defconfig| 2 +-
 arch/m68k/configs/sun3x_defconfig   | 2 +-
 arch/powerpc/configs/ppc64_defconfig| 2 +-
 lib/Kconfig.debug   | 6 +++---
 lib/math/Makefile   | 5 +
 lib/math/tests/Makefile | 5 -
 lib/math/{test_div64.c => tests/div64_kunit.c}  | 0
 .../mul_u64_u64_div_u64_kunit.c}| 0
 lib/math/{rational-test.c => tests/rational_kunit.c}| 0
 19 files changed, 21 insertions(+), 21 deletions(-)
 rename lib/math/{test_div64.c => tests/div64_kunit.c} (100%)
 rename lib/math/{test_mul_u64_u64_div_u64.c => 
tests/mul_u64_u64_div_u64_kunit.c} (100%)
 rename lib/math/{rational-test.c => tests/rational_kunit.c} (100%)

diff --git a/arch/m68k/configs/amiga_defconfig 
b/arch/m68k/configs/amiga_defconfig
index d01dc47d52ea..7ba9311c084c 100644
--- a/arch/m68k/configs/amiga_defconfig
+++ b/arch/m68k/configs/amiga_defconfig
@@ -619,7 +619,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
diff --git a/arch/m68k/configs/apollo_defconfig 
b/arch/m68k/configs/apollo_defconfig
index 46808e581d7b..273fe4032b85 100644
--- a/arch/m68k/configs/apollo_defconfig
+++ b/arch/m68k/configs/apollo_defconfig
@@ -576,7 +576,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
diff --git a/arch/m68k/configs/atari_defconfig 
b/arch/m68k/configs/atari_defconfig
index 4469a7839c9d..9976cda99fc1 100644
--- a/arch/m68k/configs/atari_defconfig
+++ b/arch/m68k/configs/atari_defconfig
@@ -596,7 +596,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
diff --git a/arch/m68k/configs/bvme6000_defconfig 
b/arch/m68k/configs/bvme6000_defconfig
index c0719322c028..f59082c8fe06 100644
--- a/arch/m68k/configs/bvme6000_defconfig
+++ b/arch/m68k/configs/bvme6000_defconfig
@@ -568,7 +568,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
diff --git a/arch/m68k/configs/hp300_defconfig 
b/arch/m68k/configs/hp300_defconfig
index 8d429e63f8f2..6db3556da9ac 100644
--- a/arch/m68k/configs/hp300_defconfig
+++ b/arch/m68k/configs/hp300_defconfig
@@ -578,7 +578,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
diff --git a/arch/m68k/configs/mac_defconfig b/arch/m68k/configs/mac_defconfig
index bafd33da27c1..25c06b5c83ee 100644
--- a/arch/m68k/configs/mac_defconfig
+++ b/arch/m68k/configs/mac_defconfig
@@ -595,7 +595,7 @@ CONFIG_KUNIT=m
 CONFIG_KUNIT_ALL_TESTS=m
 CONFIG_TEST_DHRY=m
 CONFIG_TEST_MIN_HEAP=m
-CONFIG_TEST_DIV64=m
+CONFIG_DIV64_KUNIT_TEST=m
 CONFIG_REED_SOLOMON_TEST=m
 CONFIG_ATOMIC64_SELFTEST=m
 CONFIG_ASYNC_RAID6_TEST=m
diff --git a/arch/m68k/configs/multi_defconfig 
b/arch/m68k/configs/multi_defconfig
index 6f5ca3f85ea1..35e57e0ee139 100644
--- a/arch/m68k/configs/multi_defc