diff mbox series

[v1] Fix wqueue09 according with 5.17 kernel updates

Message ID 20220328123114.31881-1-andrea.cervesato@suse.de
State Superseded
Headers show
Series [v1] Fix wqueue09 according with 5.17 kernel updates | expand

Commit Message

Andrea Cervesato March 28, 2022, 12:31 p.m. UTC
Kernel 5.17 introduced many changes in the watch_queue support. In
particular, commit 3b4c0371928c17af03e8397ac842346624017ce6 changes the
behaviour of IOC_WATCH_QUEUE_SET_SIZE and ioctl control over watch_queue
buffer size: now we need to generate more events than before. In
particular, more than the bitmap size to the number of notes.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
---
 testcases/kernel/watchqueue/wqueue09.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Cyril Hrubis March 28, 2022, 3:01 p.m. UTC | #1
Hi!
> Kernel 5.17 introduced many changes in the watch_queue support. In
> particular, commit 3b4c0371928c17af03e8397ac842346624017ce6 changes the
> behaviour of IOC_WATCH_QUEUE_SET_SIZE and ioctl control over watch_queue
> buffer size: now we need to generate more events than before. In
> particular, more than the bitmap size to the number of notes.
> 
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
> ---
>  testcases/kernel/watchqueue/wqueue09.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/testcases/kernel/watchqueue/wqueue09.c b/testcases/kernel/watchqueue/wqueue09.c
> index 55d567249..86feebf4a 100644
> --- a/testcases/kernel/watchqueue/wqueue09.c
> +++ b/testcases/kernel/watchqueue/wqueue09.c
> @@ -29,14 +29,14 @@ static void saw_data_loss(struct watch_notification *n,
>  
>  static void run(void)
>  {
> -	int fd;
> +	int fd, i;
>  	key_serial_t key;
>  
> -	fd = wqueue_watch(1, &wqueue_filter);
> +	fd = wqueue_watch(32, &wqueue_filter);

We may as well keep the 1 here, kernel will rount it to smallest
possible size anyways.

>  	key = wqueue_add_key(fd);
> -	keyctl(KEYCTL_UPDATE, key, "b", 1);
> -	keyctl(KEYCTL_REVOKE, key);
> +	for (i = 0; i < 256; i++)
> +		keyctl(KEYCTL_UPDATE, key, "b", 1);

Have you tried this on any machine with 64k pages? If the minimal size
is rounded to a PAGE_SIZE and we get 32 messages in 4k page that would
mean that we would fit 512 messages in 64k page. So maybe we would need
512 messages on 65k page size?

>  	data_lost = 0;
>  	while (!data_lost)
> -- 
> 2.35.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
Petr Vorel March 29, 2022, 4:03 p.m. UTC | #2
Hi Cyril, Andrea,

> >  testcases/kernel/watchqueue/wqueue09.c | 8 ++++----
...
> >  	key = wqueue_add_key(fd);
> > -	keyctl(KEYCTL_UPDATE, key, "b", 1);
> > -	keyctl(KEYCTL_REVOKE, key);
> > +	for (i = 0; i < 256; i++)
> > +		keyctl(KEYCTL_UPDATE, key, "b", 1);

> Have you tried this on any machine with 64k pages? If the minimal size
> is rounded to a PAGE_SIZE and we get 32 messages in 4k page that would
> mean that we would fit 512 messages in 64k page. So maybe we would need
> 512 messages on 65k page size?

FYI while test works on small -i, it blocks on higher:

./wqueue09 -i1000
...
common.h:153: TINFO: NOTIFY[000]: ty=000000 sy=01 i=00000008
wqueue09.c:48: TPASS: Meta loss notification received
common.h:134: TINFO: Reading watch queue events
common.h:153: TINFO: NOTIFY[000]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[010]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[020]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[030]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[040]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[050]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[060]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[070]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[080]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[090]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[0a0]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[0b0]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[0c0]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[0d0]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[0e0]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[0f0]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[100]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[110]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[120]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[130]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[140]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[150]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[160]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[170]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[180]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[190]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[1a0]: ty=000001 sy=01 i=00000110
common.h:134: TINFO: Reading watch queue events
common.h:153: TINFO: NOTIFY[000]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[010]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[020]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[030]: ty=000001 sy=01 i=00000110
common.h:153: TINFO: NOTIFY[040]: ty=000001 sy=01 i=00000110
common.h:134: TINFO: Reading watch queue events
common.h:153: TINFO: NOTIFY[000]: ty=000000 sy=01 i=00000008
wqueue09.c:48: TPASS: Meta loss notification received
common.h:134: TINFO: Reading watch queue events
=> timeouts

I tested this on ppc64le with 65k page size on 5.17.0-rc5-150400.9-default
But it's not page size specific, as it fails also on x86_64 with the default 4k
page size.

And *without* this patch it's also broken with higher -i (tested on both x86_64
with the default 4k page size and ppc64le with 65k):

./wqueue09 -i1000
wqueue09.c:48: TPASS: Meta loss notification received
common.h:134: TINFO: Reading watch queue events
common.h:152: TINFO: NOTIFY[000]: ty=000001 sy=01 i=00000110
common.h:134: TINFO: Reading watch queue events
common.h:152: TINFO: NOTIFY[000]: ty=000000 sy=01 i=00000008
wqueue09.c:48: TPASS: Meta loss notification received
common.h:86: TBROK: add_key error: EDQUOT

Kind regards,
Petr
Cyril Hrubis March 30, 2022, 9:25 a.m. UTC | #3
Hi!
> FYI while test works on small -i, it blocks on higher:
> 
> ./wqueue09 -i1000
> ...
> common.h:153: TINFO: NOTIFY[000]: ty=000000 sy=01 i=00000008
> wqueue09.c:48: TPASS: Meta loss notification received
> common.h:134: TINFO: Reading watch queue events
> common.h:153: TINFO: NOTIFY[000]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[010]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[020]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[030]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[040]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[050]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[060]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[070]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[080]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[090]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[0a0]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[0b0]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[0c0]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[0d0]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[0e0]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[0f0]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[100]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[110]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[120]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[130]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[140]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[150]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[160]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[170]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[180]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[190]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[1a0]: ty=000001 sy=01 i=00000110
> common.h:134: TINFO: Reading watch queue events
> common.h:153: TINFO: NOTIFY[000]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[010]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[020]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[030]: ty=000001 sy=01 i=00000110
> common.h:153: TINFO: NOTIFY[040]: ty=000001 sy=01 i=00000110
> common.h:134: TINFO: Reading watch queue events
> common.h:153: TINFO: NOTIFY[000]: ty=000000 sy=01 i=00000008
> wqueue09.c:48: TPASS: Meta loss notification received
> common.h:134: TINFO: Reading watch queue events
> => timeouts
> 
> I tested this on ppc64le with 65k page size on 5.17.0-rc5-150400.9-default
> But it's not page size specific, as it fails also on x86_64 with the default 4k
> page size.

That would mean that the keyctl() operations did fail, I guess that we
should check the results of these calls.

> And *without* this patch it's also broken with higher -i (tested on both x86_64
> with the default 4k page size and ppc64le with 65k):
> 
> ./wqueue09 -i1000
> wqueue09.c:48: TPASS: Meta loss notification received
> common.h:134: TINFO: Reading watch queue events
> common.h:152: TINFO: NOTIFY[000]: ty=000001 sy=01 i=00000110
> common.h:134: TINFO: Reading watch queue events
> common.h:152: TINFO: NOTIFY[000]: ty=000000 sy=01 i=00000008
> wqueue09.c:48: TPASS: Meta loss notification received
> common.h:86: TBROK: add_key error: EDQUOT

This may be solveable by moving the add_key() call to the test setup.
diff mbox series

Patch

diff --git a/testcases/kernel/watchqueue/wqueue09.c b/testcases/kernel/watchqueue/wqueue09.c
index 55d567249..86feebf4a 100644
--- a/testcases/kernel/watchqueue/wqueue09.c
+++ b/testcases/kernel/watchqueue/wqueue09.c
@@ -29,14 +29,14 @@  static void saw_data_loss(struct watch_notification *n,
 
 static void run(void)
 {
-	int fd;
+	int fd, i;
 	key_serial_t key;
 
-	fd = wqueue_watch(1, &wqueue_filter);
+	fd = wqueue_watch(32, &wqueue_filter);
 
 	key = wqueue_add_key(fd);
-	keyctl(KEYCTL_UPDATE, key, "b", 1);
-	keyctl(KEYCTL_REVOKE, key);
+	for (i = 0; i < 256; i++)
+		keyctl(KEYCTL_UPDATE, key, "b", 1);
 
 	data_lost = 0;
 	while (!data_lost)