Fanotify tests for FAN_MARK_EVICTABLE
cover Fanotify tests for FAN_MARK_EVICTABLE
Hi Petr,
FAN_MARK_EVICTABLE feature was merge in v5.19-rc1.
Here are the tests for it.
inotify12 is a test for an unrelated fix.
Note that fanotify23 is run on ext2.
That is because, I could not find a way to reliably evict an inode on any filesystem and the rain dance I did with vfs_cache_pressure and drop_caches works reliably with ext2 on my test setup.
If that turns out not to work on other systems, we will need to re-think of a more aggressive way to force inode eviction.
Thanks,
Amir.
Amir Goldstein (5):
syscalls/inotify12: Introduce test for inotify mask flags syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test syscalls/fanotify10: Watch directory that is not the mount path syscalls/fanotify10: Mount cycle between test cases syscalls/fanotify10: Add test cases for evictable ignore mark
runtest/syscalls | 2 + testcases/kernel/syscalls/fanotify/.gitignore | 1 + testcases/kernel/syscalls/fanotify/fanotify.h | 4 + .../kernel/syscalls/fanotify/fanotify10.c | 131 +++++++-- .../kernel/syscalls/fanotify/fanotify23.c | 258 ++++++++++++++++++ testcases/kernel/syscalls/inotify/.gitignore | 1 + testcases/kernel/syscalls/inotify/inotify12.c | 168 ++++++++++++ 7 files changed, 546 insertions(+), 19 deletions(-) create mode 100644 testcases/kernel/syscalls/fanotify/fanotify23.c create mode 100644 testcases/kernel/syscalls/inotify/inotify12.c
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/5 syscalls/inotify12: Introduce test for inotify mask flags
Test behavior of IN_ONESHOT and IN_EXCL_UNLINK.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/inotify/.gitignore | 1 + testcases/kernel/syscalls/inotify/inotify12.c | 168 ++++++++++++++++++ 3 files changed, 170 insertions(+) create mode 100644 testcases/kernel/syscalls/inotify/inotify12.c
runtest/syscalls +1 -0
@@ -588,6 +588,7 @@ inotify08 inotify08 inotify09 inotify09 inotify10 inotify10 inotify11 inotify11 +inotify12 inotify12 fanotify01 fanotify01 fanotify02 fanotify02
testcases/kernel/syscalls/inotify/.gitignore +1 -0
@@ -9,3 +9,4 @@ /inotify09 /inotify10 /inotify11 +/inotify12
testcases/kernel/syscalls/inotify/inotify12.c new file +168 -0
168 lines not on this page · raw message
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
Quoted 184 lines · Amir Goldstein
Test behavior of
IN_ONESHOTandIN_EXCL_UNLINK.Signed-off-by Amir Goldstein <[email protected]>--- runtest/syscalls | 1 + testcases/kernel/syscalls/inotify/.gitignore | 1 + testcases/kernel/syscalls/inotify/inotify12.c | 168 ++++++++++++++++++ 3 files changed, 170 insertions(+) create mode 100644 testcases/kernel/syscalls/inotify/inotify12.cruntest/syscalls +1
-0@@ -588,6 +588,7 @@ inotify08 inotify08 inotify09 inotify09 inotify10 inotify10 inotify11 inotify11 +inotify12 inotify12 fanotify01 fanotify01 fanotify02 fanotify02testcases/kernel/syscalls/inotify/.gitignore +1
-0@@ -9,3 +9,4 @@ /inotify09 /inotify10 /inotify11 +/inotify12testcases/kernel/syscalls/inotify/inotify12.c new file +146
-0@@ -0,0 +1,168 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2022 CTERA Networks. All Rights Reserved. +* +* Author: Amir Goldstein <[email protected]> +*/ + +/*\ +* [Description] +* Test special inotify mask flags. +* +* Regression test for kernel commit a32e697cda27: +* +* inotify: show inotify mask flags in proc fdinfo +*/ + +#include "config.h" + +#include <stdio.h> +#include <unistd.h> +#include <fcntl.h> +#include <signal.h> +#include <sys/wait.h> + +#include "tst_test.h" +#include "tst_safe_macros.h" +#include "inotify.h" + +#if defined(HAVE_SYS_INOTIFY_H ) +#include <sys/inotify.h> + +#define EVENT_MAX 32 +/* Size of the event structure, not including the name */ +#define EVENT_SIZE (sizeof(struct inotify_event)) +#define EVENT_BUF_LEN (EVENT_MAX * (EVENT_SIZE + 16)) + +#define TEST_FILE "test_file" + +static char event_buf[EVENT_BUF_LEN ]; + +static struct tcase { +const char *tname; +unsigned int mask; +int expect_events; +} tcases[] = { + { +"Watch for multi events" , +IN_MODIFY , +2 , + }, + { +"Watch for single event" , +IN_MODIFY |IN_ONESHOT , +1 , + }, + { +"Watch for events on linked file" , +IN_MODIFY |IN_EXCL_UNLINK , +1 , + }, +}; + +int fd_notify; + +static void verify_inotify (unsigned int n) +{ +struct tcase *tc = &tcases[n]; +int fd, len; +unsigned int tmpmask; +char procfdinfo[100 ]; +struct inotify_event *event = (struct inotify_event *)event_buf; + +tst_res (TINFO ,"Test #%d: %s" , n, tc->tname); + + fd_notify =SAFE_MYINOTIFY_INIT1 (O_NONBLOCK ); + +SAFE_FILE_PRINTF (TEST_FILE ,"1" ); + +SAFE_MYINOTIFY_ADD_WATCH (fd_notify,"." , tc->mask); + +sprintf (procfdinfo,"/proc/%d/fdinfo/%d" , (int )getpid (), fd_notify); +if (FILE_LINES_SCANF (procfdinfo,"inotify wd:%*d ino:%*x sdev:%*x mask:%x" , + &tmpmask)) { +tst_res (TFAIL ,"Could not parse inotify fdinfo" ); + }else if (tmpmask != tc->mask) { +tst_res (TFAIL ,"Incorrect mask %x in inotify fdinfo (expected %x)" , + tmpmask, tc->mask); + }else { +tst_res (TPASS ,"Correct mask in inotify fdinfo" ); + } + + fd =SAFE_OPEN (TEST_FILE ,O_RDWR ); +SAFE_WRITE (1 , fd,"2" ,1 ); + +/* +* Read the 1st IN_MODIFY event +*/ + len =SAFE_READ (0 , fd_notify, event_buf,EVENT_BUF_LEN ); + +if (len < (int )sizeof (*event)) { +tst_res (TFAIL ,"Got no events" ); + }else if (event->mask ==IN_MODIFY ) { +tst_res (TPASS ,"Got 1st event as expected" ); + }else { +tst_res (TFAIL ,"Got event 0x%x (expected 0x%x)" , + event->mask,IN_MODIFY ); + } + +/* +* Unlink file so IN_EXCL_UNLINK won't get IN_ACCESS event. +* IN_ONESHOT won't get IN_ACCESS event because IN_MODIFY +* was already generated. +*/ +SAFE_UNLINK (TEST_FILE ); +SAFE_WRITE (1 , fd,"3" ,1 ); +SAFE_CLOSE (fd); + +/* +* Possibly read the 2nd IN_MODIFY event +*/ + errno =0 ; + len =read (fd_notify, event_buf,EVENT_BUF_LEN ); +SAFE_CLOSE (fd_notify); +if (len <0 && errno ==EAGAIN ) { +/* Treat no event same as we treat IN_IGNORED */ + event->mask =IN_IGNORED ; + }else if (len < (int )sizeof (*event)) { +tst_res (TFAIL |TERRNO ,"Failed to read events" ); +return ; + } + +if (event->mask ==IN_MODIFY ) { +if (tc->expect_events >1 ) +tst_res (TPASS ,"Got 2nd event as expected" ); +else +tst_res (TFAIL ,"Got unexpected 2nd event" ); + }else if (event->mask ==IN_IGNORED ) { +if (tc->expect_events ==1 ) +tst_res (TPASS ,"Got no more events as expected" ); +else +tst_res (TFAIL ,"Got only one event (expected %d)" , + tc->expect_events); + }else { +tst_res (TFAIL ,"Got unexpected event 0x%x" , + event->mask); + }
testcases/kernel/syscalls/inotify/inotify12.c line 156
Quoted 10 lines
testcases/kernel/syscalls/inotify/inotify12.c new file +10
-0+} + +static void cleanup (void ) +{ +if (fd_notify >0 ) +SAFE_CLOSE (fd_notify); +} + +static struct tst_test test = { + .timeout =10 ,
OOPS should be changed to .max_runtime = 10
testcases/kernel/syscalls/inotify/inotify12.c line 163
Quoted 7 lines
testcases/kernel/syscalls/inotify/inotify12.c new file +7
-0+ .needs_tmpdir = 1, + .cleanup = cleanup, + .test = verify_inotify, + .tcnt = ARRAY_SIZE(tcases), + .tags = (const struct tst_tag []) { + {"linux-git" ,"a32e697cda27" }, + {}
Missing }
Sorry, I hadn't notice this build failure before posting.
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
Hi Amir,
Quoted 1 line
Quoted 1 line
testcases/kernel/syscalls/inotify/inotify12.c +0
-0
...
Quoted 13 lines
testcases/kernel/syscalls/inotify/inotify12.c line 156
Quoted 2 lines
testcases/kernel/syscalls/inotify/inotify12.c +2
-0+static struct tst_test test = { + .timeout =10 ,OOPS should be changed to .max_runtime = 10
testcases/kernel/syscalls/inotify/inotify12.c line 163
Quoted 7 lines
testcases/kernel/syscalls/inotify/inotify12.c +7
-0+ .needs_tmpdir = 1, + .cleanup = cleanup, + .test = verify_inotify, + .tcnt = ARRAY_SIZE(tcases), + .tags = (const struct tst_tag []) { + {"linux-git" ,"a32e697cda27" }, + {}
Quoted 3 lines
Missing }
Sorry, I hadn't notice this build failure before posting.
No big deal, we can fix this before merge.
And we have to try again to decide how to quickly merge tests for rc kernel.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
Quoted 18 lines · Petr Vorel
Hi Amir,
Quoted 1 line
Quoted 1 line
testcases/kernel/syscalls/inotify/inotify12.c +0
-0...
Quoted 12 lines
testcases/kernel/syscalls/inotify/inotify12.c line 156
Quoted 2 lines
testcases/kernel/syscalls/inotify/inotify12.c +2
-0+static struct tst_test test = { + .timeout =10 ,OOPS should be changed to .max_runtime = 10
Quoted 7 lines
testcases/kernel/syscalls/inotify/inotify12.c +7
-0+ .needs_tmpdir = 1, + .cleanup = cleanup, + .test = verify_inotify, + .tcnt = ARRAY_SIZE(tcases), + .tags = (const struct tst_tag []) { + {"linux-git" ,"a32e697cda27" }, + {}
Quoted 7 lines
Quoted 3 lines
Missing }
Sorry, I hadn't notice this build failure before posting.
No big deal, we can fix this before merge.
And we have to try again to decide how to quickly merge tests for rc kernel.
Right.. forgot about that.
FWIW, the specific fix of test inotify12 is already in stable kernels (v5.10.121, ...)
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
Quoted 23 lines · Petr Vorel
Quoted 21 lines
Hi Amir,
Quoted 1 line
Quoted 1 line
testcases/kernel/syscalls/inotify/inotify12.c +0
-0...
Quoted 16 lines
testcases/kernel/syscalls/inotify/inotify12.c line 156
Quoted 2 lines
testcases/kernel/syscalls/inotify/inotify12.c +2
-0+static struct tst_test test = { + .timeout =10 ,OOPS should be changed to .max_runtime = 10
testcases/kernel/syscalls/inotify/inotify12.c line 163
Quoted 7 lines
testcases/kernel/syscalls/inotify/inotify12.c +7
-0+ .needs_tmpdir = 1, + .cleanup = cleanup, + .test = verify_inotify, + .tcnt = ARRAY_SIZE(tcases), + .tags = (const struct tst_tag []) { + {"linux-git" ,"a32e697cda27" }, + {}Missing }
Sorry, I hadn't notice this build failure before posting.
Quoted 7 lines
Quoted 3 lines
No big deal, we can fix this before merge.
And we have to try again to decide how to quickly merge tests for rc kernel.
Right.. forgot about that.
FWIW, the specific fix of test inotify12 is already in stable kernels (v5.10.121, ...)
Correct, I have searched for this before. That means we merge this one very soon. I'm just waiting if Jan has some comments.
Kind regards,
Petr
Quoted 2 lines
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
In reply to Amir GoldsteinHi Amir,
...
Quoted 7 lines
+/*\
+ * [Description]
+ * Test special inotify mask flags.
+ *
+ * Regression test for kernel commita32e697cda27:
+ *
+ * inotify: show inotify mask flags in proc fdinfo
For our documentation it's better to be formatted like:
* Regression test for kernel commit:
* a32e697cda27 ("inotify: show inotify mask flags in proc fdinfo")
because spaces before text make it formatted as code. No need to repost, I'll fix it before merge.
...
Quoted 13 lines
testcases/kernel/syscalls/inotify/inotify12.c new file +13
-0+static struct tcase { +const char *tname; +unsigned int mask; +int expect_events; +} tcases[] = { + { +"Watch for multi events" , +IN_MODIFY , +2 , + }, + { +"Watch for single event" , +IN_MODIFY |IN_ONESHOT ,
testcases/kernel/syscalls/inotify/inotify12.c line 63
Quoted 10 lines
testcases/kernel/syscalls/inotify/inotify12.c new file +10
-0+ 1, + }, + { +"Watch for events on linked file" , +IN_MODIFY |IN_EXCL_UNLINK , + 1, + }, +}; + +int fd_notify;
nit: this should be static
(make check or make check-inotify12 is your friend). Again, no need to repost, I'll fix it before merge.
Code itself looks pretty good as always, thanks!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
In reply to Amir GoldsteinQuoted 3 lines · Amir Goldstein
Test behavior of
IN_ONESHOTandIN_EXCL_UNLINK.Signed-off-by Amir Goldstein <[email protected]>
Looks good to me after fixing those small bugs you've found. Feel free to add:
Honza
Quoted 205 lines
--- runtest/syscalls | 1 + testcases/kernel/syscalls/inotify/.gitignore | 1 + testcases/kernel/syscalls/inotify/inotify12.c | 168 ++++++++++++++++++ 3 files changed, 170 insertions(+) create mode 100644 testcases/kernel/syscalls/inotify/inotify12.cruntest/syscalls +1
-0@@ -588,6 +588,7 @@ inotify08 inotify08 inotify09 inotify09 inotify10 inotify10 inotify11 inotify11 +inotify12 inotify12 fanotify01 fanotify01 fanotify02 fanotify02testcases/kernel/syscalls/inotify/.gitignore +1
-0@@ -9,3 +9,4 @@ /inotify09 /inotify10 /inotify11 +/inotify12testcases/kernel/syscalls/inotify/inotify12.c new file +168
-0@@ -0,0 +1,168 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2022 CTERA Networks. All Rights Reserved. +* +* Author: Amir Goldstein <[email protected]> +*/ + +/*\ +* [Description] +* Test special inotify mask flags. +* +* Regression test for kernel commit a32e697cda27: +* +* inotify: show inotify mask flags in proc fdinfo +*/ + +#include "config.h" + +#include <stdio.h> +#include <unistd.h> +#include <fcntl.h> +#include <signal.h> +#include <sys/wait.h> + +#include "tst_test.h" +#include "tst_safe_macros.h" +#include "inotify.h" + +#if defined(HAVE_SYS_INOTIFY_H ) +#include <sys/inotify.h> + +#define EVENT_MAX 32 +/* Size of the event structure, not including the name */ +#define EVENT_SIZE (sizeof(struct inotify_event)) +#define EVENT_BUF_LEN (EVENT_MAX * (EVENT_SIZE + 16)) + +#define TEST_FILE "test_file" + +static char event_buf[EVENT_BUF_LEN ]; + +static struct tcase { +const char *tname; +unsigned int mask; +int expect_events; +} tcases[] = { + { +"Watch for multi events" , +IN_MODIFY , +2 , + }, + { +"Watch for single event" , +IN_MODIFY |IN_ONESHOT , +1 , + }, + { +"Watch for events on linked file" , +IN_MODIFY |IN_EXCL_UNLINK , +1 , + }, +}; + +int fd_notify; + +static void verify_inotify (unsigned int n) +{ +struct tcase *tc = &tcases[n]; +int fd, len; +unsigned int tmpmask; +char procfdinfo[100 ]; +struct inotify_event *event = (struct inotify_event *)event_buf; + +tst_res (TINFO ,"Test #%d: %s" , n, tc->tname); + + fd_notify =SAFE_MYINOTIFY_INIT1 (O_NONBLOCK ); + +SAFE_FILE_PRINTF (TEST_FILE ,"1" ); + +SAFE_MYINOTIFY_ADD_WATCH (fd_notify,"." , tc->mask); + +sprintf (procfdinfo,"/proc/%d/fdinfo/%d" , (int )getpid (), fd_notify); +if (FILE_LINES_SCANF (procfdinfo,"inotify wd:%*d ino:%*x sdev:%*x mask:%x" , + &tmpmask)) { +tst_res (TFAIL ,"Could not parse inotify fdinfo" ); + }else if (tmpmask != tc->mask) { +tst_res (TFAIL ,"Incorrect mask %x in inotify fdinfo (expected %x)" , + tmpmask, tc->mask); + }else { +tst_res (TPASS ,"Correct mask in inotify fdinfo" ); + } + + fd =SAFE_OPEN (TEST_FILE ,O_RDWR ); +SAFE_WRITE (1 , fd,"2" ,1 ); + +/* +* Read the 1st IN_MODIFY event +*/ + len =SAFE_READ (0 , fd_notify, event_buf,EVENT_BUF_LEN ); + +if (len < (int )sizeof (*event)) { +tst_res (TFAIL ,"Got no events" ); + }else if (event->mask ==IN_MODIFY ) { +tst_res (TPASS ,"Got 1st event as expected" ); + }else { +tst_res (TFAIL ,"Got event 0x%x (expected 0x%x)" , + event->mask,IN_MODIFY ); + } + +/* +* Unlink file so IN_EXCL_UNLINK won't get IN_ACCESS event. +* IN_ONESHOT won't get IN_ACCESS event because IN_MODIFY +* was already generated. +*/ +SAFE_UNLINK (TEST_FILE ); +SAFE_WRITE (1 , fd,"3" ,1 ); +SAFE_CLOSE (fd); + +/* +* Possibly read the 2nd IN_MODIFY event +*/ + errno =0 ; + len =read (fd_notify, event_buf,EVENT_BUF_LEN ); +SAFE_CLOSE (fd_notify); +if (len <0 && errno ==EAGAIN ) { +/* Treat no event same as we treat IN_IGNORED */ + event->mask =IN_IGNORED ; + }else if (len < (int )sizeof (*event)) { +tst_res (TFAIL |TERRNO ,"Failed to read events" ); +return ; + } + +if (event->mask ==IN_MODIFY ) { +if (tc->expect_events >1 ) +tst_res (TPASS ,"Got 2nd event as expected" ); +else +tst_res (TFAIL ,"Got unexpected 2nd event" ); + }else if (event->mask ==IN_IGNORED ) { +if (tc->expect_events ==1 ) +tst_res (TPASS ,"Got no more events as expected" ); +else +tst_res (TFAIL ,"Got only one event (expected %d)" , + tc->expect_events); + }else { +tst_res (TFAIL ,"Got unexpected event 0x%x" , + event->mask); + } +} + +static void cleanup (void ) +{ +if (fd_notify >0 ) +SAFE_CLOSE (fd_notify); +} + +static struct tst_test test = { + .timeout =10 , + .needs_tmpdir =1 , + .cleanup = cleanup, + .test = verify_inotify, + .tcnt =ARRAY_SIZE (tcases), + .tags = (const struct tst_tag []) { + {"linux-git" ,"a32e697cda27" }, + {} +}; + +#else +TST_TEST_TCONF ("system doesn't have required inotify support" ); +#endif Signature · 1 line
2.25.1
Signature · 5 lines
Jan Kara <[email protected]> SUSE Labs, CR -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
Hi all,
Quoted 6 lines
Looks good to me after fixing those small bugs you've found. Feel free to add:
Reviewed-by Jan Kara <[email protected]>Honza
Jan, thanks for your review!
Patch merged.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/5 syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test
In reply to Amir GoldsteinVerify that evictable mark does not pin inode to cache and that drop_caches evicts inode from cache and removes the evictable mark.
Verify that evictable mark can be upgraded to non-evictable but not downgraded to evictable afterwards.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/fanotify/.gitignore | 1 + testcases/kernel/syscalls/fanotify/fanotify.h | 4 + .../kernel/syscalls/fanotify/fanotify23.c | 258 ++++++++++++++++++ 4 files changed, 264 insertions(+) create mode 100644 testcases/kernel/syscalls/fanotify/fanotify23.c
runtest/syscalls +1 -0
@@ -612,6 +612,7 @@ fanotify19 fanotify19 fanotify20 fanotify20 fanotify21 fanotify21 fanotify22 fanotify22 +fanotify23 fanotify23 ioperm01 ioperm01 ioperm02 ioperm02
testcases/kernel/syscalls/fanotify/.gitignore +1 -0
@@ -20,4 +20,5 @@ /fanotify20 /fanotify21 /fanotify22 +/fanotify23 /fanotify_child
testcases/kernel/syscalls/fanotify/fanotify.h +4 -0
@@ -101,6 +101,10 @@ static inline int safe_fanotify_mark(const char *file, const int lineno,#ifndef FAN_MARK_FILESYSTEM #define FAN_MARK_FILESYSTEM 0x00000100#endif +#ifndef FAN_MARK_EVICTABLE +#define FAN_MARK_EVICTABLE 0x00000200 +#endif +/* New dirent event masks */ #ifndef FAN_ATTRIB #define FAN_ATTRIB 0x00000004
testcases/kernel/syscalls/fanotify/fanotify23.c new file +258 -0
258 lines not on this page · raw message
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test
Quoted 7 lines · Amir Goldstein
Verify that evictable mark does not pin inode to cache and that
drop_cachesevicts inode from cache and removes the evictable mark.Verify that evictable mark can be upgraded to non-evictable but not downgraded to evictable afterwards.
Signed-off-by Amir Goldstein <[email protected]>
Looks good to me. Feel free to add:
Honza
Quoted 312 lines
--- runtest/syscalls | 1 + testcases/kernel/syscalls/fanotify/.gitignore | 1 + testcases/kernel/syscalls/fanotify/fanotify.h | 4 + .../kernel/syscalls/fanotify/fanotify23.c | 258 ++++++++++++++++++ 4 files changed, 264 insertions(+) create mode 100644 testcases/kernel/syscalls/fanotify/fanotify23.cruntest/syscalls +1
-0@@ -612,6 +612,7 @@ fanotify19 fanotify19 fanotify20 fanotify20 fanotify21 fanotify21 fanotify22 fanotify22 +fanotify23 fanotify23 ioperm01 ioperm01 ioperm02 ioperm02testcases/kernel/syscalls/fanotify/.gitignore +1
-0@@ -20,4 +20,5 @@ /fanotify20 /fanotify21 /fanotify22 +/fanotify23 /fanotify_childtestcases/kernel/syscalls/fanotify/fanotify.h +4
-0@@ -101,6 +101,10 @@ static inline int safe_fanotify_mark(const char *file, const int lineno,#ifndef FAN_MARK_FILESYSTEM #define FAN_MARK_FILESYSTEM 0x00000100#endif +#ifndef FAN_MARK_EVICTABLE +#define FAN_MARK_EVICTABLE 0x00000200 +#endif +/* New dirent event masks */ #ifndef FAN_ATTRIB #define FAN_ATTRIB 0x00000004testcases/kernel/syscalls/fanotify/fanotify23.c new file +258
-0@@ -0,0 +1,258 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2022 CTERA Networks. All Rights Reserved. +* +* Author: Amir Goldstein <[email protected]> +*/ + +/*\ +* [Description] +* Check evictable fanotify inode marks. +*/ + +#define _GNU_SOURCE +#include "config.h" + +#include <stdio.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <errno.h> +#include <string.h> +#include <sys/syscall.h> +#include "tst_test.h" + +#ifdef HAVE_SYS_FANOTIFY_H +#include "fanotify.h" + +#define EVENT_MAX 1024 +/* size of the event structure, not counting name */ +#define EVENT_SIZE (sizeof (struct fanotify_event_metadata)) +/* reasonable guess as to size of 1024 events */ +#define EVENT_BUF_LEN (EVENT_MAX * EVENT_SIZE) + +#define MOUNT_PATH "fs_mnt" +#define TEST_FILE MOUNT_PATH "/testfile" + +#define DROP_CACHES_FILE "/proc/sys/vm/drop_caches" +#define CACHE_PRESSURE_FILE "/proc/sys/vm/vfs_cache_pressure" + +static int old_cache_pressure; +static int fd_notify; + +static unsigned long long event_set[EVENT_MAX ]; + +static char event_buf[EVENT_BUF_LEN ]; + +static void fsync_file (const char *path) +{ +int fd =SAFE_OPEN (path,O_RDONLY ); + +SAFE_FSYNC (fd); +SAFE_CLOSE (fd); +} + +/* Flush out all pending dirty inodes and destructing marks */ +static void mount_cycle (void ) +{ +SAFE_UMOUNT (MOUNT_PATH ); +SAFE_MOUNT (tst_device->dev,MOUNT_PATH , tst_device->fs_type,0 ,NULL ); +} + +static int verify_mark_removed (const char *path,const char *when) +{ +int ret; + +/* +* We know that inode with evictable mark was evicted when a +* bogus call remove ACCESS from event mask returns ENOENT. +*/ + errno =0 ; + ret =fanotify_mark (fd_notify,FAN_MARK_REMOVE , +FAN_ACCESS ,AT_FDCWD , path); +if (ret ==-1 && errno ==ENOENT ) { +tst_res (TPASS , +"FAN_MARK_REMOVE failed with ENOENT as expected" +" %s" , when); +return 1 ; + }else { +tst_res (TFAIL |TERRNO , +"FAN_MARK_REMOVE did not fail with ENOENT as expected" +" %s" , when); +return 0 ; + } +} + +static void test_fanotify (void ) +{ +int ret, len, test_num =0 ; +struct fanotify_event_metadata *event; +int tst_count =0 ; + + fd_notify =SAFE_FANOTIFY_INIT (FAN_CLASS_NOTIF |FAN_REPORT_FID | +FAN_NONBLOCK ,O_RDONLY ); + +/* +* Verify that evictable mark can be upgraded to non-evictable +* and cannot be downgraded to evictable. +*/ +SAFE_FANOTIFY_MARK (fd_notify,FAN_MARK_ADD |FAN_MARK_EVICTABLE , +FAN_ACCESS , +AT_FDCWD ,TEST_FILE ); +SAFE_FANOTIFY_MARK (fd_notify,FAN_MARK_ADD , +FAN_ACCESS , +AT_FDCWD ,TEST_FILE ); + errno =0 ; + ret =fanotify_mark (fd_notify,FAN_MARK_ADD |FAN_MARK_EVICTABLE , +FAN_ACCESS , +AT_FDCWD ,TEST_FILE ); +if (ret ==-1 && errno ==EEXIST ) { +tst_res (TPASS , +"FAN_MARK_ADD failed with EEXIST as expected" +" when trying to downgrade to evictable mark" ); + }else { +tst_res (TFAIL |TERRNO , +"FAN_MARK_ADD did not fail with EEXIST as expected" +" when trying to downgrade to evictable mark" ); + } +SAFE_FANOTIFY_MARK (fd_notify,FAN_MARK_REMOVE , +FAN_ACCESS , +AT_FDCWD ,TEST_FILE ); +verify_mark_removed (TEST_FILE ,"after empty mask" ); + + +/* +* Watch ATTRIB events on entire mount +*/ +SAFE_FANOTIFY_MARK (fd_notify,FAN_MARK_ADD |FAN_MARK_FILESYSTEM , +FAN_ATTRIB ,AT_FDCWD ,MOUNT_PATH ); + +/* +* Generate events +*/ +SAFE_CHMOD (TEST_FILE ,0600 ); + event_set[tst_count] =FAN_ATTRIB ; + tst_count++; + +/* Read events so far */ + ret =SAFE_READ (0 , fd_notify, event_buf,EVENT_BUF_LEN ); + len = ret; + +/* +* Evictable mark on file ignores ATTRIB events +*/ +SAFE_FANOTIFY_MARK (fd_notify,FAN_MARK_ADD |FAN_MARK_EVICTABLE | +FAN_MARK_IGNORED_MASK |FAN_MARK_IGNORED_SURV_MODIFY , +FAN_ATTRIB ,AT_FDCWD ,TEST_FILE ); + +/* ATTRIB event should be ignored */ +SAFE_CHMOD (TEST_FILE ,0600 ); + +/* +* Read events to verify event was ignored +*/ + ret =read (fd_notify, event_buf + len,EVENT_BUF_LEN - len); +if (ret <0 && errno ==EAGAIN ) { +tst_res (TPASS ,"Got no events as expected" ); + }else { +tst_res (TFAIL ,"Got expected events" ); + len += ret; + } + +/* +* drop_caches should evict inode from cache and remove evictable mark +*/ +fsync_file (TEST_FILE ); +SAFE_FILE_PRINTF (DROP_CACHES_FILE ,"3" ); + +verify_mark_removed (TEST_FILE ,"after drop_caches" ); + +SAFE_CHMOD (TEST_FILE ,0600 ); + event_set[tst_count] =FAN_ATTRIB ; + tst_count++; + +/* Read events to verify ATTRIB event was properly generated */ + ret =SAFE_READ (0 , fd_notify, event_buf + len,EVENT_BUF_LEN - len); + len += ret; + +/* +* Check events +*/ + event = (struct fanotify_event_metadata *)event_buf; + +/* Iterate over and validate events against expected result set */ +while (FAN_EVENT_OK (event, len) && test_num < tst_count) { +if (!(event->mask & event_set[test_num])) { +tst_res (TFAIL , +"got event: mask=%llx (expected %llx)" , + (unsigned long long )event->mask, + event_set[test_num]); + }else { +tst_res (TPASS , +"got event: mask=%llx" , + (unsigned long long )event->mask); + } +/* +* Close fd and invalidate it so that we don't check it again +* unnecessarily +*/ +if (event->fd >=0 ) +SAFE_CLOSE (event->fd); + event->fd =FAN_NOFD ; + event->mask &= ~event_set[test_num]; +/* No events left in current mask? Go for next event */ +if (event->mask ==0 ) { + event =FAN_EVENT_NEXT (event, len); + } + test_num++; + } + +while (FAN_EVENT_OK (event, len)) { +tst_res (TFAIL , +"got unnecessary event: mask=%llx" , + (unsigned long long )event->mask); +if (event->fd !=FAN_NOFD ) +SAFE_CLOSE (event->fd); + event =FAN_EVENT_NEXT (event, len); + } + +SAFE_CLOSE (fd_notify); +/* Flush out all pending dirty inodes and destructing marks */ +mount_cycle (); +} + +static void setup (void ) +{ +SAFE_TOUCH (TEST_FILE ,0666 ,NULL ); + +REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL (FAN_MARK_EVICTABLE ); +REQUIRE_FANOTIFY_EVENTS_SUPPORTED_ON_FS (FAN_CLASS_NOTIF |FAN_REPORT_FID , +FAN_MARK_FILESYSTEM , +FAN_ATTRIB ,"." ); + +SAFE_FILE_SCANF (CACHE_PRESSURE_FILE ,"%d" , &old_cache_pressure); +/* Set high priority for evicting inodes */ +SAFE_FILE_PRINTF (CACHE_PRESSURE_FILE ,"500" ); +} + +static void cleanup (void ) +{ +if (fd_notify >0 ) +SAFE_CLOSE (fd_notify); + +SAFE_FILE_PRINTF (CACHE_PRESSURE_FILE ,"%d" , old_cache_pressure); +} + +static struct tst_test test = { + .test_all = test_fanotify, + .setup = setup, + .cleanup = cleanup, + .needs_root =1 , + .mount_device =1 , + .mntpoint =MOUNT_PATH , +/* Shrinkers on other fs do not work reliably enough to guarantee mark eviction on drop_caches */ + .dev_fs_type ="ext2" , +}; + +#else +TST_TEST_TCONF ("system doesn't have required fanotify support" ); +#endif Signature · 1 line
2.25.1
Signature · 5 lines
Jan Kara <[email protected]> SUSE Labs, CR -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test
In reply to Amir GoldsteinHi Amir, Jan, all,
Quoted 5 lines
Verify that evictable mark does not pin inode to cache and that
drop_cachesevicts inode from cache and removes the evictable mark.Verify that evictable mark can be upgraded to non-evictable but not downgraded to evictable afterwards.
We have policy for merging tests for rc kernels [1], thus I merged this patch (added fanotify23 into runtest/staging).
I'll discuss with others what to do with fanotify10 (old test getting new functionality for rc kernel).
Kind regards,
Petr
[1] 2c0ab6f65 ("Create policy for testing unstable kernel features")
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test
Quoted 11 lines · Petr Vorel
Hi Amir, Jan, all,
Quoted 5 lines
Verify that evictable mark does not pin inode to cache and that
drop_cachesevicts inode from cache and removes the evictable mark.Verify that evictable mark can be upgraded to non-evictable but not downgraded to evictable afterwards.
We have policy for merging tests for rc kernels [1], thus I merged this patch (added fanotify23 into runtest/staging).
Cool. I am glad this issue has been sorted out :)
Quoted 3 lines
I'll discuss with others what to do with fanotify10 (old test getting new functionality for rc kernel).
Please note, fanotify10 already has:
if (tc->ignored_onchild && tst_kvercmp(5, 9, 0) < 0) {
tst_res(TCONF, "ignored mask in combination with flagFAN_EVENT_ON_CHILD"
" has undefined behavior on kernel < 5.9");
return;
}We could easily do the same for FAN_MARK_EVICTABLE and 5.19.0 (although not sure how tst_kvercmp treats 5.19-rc1?)
I doubt that anyone would want to/be able to backport this feature to older distro kernels, but even if they do, we could remove the tst_kvercmp mitigation once 5.19.0 is release and leave only the feature test if someone complains.
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test
Hi all,
Quoted 7 lines · Petr Vorel
Quoted 5 lines
Hi Amir, Jan, all,
Quoted 2 lines
Verify that evictable mark does not pin inode to cache and that
drop_cachesevicts inode from cache and removes the evictable mark.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Verify that evictable mark can be upgraded to non-evictable but not downgraded to evictable afterwards.
We have policy for merging tests for rc kernels [1], thus I merged this patch (added fanotify23 into runtest/staging).
Cool. I am glad this issue has been sorted out :)
Yw, we appreciate very much your work maintaining inotify/fanotify tests.
Quoted 8 lines
Quoted 2 lines
I'll discuss with others what to do with fanotify10 (old test getting new functionality for rc kernel).
Please note, fanotify10 already has:
if (
tc->ignored_onchild&&tst_kvercmp(5, 9, 0)< 0) {
tst_res(TCONF, "ignored mask in combination with flagFAN_EVENT_ON_CHILD"
Quoted 6 lines
" has undefined behavior on kernel < 5.9"); return; }We could easily do the same for
FAN_MARK_EVICTABLEand 5.19.0 (although not sure howtst_kvercmptreats 5.19-rc1?)
Sure, that should work, but as feature detection works reliably (tested on v5.17 and v5.18) I'd keep it as is. If problems turn out we can always put this detection.
Quoted 4 lines
I doubt that anyone would want to/be able to backport this feature to older distro kernels, but even if they do, we could remove the
tst_kvercmpmitigation once 5.19.0 is release and leave only the feature test if someone complains.
Sure.
Kind regards,
Petr
Quoted 2 lines
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/5 syscalls/fanotify10: Watch directory that is not the mount path
In reply to Amir GoldsteinMove the test file into a test directory, so we won't set a mark on the mount path when watching the children of a directory.
--- .../kernel/syscalls/fanotify/fanotify10.c | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify10.c +16 -12
@@ -74,16 +74,19 @@ static int filesystem_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint" +#define DIR_NAME "testdir"#define FILE_NAME "testfile"#define FILE2_NAME "testfile2"#define TEST_APP "fanotify_child"#define TEST_APP2 "fanotify_child2" -#define FILE_PATH MOUNT_PATH"/"FILE_NAME -#define FILE2_PATH MOUNT_PATH"/"FILE2_NAME +#define DIR_PATH MOUNT_PATH"/"DIR_NAME +#define FILE_PATH DIR_PATH"/"FILE_NAME +#define FILE2_PATH DIR_PATH"/"FILE2_NAME#define FILE_EXEC_PATH MOUNT_PATH"/"TEST_APP#define FILE2_EXEC_PATH MOUNT_PATH"/"TEST_APP2 -#define FILE_MNT2 MNT2_PATH"/"FILE_NAME -#define FILE2_MNT2 MNT2_PATH"/"FILE2_NAME +#define DIR_MNT2 MNT2_PATH"/"DIR_NAME +#define FILE_MNT2 DIR_MNT2"/"FILE_NAME +#define FILE2_MNT2 DIR_MNT2"/"FILE2_NAME#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2
@@ -239,50 +242,50 @@ static struct tcase { }, {"ignore events on children of directory created on a specific file" , -MNT2_PATH ,FANOTIFY_INODE , -FILE_PATH ,FANOTIFY_INODE , +DIR_MNT2 ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN }, {"ignore events on file created inside a parent watching children" ,FILE_PATH ,FANOTIFY_INODE , -MNT2_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN }, {"don't ignore events on file created inside a parent not watching children" ,FILE_PATH ,FANOTIFY_INODE , -MNT2_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, {"ignore mount events created inside a parent watching children" ,FILE_PATH ,FANOTIFY_MOUNT , -MNT2_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN }, {"don't ignore mount events created inside a parent not watching children" ,FILE_PATH ,FANOTIFY_MOUNT , -MNT2_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, {"ignore fs events created inside a parent watching children" ,FILE_PATH ,FANOTIFY_FILESYSTEM , -MNT2_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN }, {"don't ignore fs events created inside a parent not watching children" ,FILE_PATH ,FANOTIFY_FILESYSTEM , -MNT2_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN },
@@ -525,6 +528,7 @@ static void setup(void)SAFE_MOUNT (MOUNT_PATH ,MNT2_PATH ,"none" ,MS_BIND ,NULL ); bind_mount_created =1 ; +SAFE_MKDIR (DIR_PATH ,0755 );SAFE_FILE_PRINTF (FILE_PATH ,"1" );SAFE_FILE_PRINTF (FILE2_PATH ,"1" );
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path
Quoted 4 lines · Amir Goldstein
Move the test file into a test directory, so we won't set a mark on the mount path when watching the children of a directory.
Signed-off-by Amir Goldstein <[email protected]>
One question below...
Quoted 29 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +7
-4@@ -74,16 +74,19 @@ static int filesystem_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint" +#define DIR_NAME "testdir"#define FILE_NAME "testfile"#define FILE2_NAME "testfile2"#define TEST_APP "fanotify_child"#define TEST_APP2 "fanotify_child2" -#define FILE_PATH MOUNT_PATH"/"FILE_NAME -#define FILE2_PATH MOUNT_PATH"/"FILE2_NAME +#define DIR_PATH MOUNT_PATH"/"DIR_NAME +#define FILE_PATH DIR_PATH"/"FILE_NAME +#define FILE2_PATH DIR_PATH"/"FILE2_NAME#define FILE_EXEC_PATH MOUNT_PATH"/"TEST_APP#define FILE2_EXEC_PATH MOUNT_PATH"/"TEST_APP2 -#define FILE_MNT2 MNT2_PATH"/"FILE_NAME -#define FILE2_MNT2 MNT2_PATH"/"FILE2_NAME +#define DIR_MNT2 MNT2_PATH"/"DIR_NAME +#define FILE_MNT2 DIR_MNT2"/"FILE_NAME +#define FILE2_MNT2 DIR_MNT2"/"FILE2_NAME#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2
testcases/kernel/syscalls/fanotify/fanotify10.c static struct tcase { · line 246
Quoted 7 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +2
-2@@ -239,50 +242,50 @@ static struct tcase { }, {"ignore events on children of directory created on a specific file" , -MNT2_PATH ,FANOTIFY_INODE , - FILE_PATH, FANOTIFY_INODE, +DIR_MNT2 ,FANOTIFY_INODE , + DIR_PATH, FANOTIFY_INODE,
I'm somewhat confused here why you remove the FILE_PATH test here... In all the other tests you just replace MNT2_PATH with DIR_PATH which makes sense.
Honza
Quoted 62 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +7
-6FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN }, {"ignore events on file created inside a parent watching children" ,FILE_PATH ,FANOTIFY_INODE , -MNT2_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN }, {"don't ignore events on file created inside a parent not watching children" ,FILE_PATH ,FANOTIFY_INODE , -MNT2_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, {"ignore mount events created inside a parent watching children" ,FILE_PATH ,FANOTIFY_MOUNT , -MNT2_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN }, {"don't ignore mount events created inside a parent not watching children" ,FILE_PATH ,FANOTIFY_MOUNT , -MNT2_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, {"ignore fs events created inside a parent watching children" ,FILE_PATH ,FANOTIFY_FILESYSTEM , -MNT2_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN }, {"don't ignore fs events created inside a parent not watching children" ,FILE_PATH ,FANOTIFY_FILESYSTEM , -MNT2_PATH ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN },@@ -525,6 +528,7 @@ static void setup(void)SAFE_MOUNT (MOUNT_PATH ,MNT2_PATH ,"none" ,MS_BIND ,NULL ); bind_mount_created =1 ; +SAFE_MKDIR (DIR_PATH ,0755 );SAFE_FILE_PRINTF (FILE_PATH ,"1" );SAFE_FILE_PRINTF (FILE2_PATH ,"1" );Signature · 1 line
2.25.1
Signature · 5 lines
Jan Kara <[email protected]> SUSE Labs, CR -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path
Quoted 37 lines · Jan Kara
Quoted 4 lines · Amir Goldstein
Move the test file into a test directory, so we won't set a mark on the mount path when watching the children of a directory.
Signed-off-by Amir Goldstein <[email protected]>One question below...
Quoted 28 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +7
-4@@ -74,16 +74,19 @@ static int filesystem_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint" +#define DIR_NAME "testdir"#define FILE_NAME "testfile"#define FILE2_NAME "testfile2"#define TEST_APP "fanotify_child"#define TEST_APP2 "fanotify_child2" -#define FILE_PATH MOUNT_PATH"/"FILE_NAME -#define FILE2_PATH MOUNT_PATH"/"FILE2_NAME +#define DIR_PATH MOUNT_PATH"/"DIR_NAME +#define FILE_PATH DIR_PATH"/"FILE_NAME +#define FILE2_PATH DIR_PATH"/"FILE2_NAME#define FILE_EXEC_PATH MOUNT_PATH"/"TEST_APP#define FILE2_EXEC_PATH MOUNT_PATH"/"TEST_APP2 -#define FILE_MNT2 MNT2_PATH"/"FILE_NAME -#define FILE2_MNT2 MNT2_PATH"/"FILE2_NAME +#define DIR_MNT2 MNT2_PATH"/"DIR_NAME +#define FILE_MNT2 DIR_MNT2"/"FILE_NAME +#define FILE2_MNT2 DIR_MNT2"/"FILE2_NAME#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2
Quoted 15 lines
testcases/kernel/syscalls/fanotify/fanotify10.c static struct tcase { · line 249
Quoted 11 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +2
-2@@ -239,50 +242,50 @@ static struct tcase { }, {"ignore events on children of directory created on a specific file" , -MNT2_PATH ,FANOTIFY_INODE , -FILE_PATH ,FANOTIFY_INODE , +DIR_MNT2 ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN },I'm somewhat confused here why you remove the
FILE_PATHtest here... In all the other tests you just replaceMNT2_PATHwithDIR_PATHwhich makes sense.
Good question.
I guess while doing the conversion, I realized that the test case definition was wrong, so I fixed it and forgot to mention it in the commit message.
The test case (#17) should be placing an ignored mask on a directory (DIR_PATH) with FAN_EVENT_ON_CHILD and see that the event on a child (FILE_PATH) is ignored.
But what the test case was doing is setting an ignored mask with FAN_EVENT_ON_CHILD on the child (FILE_PATH).
Petr,
Do you want to add this to the commit message?
Or split to a separate patch?
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path
Quoted 62 lines · Jan Kara
Quoted 37 lines · Amir Goldstein
Quoted 4 lines
Move the test file into a test directory, so we won't set a mark on the mount path when watching the children of a directory.
Signed-off-by Amir Goldstein <[email protected]>One question below...
Quoted 27 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +7
-4@@ -74,16 +74,19 @@ static int filesystem_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint" +#define DIR_NAME "testdir"#define FILE_NAME "testfile"#define FILE2_NAME "testfile2"#define TEST_APP "fanotify_child"#define TEST_APP2 "fanotify_child2" -#define FILE_PATH MOUNT_PATH"/"FILE_NAME -#define FILE2_PATH MOUNT_PATH"/"FILE2_NAME +#define DIR_PATH MOUNT_PATH"/"DIR_NAME +#define FILE_PATH DIR_PATH"/"FILE_NAME +#define FILE2_PATH DIR_PATH"/"FILE2_NAME#define FILE_EXEC_PATH MOUNT_PATH"/"TEST_APP#define FILE2_EXEC_PATH MOUNT_PATH"/"TEST_APP2 -#define FILE_MNT2 MNT2_PATH"/"FILE_NAME -#define FILE2_MNT2 MNT2_PATH"/"FILE2_NAME +#define DIR_MNT2 MNT2_PATH"/"DIR_NAME +#define FILE_MNT2 DIR_MNT2"/"FILE_NAME +#define FILE2_MNT2 DIR_MNT2"/"FILE2_NAME#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2Quoted 14 lines
testcases/kernel/syscalls/fanotify/fanotify10.c static struct tcase { · line 249
Quoted 11 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +2
-2@@ -239,50 +242,50 @@ static struct tcase { }, {"ignore events on children of directory created on a specific file" , -MNT2_PATH ,FANOTIFY_INODE , -FILE_PATH ,FANOTIFY_INODE , +DIR_MNT2 ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN },I'm somewhat confused here why you remove the
FILE_PATHtest here... In all the other tests you just replaceMNT2_PATHwithDIR_PATHwhich makes sense.Good question.
I guess while doing the conversion, I realized that the test case definition was wrong, so I fixed it and forgot to mention it in the commit message.The test case (#17) should be placing an ignored mask on a directory (
DIR_PATH) withFAN_EVENT_ON_CHILDand see that the event on a child (FILE_PATH) is ignored.
Quoted 7 lines
But what the test case was doing is setting an ignored mask with
FAN_EVENT_ON_CHILDon the child (FILE_PATH).Petr,
Do you want to add this to the commit message?
Or split to a separate patch?
Both ways work for me. Could you please rebase your LTP fork, do either of these changes and ping me to pull?
Thx!
Petr
Quoted 2 lines
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path
Quoted 66 lines · Petr Vorel
Quoted 65 lines · Jan Kara
Quoted 37 lines · Amir Goldstein
Quoted 4 lines
Move the test file into a test directory, so we won't set a mark on the mount path when watching the children of a directory.
Signed-off-by Amir Goldstein <[email protected]>One question below...
Quoted 27 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +7
-4@@ -74,16 +74,19 @@ static int filesystem_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint" +#define DIR_NAME "testdir"#define FILE_NAME "testfile"#define FILE2_NAME "testfile2"#define TEST_APP "fanotify_child"#define TEST_APP2 "fanotify_child2" -#define FILE_PATH MOUNT_PATH"/"FILE_NAME -#define FILE2_PATH MOUNT_PATH"/"FILE2_NAME +#define DIR_PATH MOUNT_PATH"/"DIR_NAME +#define FILE_PATH DIR_PATH"/"FILE_NAME +#define FILE2_PATH DIR_PATH"/"FILE2_NAME#define FILE_EXEC_PATH MOUNT_PATH"/"TEST_APP#define FILE2_EXEC_PATH MOUNT_PATH"/"TEST_APP2 -#define FILE_MNT2 MNT2_PATH"/"FILE_NAME -#define FILE2_MNT2 MNT2_PATH"/"FILE2_NAME +#define DIR_MNT2 MNT2_PATH"/"DIR_NAME +#define FILE_MNT2 DIR_MNT2"/"FILE_NAME +#define FILE2_MNT2 DIR_MNT2"/"FILE2_NAME#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2Quoted 14 lines
testcases/kernel/syscalls/fanotify/fanotify10.c static struct tcase { · line 249
Quoted 11 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +2
-2@@ -239,50 +242,50 @@ static struct tcase { }, {"ignore events on children of directory created on a specific file" , -MNT2_PATH ,FANOTIFY_INODE , -FILE_PATH ,FANOTIFY_INODE , +DIR_MNT2 ,FANOTIFY_INODE , +DIR_PATH ,FANOTIFY_INODE ,FAN_EVENT_ON_CHILD ,FILE_PATH ,0 ,FAN_OPEN },I'm somewhat confused here why you remove the
FILE_PATHtest here... In all the other tests you just replaceMNT2_PATHwithDIR_PATHwhich makes sense.Good question.
I guess while doing the conversion, I realized that the test case definition was wrong, so I fixed it and forgot to mention it in the commit message.The test case (#17) should be placing an ignored mask on a directory (
DIR_PATH) withFAN_EVENT_ON_CHILDand see that the event on a child (FILE_PATH) is ignored.But what the test case was doing is setting an ignored mask with
FAN_EVENT_ON_CHILDon the child (FILE_PATH).
Quoted 7 lines
Quoted 4 lines
Petr,
Do you want to add this to the commit message?
Or split to a separate patch?Both ways work for me. Could you please rebase your LTP fork, do either of these changes and ping me to pull?
Done:
https://github.com/amir73il/ltp/commits/fan_evictable
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path
Hi Amir,
...
Quoted 5 lines
Quoted 2 lines
Both ways work for me. Could you please rebase your LTP fork, do either of these changes and ping me to pull?
Thanks a lot, merged!
Kind regards,
Petr
Quoted 2 lines
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 4/5 syscalls/fanotify10: Mount cycle between test cases
In reply to Amir GoldsteinMount cycle detects inode refcount errors and waits for all marks of test case to be destructed before continuing to next test case.
--- .../kernel/syscalls/fanotify/fanotify10.c | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify10.c +18 -7
@@ -360,6 +360,17 @@ static void cleanup_fanotify_groups(void) } } +/* Flush out all pending dirty inodes and destructing marks */ +static void mount_cycle (void ) +{ +if (bind_mount_created) +SAFE_UMOUNT (MNT2_PATH ); +SAFE_UMOUNT (MOUNT_PATH ); +SAFE_MOUNT (tst_device->dev,MOUNT_PATH , tst_device->fs_type,0 ,NULL ); +SAFE_MOUNT (MOUNT_PATH ,MNT2_PATH ,"none" ,MS_BIND ,NULL ); + bind_mount_created =1 ; +} +static void verify_event (int p,int group,struct fanotify_event_metadata *event,unsigned long long expected_mask) {
@@ -508,6 +519,7 @@ static void test_fanotify(unsigned int n) } cleanup:cleanup_fanotify_groups (); +mount_cycle (); }static void setup (void )
@@ -523,25 +535,24 @@ static void setup(void) num_classes =NUM_PRIORITIES ; } -/* Create another bind mount at another path for generating events */ -SAFE_MKDIR (MNT2_PATH ,0755 ); -SAFE_MOUNT (MOUNT_PATH ,MNT2_PATH ,"none" ,MS_BIND ,NULL ); - bind_mount_created =1 ; -SAFE_MKDIR (DIR_PATH ,0755 );SAFE_FILE_PRINTF (FILE_PATH ,"1" );SAFE_FILE_PRINTF (FILE2_PATH ,"1" );SAFE_CP (TEST_APP ,FILE_EXEC_PATH );SAFE_CP (TEST_APP ,FILE2_EXEC_PATH ); + +/* Create another bind mount at another path for generating events */ +SAFE_MKDIR (MNT2_PATH ,0755 ); +mount_cycle (); }static void cleanup (void ) {cleanup_fanotify_groups (); -if (bind_mount_created &&tst_umount (MNT2_PATH ) <0 ) -tst_brk (TBROK |TERRNO ,"bind umount failed" ); +if (bind_mount_created) +SAFE_UMOUNT (MNT2_PATH ); }static const char *const resource_files[] = {
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 4/5] syscalls/fanotify10: Mount cycle between test cases
Quoted 4 lines · Amir Goldstein
Mount cycle detects inode refcount errors and waits for all marks of test case to be destructed before continuing to next test case.
Signed-off-by Amir Goldstein <[email protected]>
Looks good to me. Feel free to add:
Honza
Quoted 69 lines
--- .../kernel/syscalls/fanotify/fanotify10.c | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-)testcases/kernel/syscalls/fanotify/fanotify10.c +18
-7@@ -360,6 +360,17 @@ static void cleanup_fanotify_groups(void) } } +/* Flush out all pending dirty inodes and destructing marks */ +static void mount_cycle (void ) +{ +if (bind_mount_created) +SAFE_UMOUNT (MNT2_PATH ); +SAFE_UMOUNT (MOUNT_PATH ); +SAFE_MOUNT (tst_device->dev,MOUNT_PATH , tst_device->fs_type,0 ,NULL ); +SAFE_MOUNT (MOUNT_PATH ,MNT2_PATH ,"none" ,MS_BIND ,NULL ); + bind_mount_created =1 ; +} +static void verify_event (int p,int group,struct fanotify_event_metadata *event,unsigned long long expected_mask) {@@ -508,6 +519,7 @@ static void test_fanotify(unsigned int n) } cleanup:cleanup_fanotify_groups (); +mount_cycle (); }static void setup (void )@@ -523,25 +535,24 @@ static void setup(void) num_classes =NUM_PRIORITIES ; } -/* Create another bind mount at another path for generating events */ -SAFE_MKDIR (MNT2_PATH ,0755 ); -SAFE_MOUNT (MOUNT_PATH ,MNT2_PATH ,"none" ,MS_BIND ,NULL ); - bind_mount_created =1 ; -SAFE_MKDIR (DIR_PATH ,0755 );SAFE_FILE_PRINTF (FILE_PATH ,"1" );SAFE_FILE_PRINTF (FILE2_PATH ,"1" );SAFE_CP (TEST_APP ,FILE_EXEC_PATH );SAFE_CP (TEST_APP ,FILE2_EXEC_PATH ); + +/* Create another bind mount at another path for generating events */ +SAFE_MKDIR (MNT2_PATH ,0755 ); +mount_cycle (); }static void cleanup (void ) {cleanup_fanotify_groups (); -if (bind_mount_created &&tst_umount (MNT2_PATH ) <0 ) -tst_brk (TBROK |TERRNO ,"bind umount failed" ); +if (bind_mount_created) +SAFE_UMOUNT (MNT2_PATH ); }static const char *const resource_files[] = {Signature · 1 line
2.25.1
Signature · 5 lines
Jan Kara <[email protected]> SUSE Labs, CR -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 5/5 syscalls/fanotify10: Add test cases for evictable ignore mark
In reply to Amir GoldsteinTest multiple groups with evictable mark with ignore mask
--- .../kernel/syscalls/fanotify/fanotify10.c | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+)
testcases/kernel/syscalls/fanotify/fanotify10.c +78 -0
@@ -71,6 +71,7 @@ static char event_buf[EVENT_BUF_LEN];static int exec_events_unsupported;static int fan_report_dfid_unsupported;static int filesystem_mark_unsupported; +static int evictable_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint"
@@ -90,6 +91,10 @@ static int filesystem_mark_unsupported;#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2 +#define DROP_CACHES_FILE "/proc/sys/vm/drop_caches" +#define CACHE_PRESSURE_FILE "/proc/sys/vm/vfs_cache_pressure" + +static int old_cache_pressure;static pid_t child_pid;static int bind_mount_created;static unsigned int num_classes =NUM_CLASSES ;
@@ -98,12 +103,14 @@ enum {FANOTIFY_INODE ,FANOTIFY_MOUNT ,FANOTIFY_FILESYSTEM , + FANOTIFY_EVICTABLE, };static struct fanotify_mark_type fanotify_mark_types[] = {INIT_FANOTIFY_MARK_TYPE (INODE ),INIT_FANOTIFY_MARK_TYPE (MOUNT ),INIT_FANOTIFY_MARK_TYPE (FILESYSTEM ), +INIT_FANOTIFY_MARK_TYPE (EVICTABLE ), }; static struct tcase {
@@ -289,14 +296,59 @@ static struct tcase { 0, FILE_PATH, FAN_OPEN, FAN_OPEN }, +/* Evictable ignore mark test cases */ + { +"don't ignore mount events created on file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created on a file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore mount events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , +DIR_PATH ,FANOTIFY_EVICTABLE , +FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +DIR_PATH ,FANOTIFY_EVICTABLE , +FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, }; +static void show_fanotify_marks (int fd) +{ +unsigned int mflags, mask, ignored_mask; +char procfdinfo[100 ]; + +sprintf (procfdinfo,"/proc/%d/fdinfo/%d" , (int )getpid (), fd); +if (FILE_LINES_SCANF (procfdinfo,"fanotify ino:%*x sdev:%*x mflags: %x mask:%x ignored_mask:%x" , + &mflags, &mask, &ignored_mask)) { +tst_res (TPASS ,"No fanotify inode marks as expected" ); + }else { +tst_res (TFAIL ,"Unexpected inode mark (mflags=%x, mask=%x ignored_mask=%x)" , + mflags, mask, ignored_mask); + } +} +static int create_fanotify_groups (unsigned int n) {struct tcase *tc = &tcases[n];struct fanotify_mark_type *mark, *ignore_mark;unsigned int mark_ignored, mask;unsigned int p, i; +int evictable_ignored = (tc->ignore_mark_type ==FANOTIFY_EVICTABLE ); mark = &fanotify_mark_types[tc->mark_type]; ignore_mark = &fanotify_mark_types[tc->ignore_mark_type];
@@ -345,6 +397,20 @@ add_mark: } } } + +/* +* drop_caches should evict inode from cache and remove evictable marks +*/ +if (evictable_ignored) { +SAFE_FILE_PRINTF (DROP_CACHES_FILE ,"3" ); +for (p =0 ; p < num_classes; p++) { +for (i =0 ; i <GROUPS_PER_PRIO ; i++) { +if (fd_notify[p][i] >0 ) +show_fanotify_marks (fd_notify[p][i]); + } + } + } +return 0 ; }
@@ -439,6 +505,11 @@ static void test_fanotify(unsigned int n)return ; } +if (evictable_mark_unsupported && tc->ignore_mark_type ==FANOTIFY_EVICTABLE ) { +tst_res (TCONF ,"FAN_MARK_EVICTABLE not supported in kernel?" ); +return ; + } +if (tc->ignored_onchild &&tst_kvercmp (5 ,9 ,0 ) <0 ) {tst_res (TCONF ,"ignored mask in combination with flag FAN_EVENT_ON_CHILD" " has undefined behavior on kernel < 5.9" );
@@ -527,6 +598,7 @@ static void setup(void) exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC ,FAN_CLASS_CONTENT ,0 ); filesystem_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_FILESYSTEM ); + evictable_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_EVICTABLE ); fan_report_dfid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_DFID_NAME ,MOUNT_PATH );if (fan_report_dfid_unsupported) {
@@ -545,6 +617,10 @@ static void setup(void)/* Create another bind mount at another path for generating events */ SAFE_MKDIR (MNT2_PATH ,0755 );mount_cycle (); + +SAFE_FILE_SCANF (CACHE_PRESSURE_FILE ,"%d" , &old_cache_pressure); +/* Set high priority for evicting inodes */ +SAFE_FILE_PRINTF (CACHE_PRESSURE_FILE ,"500" ); }static void cleanup (void )
@@ -553,6 +629,8 @@ static void cleanup(void)if (bind_mount_created)SAFE_UMOUNT (MNT2_PATH ); + +SAFE_FILE_PRINTF (CACHE_PRESSURE_FILE ,"%d" , old_cache_pressure); }static const char *const resource_files[] = {
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
Quoted 3 lines · Amir Goldstein
Test multiple groups with evictable mark with ignore mask
Signed-off-by Amir Goldstein <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 166 lines
--- .../kernel/syscalls/fanotify/fanotify10.c | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+)testcases/kernel/syscalls/fanotify/fanotify10.c +78
-0@@ -71,6 +71,7 @@ static char event_buf[EVENT_BUF_LEN];static int exec_events_unsupported;static int fan_report_dfid_unsupported;static int filesystem_mark_unsupported; +static int evictable_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint"@@ -90,6 +91,10 @@ static int filesystem_mark_unsupported;#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2 +#define DROP_CACHES_FILE "/proc/sys/vm/drop_caches" +#define CACHE_PRESSURE_FILE "/proc/sys/vm/vfs_cache_pressure" + +static int old_cache_pressure;static pid_t child_pid;static int bind_mount_created;static unsigned int num_classes =NUM_CLASSES ;@@ -98,12 +103,14 @@ enum {FANOTIFY_INODE ,FANOTIFY_MOUNT ,FANOTIFY_FILESYSTEM , + FANOTIFY_EVICTABLE, };static struct fanotify_mark_type fanotify_mark_types[] = {INIT_FANOTIFY_MARK_TYPE (INODE ),INIT_FANOTIFY_MARK_TYPE (MOUNT ),INIT_FANOTIFY_MARK_TYPE (FILESYSTEM ), +INIT_FANOTIFY_MARK_TYPE (EVICTABLE ), }; static struct tcase {@@ -289,14 +296,59 @@ static struct tcase { 0, FILE_PATH, FAN_OPEN, FAN_OPEN }, +/* Evictable ignore mark test cases */ + { +"don't ignore mount events created on file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created on a file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore mount events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , +DIR_PATH ,FANOTIFY_EVICTABLE , +FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +DIR_PATH ,FANOTIFY_EVICTABLE , +FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, }; +static void show_fanotify_marks (int fd) +{ +unsigned int mflags, mask, ignored_mask; +char procfdinfo[100 ]; + +sprintf (procfdinfo,"/proc/%d/fdinfo/%d" , (int )getpid (), fd); +if (FILE_LINES_SCANF (procfdinfo,"fanotify ino:%*x sdev:%*x mflags: %x mask:%x ignored_mask:%x" , + &mflags, &mask, &ignored_mask)) { +tst_res (TPASS ,"No fanotify inode marks as expected" ); + }else { +tst_res (TFAIL ,"Unexpected inode mark (mflags=%x, mask=%x ignored_mask=%x)" , + mflags, mask, ignored_mask); + } +} +static int create_fanotify_groups (unsigned int n) {struct tcase *tc = &tcases[n];struct fanotify_mark_type *mark, *ignore_mark;unsigned int mark_ignored, mask;unsigned int p, i; +int evictable_ignored = (tc->ignore_mark_type ==FANOTIFY_EVICTABLE ); mark = &fanotify_mark_types[tc->mark_type]; ignore_mark = &fanotify_mark_types[tc->ignore_mark_type];@@ -345,6 +397,20 @@ add_mark: } } } + +/* +* drop_caches should evict inode from cache and remove evictable marks +*/ +if (evictable_ignored) { +SAFE_FILE_PRINTF (DROP_CACHES_FILE ,"3" ); +for (p =0 ; p < num_classes; p++) { +for (i =0 ; i <GROUPS_PER_PRIO ; i++) { +if (fd_notify[p][i] >0 ) +show_fanotify_marks (fd_notify[p][i]); + } + } + } +return 0 ; }@@ -439,6 +505,11 @@ static void test_fanotify(unsigned int n)return ; } +if (evictable_mark_unsupported && tc->ignore_mark_type ==FANOTIFY_EVICTABLE ) { +tst_res (TCONF ,"FAN_MARK_EVICTABLE not supported in kernel?" ); +return ; + } +if (tc->ignored_onchild &&tst_kvercmp (5 ,9 ,0 ) <0 ) {tst_res (TCONF ,"ignored mask in combination with flag FAN_EVENT_ON_CHILD" " has undefined behavior on kernel < 5.9" );@@ -527,6 +598,7 @@ static void setup(void) exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC ,FAN_CLASS_CONTENT ,0 ); filesystem_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_FILESYSTEM ); + evictable_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_EVICTABLE ); fan_report_dfid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_DFID_NAME ,MOUNT_PATH );if (fan_report_dfid_unsupported) {@@ -545,6 +617,10 @@ static void setup(void)/* Create another bind mount at another path for generating events */ SAFE_MKDIR (MNT2_PATH ,0755 );mount_cycle (); + +SAFE_FILE_SCANF (CACHE_PRESSURE_FILE ,"%d" , &old_cache_pressure); +/* Set high priority for evicting inodes */ +SAFE_FILE_PRINTF (CACHE_PRESSURE_FILE ,"500" ); }static void cleanup (void )@@ -553,6 +629,8 @@ static void cleanup(void)if (bind_mount_created)SAFE_UMOUNT (MNT2_PATH ); + +SAFE_FILE_PRINTF (CACHE_PRESSURE_FILE ,"%d" , old_cache_pressure); }static const char *const resource_files[] = {Signature · 1 line
2.25.1
Signature · 5 lines
Jan Kara <[email protected]> SUSE Labs, CR -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
In reply to Amir GoldsteinQuoted 69 lines · Amir Goldstein
Test multiple groups with evictable mark with ignore mask
Signed-off-by Amir Goldstein <[email protected]>--- .../kernel/syscalls/fanotify/fanotify10.c | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+)testcases/kernel/syscalls/fanotify/fanotify10.c +26
-0@@ -71,6 +71,7 @@ static char event_buf[EVENT_BUF_LEN];static int exec_events_unsupported;static int fan_report_dfid_unsupported;static int filesystem_mark_unsupported; +static int evictable_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint"@@ -90,6 +91,10 @@ static int filesystem_mark_unsupported;#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2 +#define DROP_CACHES_FILE "/proc/sys/vm/drop_caches" +#define CACHE_PRESSURE_FILE "/proc/sys/vm/vfs_cache_pressure" + +static int old_cache_pressure;static pid_t child_pid;static int bind_mount_created;static unsigned int num_classes =NUM_CLASSES ;@@ -98,12 +103,14 @@ enum {FANOTIFY_INODE ,FANOTIFY_MOUNT ,FANOTIFY_FILESYSTEM , + FANOTIFY_EVICTABLE, };static struct fanotify_mark_type fanotify_mark_types[] = {INIT_FANOTIFY_MARK_TYPE (INODE ),INIT_FANOTIFY_MARK_TYPE (MOUNT ),INIT_FANOTIFY_MARK_TYPE (FILESYSTEM ), +INIT_FANOTIFY_MARK_TYPE (EVICTABLE ), }; static struct tcase {@@ -289,14 +296,59 @@ static struct tcase {0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, +/* Evictable ignore mark test cases */ + { +"don't ignore mount events created on file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created on a file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore mount events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , + DIR_PATH, FANOTIFY_EVICTABLE,
testcases/kernel/syscalls/fanotify/fanotify10.c static struct tcase { · line 327
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +10
-0+FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +DIR_PATH ,FANOTIFY_EVICTABLE , +FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + },
Hi,
we are seeing some sporadic failures from this last testcase, with recent upstream kernels (v5.19-rc4-14-g941e3e791269).
Has anyone also ran into it and knows if it's bug on test side or kernel?
fanotify10.c:496: TINFO: Test #27: don't ignore fs events created inside a parent with evicted ignore mark
fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
fanotify10.c:455: TPASS: group 0 (8) got event: mask 20 pid=13307 fd=15 fanotify10.c:455: TPASS: group 1 (8) got event: mask 20 pid=13307 fd=15 fanotify10.c:455: TPASS: group 2 (8) got event: mask 20 pid=13307 fd=15 fanotify10.c:538: TFAIL: group 0 (4) with FAN_MARK_FILESYSTEM did not get event fanotify10.c:538: TFAIL: group 1 (4) with FAN_MARK_FILESYSTEM did not get event fanotify10.c:538: TFAIL: group 2 (4) with FAN_MARK_FILESYSTEM did not get event fanotify10.c:538: TFAIL: group 0 (0) with FAN_MARK_FILESYSTEM did not get event fanotify10.c:538: TFAIL: group 1 (0) with FAN_MARK_FILESYSTEM did not get event fanotify10.c:538: TFAIL: group 2 (0) with FAN_MARK_FILESYSTEM did not get event fanotify10.c:538: TFAIL: group 0 (e00) with FAN_MARK_FILESYSTEM did not get event
fanotify10.c:538: TFAIL: group 1 (e00) with FAN_MARK_FILESYSTEM did not get event
fanotify10.c:538: TFAIL: group 2 (e00) with FAN_MARK_FILESYSTEM did not get event
Thanks,
Jan
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
Quoted 88 lines · Jan Stancek
Quoted 69 lines · Amir Goldstein
Test multiple groups with evictable mark with ignore mask
Signed-off-by Amir Goldstein <[email protected]>--- .../kernel/syscalls/fanotify/fanotify10.c | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+)testcases/kernel/syscalls/fanotify/fanotify10.c +26
-0@@ -71,6 +71,7 @@ static char event_buf[EVENT_BUF_LEN];static int exec_events_unsupported;static int fan_report_dfid_unsupported;static int filesystem_mark_unsupported; +static int evictable_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint"@@ -90,6 +91,10 @@ static int filesystem_mark_unsupported;#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2 +#define DROP_CACHES_FILE "/proc/sys/vm/drop_caches" +#define CACHE_PRESSURE_FILE "/proc/sys/vm/vfs_cache_pressure" + +static int old_cache_pressure;static pid_t child_pid;static int bind_mount_created;static unsigned int num_classes =NUM_CLASSES ;@@ -98,12 +103,14 @@ enum {FANOTIFY_INODE ,FANOTIFY_MOUNT ,FANOTIFY_FILESYSTEM , + FANOTIFY_EVICTABLE, };static struct fanotify_mark_type fanotify_mark_types[] = {INIT_FANOTIFY_MARK_TYPE (INODE ),INIT_FANOTIFY_MARK_TYPE (MOUNT ),INIT_FANOTIFY_MARK_TYPE (FILESYSTEM ), +INIT_FANOTIFY_MARK_TYPE (EVICTABLE ), }; static struct tcase {@@ -289,14 +296,59 @@ static struct tcase {0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, +/* Evictable ignore mark test cases */ + { +"don't ignore mount events created on file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created on a file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore mount events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , + DIR_PATH, FANOTIFY_EVICTABLE,testcases/kernel/syscalls/fanotify/fanotify10.c static struct tcase { · line 327
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +10
-0+FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +DIR_PATH ,FANOTIFY_EVICTABLE , +FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + },Hi,
we are seeing some sporadic failures from this last testcase, with recent upstream kernels (v5.19-rc4-14-g941e3e791269).
Has anyone also ran into it and knows if it's bug on test side or kernel?
Quoted 7 lines
fanotify10.c:496: TINFO: Test #27: don't ignore fs events created inside a parent with evicted ignore mark fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
It is a test bug.
The problem is that we want to evict an inode, but there is no reliable mechanism to do that.
This is the reason for this workaround in fanotify23:
/* Shrinkers on other fs do not work reliably enough to
guarantee mark eviction on drop_caches */
.dev_fs_type = "ext2",I did not encounter the problem with fanotify10 myself, but it should be the same.
fanotify10 is not filesystem dependent, so if you can apply the same workaround from fanotify23 and it works on your systems we can do that.
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
Quoted 104 lines · Amir Goldstein
Quoted 88 lines · Jan Stancek
Quoted 69 lines · Amir Goldstein
Test multiple groups with evictable mark with ignore mask
Signed-off-by Amir Goldstein <[email protected]>--- .../kernel/syscalls/fanotify/fanotify10.c | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+)testcases/kernel/syscalls/fanotify/fanotify10.c +26
-0@@ -71,6 +71,7 @@ static char event_buf[EVENT_BUF_LEN];static int exec_events_unsupported;static int fan_report_dfid_unsupported;static int filesystem_mark_unsupported; +static int evictable_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint"@@ -90,6 +91,10 @@ static int filesystem_mark_unsupported;#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2 +#define DROP_CACHES_FILE "/proc/sys/vm/drop_caches" +#define CACHE_PRESSURE_FILE "/proc/sys/vm/vfs_cache_pressure" + +static int old_cache_pressure;static pid_t child_pid;static int bind_mount_created;static unsigned int num_classes =NUM_CLASSES ;@@ -98,12 +103,14 @@ enum {FANOTIFY_INODE ,FANOTIFY_MOUNT ,FANOTIFY_FILESYSTEM , + FANOTIFY_EVICTABLE, };static struct fanotify_mark_type fanotify_mark_types[] = {INIT_FANOTIFY_MARK_TYPE (INODE ),INIT_FANOTIFY_MARK_TYPE (MOUNT ),INIT_FANOTIFY_MARK_TYPE (FILESYSTEM ), +INIT_FANOTIFY_MARK_TYPE (EVICTABLE ), }; static struct tcase {@@ -289,14 +296,59 @@ static struct tcase {0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, +/* Evictable ignore mark test cases */ + { +"don't ignore mount events created on file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created on a file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore mount events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , + DIR_PATH, FANOTIFY_EVICTABLE,testcases/kernel/syscalls/fanotify/fanotify10.c static struct tcase { · line 327
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +10
-0+FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +DIR_PATH ,FANOTIFY_EVICTABLE , +FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + },Hi,
we are seeing some sporadic failures from this last testcase, with recent upstream kernels (v5.19-rc4-14-g941e3e791269).
Has anyone also ran into it and knows if it's bug on test side or kernel?Quoted 7 lines
fanotify10.c:496: TINFO: Test #27: don't ignore fs events created inside a parent with evicted ignore mark fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
It is a test bug.
The problem is that we want to evict an inode, but there is no reliable mechanism to do that.This is the reason for this workaround in fanotify23:
Quoted 8 lines
/* Shrinkers on other fs do not work reliably enough to guarantee mark eviction on drop_caches */ .dev_fs_type = "ext2",I did not encounter the problem with fanotify10 myself, but it should be the same.
fanotify10 is not filesystem dependent, so if you can apply the same workaround from fanotify23 and it works on your systems we can do that.
Test is using default fs type, which should already be ext2. Here's a more complete log from failed test:
https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/06/30/redhat:576928171/build_ppc64le_redhat:576928171_ppc64le/tests/1/results_0001/job.01/recipes/12221009/tasks/8/logs/syscalls.fail.log
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
Quoted 88 lines · Jan Stancek
Quoted 86 lines · Amir Goldstein
Quoted 84 lines · Jan Stancek
Quoted 69 lines · Amir Goldstein
Test multiple groups with evictable mark with ignore mask
Signed-off-by Amir Goldstein <[email protected]>--- .../kernel/syscalls/fanotify/fanotify10.c | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+)testcases/kernel/syscalls/fanotify/fanotify10.c +26
-0@@ -71,6 +71,7 @@ static char event_buf[EVENT_BUF_LEN];static int exec_events_unsupported;static int fan_report_dfid_unsupported;static int filesystem_mark_unsupported; +static int evictable_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint"@@ -90,6 +91,10 @@ static int filesystem_mark_unsupported;#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2 +#define DROP_CACHES_FILE "/proc/sys/vm/drop_caches" +#define CACHE_PRESSURE_FILE "/proc/sys/vm/vfs_cache_pressure" + +static int old_cache_pressure;static pid_t child_pid;static int bind_mount_created;static unsigned int num_classes =NUM_CLASSES ;@@ -98,12 +103,14 @@ enum {FANOTIFY_INODE ,FANOTIFY_MOUNT ,FANOTIFY_FILESYSTEM , + FANOTIFY_EVICTABLE, };static struct fanotify_mark_type fanotify_mark_types[] = {INIT_FANOTIFY_MARK_TYPE (INODE ),INIT_FANOTIFY_MARK_TYPE (MOUNT ),INIT_FANOTIFY_MARK_TYPE (FILESYSTEM ), +INIT_FANOTIFY_MARK_TYPE (EVICTABLE ), }; static struct tcase {@@ -289,14 +296,59 @@ static struct tcase {0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, +/* Evictable ignore mark test cases */ + { +"don't ignore mount events created on file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created on a file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore mount events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , + DIR_PATH, FANOTIFY_EVICTABLE,testcases/kernel/syscalls/fanotify/fanotify10.c static struct tcase { · line 327
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +10
-0+FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +DIR_PATH ,FANOTIFY_EVICTABLE , +FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + },Hi,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
we are seeing some sporadic failures from this last testcase, with recent upstream kernels (v5.19-rc4-14-g941e3e791269).
Has anyone also ran into it and knows if it's bug on test side or kernel?
Hi Jan,
I am traveling so I cannot work on solving the problem for the next week, but I can explain the problem and offer suggestions for short term solutions and maybe a longer term solution.
Quoted 19 lines
Quoted 19 lines
Quoted 8 lines
fanotify10.c:496: TINFO: Test #27: don't ignore fs events created inside a parent with evicted ignore mark fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
It is a test bug.
The problem is that we want to evict an inode, but there is no reliable mechanism to do that.This is the reason for this workaround in fanotify23:
/* Shrinkers on other fs do not work reliably enough to guarantee mark eviction on drop_caches */ .dev_fs_type = "ext2",
Quoted 6 lines
Quoted 4 lines
I did not encounter the problem with fanotify10 myself, but it should be the same.
fanotify10 is not filesystem dependent, so if you can apply the same workaround from fanotify23 and it works on your systems we can do that.Test is using default fs type, which should already be ext2.
I see. You can try xfs on your system to see if it behaves better, because xfs has a specialized inode shriker.
Quoted 3 lines
Here's a more complete log from failed test:
https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/06/30/redhat:576928171/build_ppc64le_redhat:576928171_ppc64le/tests/1/results_0001/job.01/recipes/12221009/tasks/8/logs/syscalls.fail.log
Are the failures only in the first test iteration?
As a long shot, I would try to remove mount_cycle() from setup(). I see that fanotify23 does not have it and it is not really needed, so it may help
fanotify10 pass the first iteration.
The problem is that the drop_caches knob is not a reliable way to evict inodes, so when a test like fanotify10 needs to evict an inode, random factors are mixed into the test run.
As a quick band aid, I suggest to replace the TFAIL, "Unexpected inode mark" in show_fanotify_marks() with TCONF, because the test failed to setup an "evictable ignored mark that gets evicted", propagate a failure return value fromcreate_fanotify_groups() => show_fanotify_marks() and skip the test case instead of failing it.
For long term, it would be nice if LTP could provide a drop_inode_cache() library
function that tries harder to make inode eviction work using tricks like fanotify10
and fanotify23 increases vfs_cache_pressure.
To pressure memory shrinkers to evict more inodes, need to check the amount of total RAM in the system and dirty pages and add enough dirty memory pages that cannot be evicted to drive the inode shrinker to work harder. Utilizing memory cgroups with some of the new per memcg cache eviction knobs could also be an option, but I did not look into it and not sure on which kernels
this is available.
Bottom line is that there is a lot of black magic involved with memory shrinkers and as your report shows, hacks and trick may impact different systems in different ways, so it is better it the infrastructure is developed and tested in LTP lib and not in individual tests.
Hope this helps.
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
Quoted 126 lines · Amir Goldstein
Quoted 88 lines · Jan Stancek
Quoted 86 lines · Amir Goldstein
Quoted 84 lines · Jan Stancek
Quoted 69 lines · Amir Goldstein
Test multiple groups with evictable mark with ignore mask
Signed-off-by Amir Goldstein <[email protected]>--- .../kernel/syscalls/fanotify/fanotify10.c | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+)testcases/kernel/syscalls/fanotify/fanotify10.c +26
-0@@ -71,6 +71,7 @@ static char event_buf[EVENT_BUF_LEN];static int exec_events_unsupported;static int fan_report_dfid_unsupported;static int filesystem_mark_unsupported; +static int evictable_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint"@@ -90,6 +91,10 @@ static int filesystem_mark_unsupported;#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2 +#define DROP_CACHES_FILE "/proc/sys/vm/drop_caches" +#define CACHE_PRESSURE_FILE "/proc/sys/vm/vfs_cache_pressure" + +static int old_cache_pressure;static pid_t child_pid;static int bind_mount_created;static unsigned int num_classes =NUM_CLASSES ;@@ -98,12 +103,14 @@ enum {FANOTIFY_INODE ,FANOTIFY_MOUNT ,FANOTIFY_FILESYSTEM , + FANOTIFY_EVICTABLE, };static struct fanotify_mark_type fanotify_mark_types[] = {INIT_FANOTIFY_MARK_TYPE (INODE ),INIT_FANOTIFY_MARK_TYPE (MOUNT ),INIT_FANOTIFY_MARK_TYPE (FILESYSTEM ), +INIT_FANOTIFY_MARK_TYPE (EVICTABLE ), }; static struct tcase {@@ -289,14 +296,59 @@ static struct tcase {0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, +/* Evictable ignore mark test cases */ + { +"don't ignore mount events created on file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created on a file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore mount events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , + DIR_PATH, FANOTIFY_EVICTABLE,testcases/kernel/syscalls/fanotify/fanotify10.c static struct tcase { · line 327
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +10
-0+FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +DIR_PATH ,FANOTIFY_EVICTABLE , +FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + },Hi,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
we are seeing some sporadic failures from this last testcase, with recent upstream kernels (v5.19-rc4-14-g941e3e791269).
Has anyone also ran into it and knows if it's bug on test side or kernel?Hi Jan,
I am traveling so I cannot work on solving the problem for the next week, but I can explain the problem and offer suggestions for short term solutions and maybe a longer term solution.
Quoted 19 lines
Quoted 19 lines
Quoted 8 lines
fanotify10.c:496: TINFO: Test #27: don't ignore fs events created inside a parent with evicted ignore mark fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
It is a test bug.
The problem is that we want to evict an inode, but there is no reliable mechanism to do that.This is the reason for this workaround in fanotify23:
/* Shrinkers on other fs do not work reliably enough to guarantee mark eviction on drop_caches */ .dev_fs_type = "ext2",Quoted 6 lines
Quoted 4 lines
I did not encounter the problem with fanotify10 myself, but it should be the same.
fanotify10 is not filesystem dependent, so if you can apply the same workaround from fanotify23 and it works on your systems we can do that.Test is using default fs type, which should already be ext2.
Quoted 8 lines
I see. You can try xfs on your system to see if it behaves better, because xfs has a specialized inode shriker.
Quoted 3 lines
Here's a more complete log from failed test:
https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/06/30/redhat:576928171/build_ppc64le_redhat:576928171_ppc64le/tests/1/results_0001/job.01/recipes/12221009/tasks/8/logs/syscalls.fail.logAre the failures only in the first test iteration?
I think so. It runs in automated environment, where we see failures about once a week. I haven't managed to reproduce it by hand yet.
Quoted 10 lines
As a long shot, I would try to remove
mount_cycle()fromsetup(). I see that fanotify23 does not have it and it is not really needed, so it may help
fanotify10 pass the first iteration.The problem is that the
drop_cachesknob is not a reliable way to evict inodes, so when a test like fanotify10 needs to evict an inode, random factors are mixed into the test run.
Quoted 6 lines
As a quick band aid, I suggest to replace the TFAIL, "Unexpected inode mark" in
show_fanotify_marks()with TCONF, because the test failed to setup an "evictable ignored mark that gets evicted", propagate a failure return value fromcreate_fanotify_groups()=>show_fanotify_marks()and skip the test case instead of failing it.
Thanks for suggestion.
Quoted 24 lines
For long term, it would be nice if LTP could provide a
drop_inode_cache()library
function that tries harder to make inode eviction work using tricks like fanotify10
and fanotify23 increasesvfs_cache_pressure.
To pressure memory shrinkers to evict more inodes, need to check the amount of total RAM in the system and dirty pages and add enough dirty memory pages that cannot be evicted to drive the inode shrinker to work harder. Utilizing memory cgroups with some of the new per memcg cache eviction knobs could also be an option, but I did not look into it and not sure on which kernels
this is available.Bottom line is that there is a lot of black magic involved with memory shrinkers and as your report shows, hacks and trick may impact different systems in different ways, so it is better it the infrastructure is developed and tested in LTP lib and not in individual tests.
Hope this helps.
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
Quoted 149 lines · Jan Stancek
Quoted 126 lines · Amir Goldstein
Quoted 88 lines · Jan Stancek
Quoted 86 lines · Amir Goldstein
Quoted 84 lines · Jan Stancek
Quoted 69 lines · Amir Goldstein
Test multiple groups with evictable mark with ignore mask
Signed-off-by Amir Goldstein <[email protected]>--- .../kernel/syscalls/fanotify/fanotify10.c | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+)testcases/kernel/syscalls/fanotify/fanotify10.c +26
-0@@ -71,6 +71,7 @@ static char event_buf[EVENT_BUF_LEN];static int exec_events_unsupported;static int fan_report_dfid_unsupported;static int filesystem_mark_unsupported; +static int evictable_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint"@@ -90,6 +91,10 @@ static int filesystem_mark_unsupported;#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2 +#define DROP_CACHES_FILE "/proc/sys/vm/drop_caches" +#define CACHE_PRESSURE_FILE "/proc/sys/vm/vfs_cache_pressure" + +static int old_cache_pressure;static pid_t child_pid;static int bind_mount_created;static unsigned int num_classes =NUM_CLASSES ;@@ -98,12 +103,14 @@ enum {FANOTIFY_INODE ,FANOTIFY_MOUNT ,FANOTIFY_FILESYSTEM , + FANOTIFY_EVICTABLE, };static struct fanotify_mark_type fanotify_mark_types[] = {INIT_FANOTIFY_MARK_TYPE (INODE ),INIT_FANOTIFY_MARK_TYPE (MOUNT ),INIT_FANOTIFY_MARK_TYPE (FILESYSTEM ), +INIT_FANOTIFY_MARK_TYPE (EVICTABLE ), }; static struct tcase {@@ -289,14 +296,59 @@ static struct tcase {0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, +/* Evictable ignore mark test cases */ + { +"don't ignore mount events created on file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created on a file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore mount events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , + DIR_PATH, FANOTIFY_EVICTABLE,testcases/kernel/syscalls/fanotify/fanotify10.c static struct tcase { · line 327
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +10
-0+FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +DIR_PATH ,FANOTIFY_EVICTABLE , +FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + },Hi,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
we are seeing some sporadic failures from this last testcase, with recent upstream kernels (v5.19-rc4-14-g941e3e791269).
Has anyone also ran into it and knows if it's bug on test side or kernel?Hi Jan,
I am traveling so I cannot work on solving the problem for the next week, but I can explain the problem and offer suggestions for short term solutions and maybe a longer term solution.
Quoted 19 lines
Quoted 19 lines
Quoted 8 lines
fanotify10.c:496: TINFO: Test #27: don't ignore fs events created inside a parent with evicted ignore mark fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
It is a test bug.
The problem is that we want to evict an inode, but there is no reliable mechanism to do that.This is the reason for this workaround in fanotify23:
/* Shrinkers on other fs do not work reliably enough to guarantee mark eviction on drop_caches */ .dev_fs_type = "ext2",Quoted 6 lines
Quoted 4 lines
I did not encounter the problem with fanotify10 myself, but it should be the same.
fanotify10 is not filesystem dependent, so if you can apply the same workaround from fanotify23 and it works on your systems we can do that.Test is using default fs type, which should already be ext2.
Quoted 8 lines
I see. You can try xfs on your system to see if it behaves better, because xfs has a specialized inode shriker.
Quoted 3 lines
Here's a more complete log from failed test:
https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/06/30/redhat:576928171/build_ppc64le_redhat:576928171_ppc64le/tests/1/results_0001/job.01/recipes/12221009/tasks/8/logs/syscalls.fail.logAre the failures only in the first test iteration?
I think so. It runs in automated environment, where we see failures about once a week. I haven't managed to reproduce it by hand yet.
Quoted 10 lines
As a long shot, I would try to remove
mount_cycle()fromsetup(). I see that fanotify23 does not have it and it is not really needed, so it may help
fanotify10 pass the first iteration.The problem is that the
drop_cachesknob is not a reliable way to evict inodes, so when a test like fanotify10 needs to evict an inode, random factors are mixed into the test run.
Quoted 8 lines
Quoted 6 lines
As a quick band aid, I suggest to replace the TFAIL, "Unexpected inode mark" in
show_fanotify_marks()with TCONF, because the test failed to setup an "evictable ignored mark that gets evicted", propagate a failure return value fromcreate_fanotify_groups()=>show_fanotify_marks()and skip the test case instead of failing it.Thanks for suggestion.
Is this still an issue? I didn't see anything happening in the fanotify10 test upstream. If the issue still happens, maybe something like the attached patch may improve the situation? Jan, do you have a chance to test it?
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
From 988e3eb2ac0cdffa447c9ffc71256f460ae01a94 Mon Sep 17 00:00:00 2001
From: Jan Kara <[email protected]>
Date: Wed, 24 Aug 2022 13:26:29 +0200
Subject: [PATCH] syscalls/fanotify10: Make evictable marks test more reliable
In some setups evictable marks tests are failing because the inode with evictable mark does not get evicted. Make sure we sync the filesystem before we try to drop caches to increase likelyhood the inode will get evicted.
--- testcases/kernel/syscalls/fanotify/fanotify10.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/fanotify/fanotify10.c +10 -1
@@ -342,6 +342,15 @@ static void show_fanotify_marks(int fd) } } +static void drop_caches (char *path) +{ +int fd =SAFE_OPEN (path,O_RDONLY ); +if (syncfs (fd) <0 ) +tst_brk (TBROK |TERRNO ,"Unexpected error when syncing filesystem" ); +SAFE_CLOSE (fd); +SAFE_FILE_PRINTF (DROP_CACHES_FILE ,"3" ); +} +static int create_fanotify_groups (unsigned int n) {struct tcase *tc = &tcases[n];
@@ -402,7 +411,7 @@ add_mark:* drop_caches should evict inode from cache and remove evictable marks */ if (evictable_ignored) { -SAFE_FILE_PRINTF (DROP_CACHES_FILE ,"3" ); +drop_caches (tc->mark_path);for (p =0 ; p < num_classes; p++) {for (i =0 ; i <GROUPS_PER_PRIO ; i++) {if (fd_notify[p][i] >0 )
Signature · 1 line
2.35.3
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
Quoted 158 lines · Jan Kara
Quoted 156 lines · Jan Stancek
Quoted 126 lines · Amir Goldstein
Quoted 88 lines · Jan Stancek
Quoted 86 lines · Amir Goldstein
Quoted 84 lines · Jan Stancek
Quoted 69 lines · Amir Goldstein
Test multiple groups with evictable mark with ignore mask
Signed-off-by Amir Goldstein <[email protected]>--- .../kernel/syscalls/fanotify/fanotify10.c | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+)testcases/kernel/syscalls/fanotify/fanotify10.c +26
-0@@ -71,6 +71,7 @@ static char event_buf[EVENT_BUF_LEN];static int exec_events_unsupported;static int fan_report_dfid_unsupported;static int filesystem_mark_unsupported; +static int evictable_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint"@@ -90,6 +91,10 @@ static int filesystem_mark_unsupported;#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2 +#define DROP_CACHES_FILE "/proc/sys/vm/drop_caches" +#define CACHE_PRESSURE_FILE "/proc/sys/vm/vfs_cache_pressure" + +static int old_cache_pressure;static pid_t child_pid;static int bind_mount_created;static unsigned int num_classes =NUM_CLASSES ;@@ -98,12 +103,14 @@ enum {FANOTIFY_INODE ,FANOTIFY_MOUNT ,FANOTIFY_FILESYSTEM , + FANOTIFY_EVICTABLE, };static struct fanotify_mark_type fanotify_mark_types[] = {INIT_FANOTIFY_MARK_TYPE (INODE ),INIT_FANOTIFY_MARK_TYPE (MOUNT ),INIT_FANOTIFY_MARK_TYPE (FILESYSTEM ), +INIT_FANOTIFY_MARK_TYPE (EVICTABLE ), }; static struct tcase {@@ -289,14 +296,59 @@ static struct tcase {0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, +/* Evictable ignore mark test cases */ + { +"don't ignore mount events created on file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created on a file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore mount events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , + DIR_PATH, FANOTIFY_EVICTABLE,testcases/kernel/syscalls/fanotify/fanotify10.c static struct tcase { · line 327
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +10
-0+FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +DIR_PATH ,FANOTIFY_EVICTABLE , +FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + },Hi,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
we are seeing some sporadic failures from this last testcase, with recent upstream kernels (v5.19-rc4-14-g941e3e791269).
Has anyone also ran into it and knows if it's bug on test side or kernel?Hi Jan,
I am traveling so I cannot work on solving the problem for the next week, but I can explain the problem and offer suggestions for short term solutions and maybe a longer term solution.
Quoted 19 lines
Quoted 19 lines
Quoted 8 lines
fanotify10.c:496: TINFO: Test #27: don't ignore fs events created inside a parent with evicted ignore mark fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
It is a test bug.
The problem is that we want to evict an inode, but there is no reliable mechanism to do that.This is the reason for this workaround in fanotify23:
/* Shrinkers on other fs do not work reliably enough to guarantee mark eviction on drop_caches */ .dev_fs_type = "ext2",Quoted 6 lines
Quoted 4 lines
I did not encounter the problem with fanotify10 myself, but it should be the same.
fanotify10 is not filesystem dependent, so if you can apply the same workaround from fanotify23 and it works on your systems we can do that.Test is using default fs type, which should already be ext2.
Quoted 8 lines
I see. You can try xfs on your system to see if it behaves better, because xfs has a specialized inode shriker.
Quoted 3 lines
Here's a more complete log from failed test:
https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/06/30/redhat:576928171/build_ppc64le_redhat:576928171_ppc64le/tests/1/results_0001/job.01/recipes/12221009/tasks/8/logs/syscalls.fail.logAre the failures only in the first test iteration?
I think so. It runs in automated environment, where we see failures about once a week. I haven't managed to reproduce it by hand yet.
Quoted 16 lines
As a long shot, I would try to remove
mount_cycle()fromsetup(). I see that fanotify23 does not have it and it is not really needed, so it may help
fanotify10 pass the first iteration.The problem is that the
drop_cachesknob is not a reliable way to evict inodes, so when a test like fanotify10 needs to evict an inode, random factors are mixed into the test run.As a quick band aid, I suggest to replace the TFAIL, "Unexpected inode mark" in
show_fanotify_marks()with TCONF, because the test failed to setup an "evictable ignored mark that gets evicted", propagate a failure return value fromcreate_fanotify_groups()=>show_fanotify_marks()and skip the test case instead of failing it.
Quoted 7 lines
Quoted 1 line
Thanks for suggestion.
Is this still an issue? I didn't see anything happening in the fanotify10 test upstream. If the issue still happens, maybe something like the attached patch may improve the situation? Jan, do you have a chance to test it?
Jan,
Did you notice that the test already does mount_cycle()
after setup and that there is no modification of any file during the test? I don't see how syncfs() would make a difference.
Maybe it's an atime update of the executed file??
I think at some point in the discussion it was said that the issue only happens on the first run of the test loop.
If it's atime update then syncfs() might help and adding noatime mount flags to the test could also fix it.
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
Quoted 173 lines · Amir Goldstein
Quoted 158 lines · Jan Kara
Quoted 156 lines · Jan Stancek
Quoted 126 lines · Amir Goldstein
Quoted 88 lines · Jan Stancek
Quoted 86 lines · Amir Goldstein
Quoted 84 lines · Jan Stancek
Quoted 69 lines · Amir Goldstein
Test multiple groups with evictable mark with ignore mask
Signed-off-by Amir Goldstein <[email protected]>--- .../kernel/syscalls/fanotify/fanotify10.c | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+)testcases/kernel/syscalls/fanotify/fanotify10.c +26
-0@@ -71,6 +71,7 @@ static char event_buf[EVENT_BUF_LEN];static int exec_events_unsupported;static int fan_report_dfid_unsupported;static int filesystem_mark_unsupported; +static int evictable_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint"@@ -90,6 +91,10 @@ static int filesystem_mark_unsupported;#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2 +#define DROP_CACHES_FILE "/proc/sys/vm/drop_caches" +#define CACHE_PRESSURE_FILE "/proc/sys/vm/vfs_cache_pressure" + +static int old_cache_pressure;static pid_t child_pid;static int bind_mount_created;static unsigned int num_classes =NUM_CLASSES ;@@ -98,12 +103,14 @@ enum {FANOTIFY_INODE ,FANOTIFY_MOUNT ,FANOTIFY_FILESYSTEM , + FANOTIFY_EVICTABLE, };static struct fanotify_mark_type fanotify_mark_types[] = {INIT_FANOTIFY_MARK_TYPE (INODE ),INIT_FANOTIFY_MARK_TYPE (MOUNT ),INIT_FANOTIFY_MARK_TYPE (FILESYSTEM ), +INIT_FANOTIFY_MARK_TYPE (EVICTABLE ), }; static struct tcase {@@ -289,14 +296,59 @@ static struct tcase {0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, +/* Evictable ignore mark test cases */ + { +"don't ignore mount events created on file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created on a file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore mount events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , + DIR_PATH, FANOTIFY_EVICTABLE,testcases/kernel/syscalls/fanotify/fanotify10.c static struct tcase { · line 327
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +10
-0+FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +DIR_PATH ,FANOTIFY_EVICTABLE , +FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + },Hi,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
we are seeing some sporadic failures from this last testcase, with recent upstream kernels (v5.19-rc4-14-g941e3e791269).
Has anyone also ran into it and knows if it's bug on test side or kernel?Hi Jan,
I am traveling so I cannot work on solving the problem for the next week, but I can explain the problem and offer suggestions for short term solutions and maybe a longer term solution.
Quoted 19 lines
Quoted 19 lines
Quoted 8 lines
fanotify10.c:496: TINFO: Test #27: don't ignore fs events created inside a parent with evicted ignore mark fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
It is a test bug.
The problem is that we want to evict an inode, but there is no reliable mechanism to do that.This is the reason for this workaround in fanotify23:
/* Shrinkers on other fs do not work reliably enough to guarantee mark eviction on drop_caches */ .dev_fs_type = "ext2",Quoted 6 lines
Quoted 4 lines
I did not encounter the problem with fanotify10 myself, but it should be the same.
fanotify10 is not filesystem dependent, so if you can apply the same workaround from fanotify23 and it works on your systems we can do that.Test is using default fs type, which should already be ext2.
Quoted 8 lines
I see. You can try xfs on your system to see if it behaves better, because xfs has a specialized inode shriker.
Quoted 3 lines
Here's a more complete log from failed test:
https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/06/30/redhat:576928171/build_ppc64le_redhat:576928171_ppc64le/tests/1/results_0001/job.01/recipes/12221009/tasks/8/logs/syscalls.fail.logAre the failures only in the first test iteration?
I think so. It runs in automated environment, where we see failures about once a week. I haven't managed to reproduce it by hand yet.
Quoted 16 lines
As a long shot, I would try to remove
mount_cycle()fromsetup(). I see that fanotify23 does not have it and it is not really needed, so it may help
fanotify10 pass the first iteration.The problem is that the
drop_cachesknob is not a reliable way to evict inodes, so when a test like fanotify10 needs to evict an inode, random factors are mixed into the test run.As a quick band aid, I suggest to replace the TFAIL, "Unexpected inode mark" in
show_fanotify_marks()with TCONF, because the test failed to setup an "evictable ignored mark that gets evicted", propagate a failure return value fromcreate_fanotify_groups()=>show_fanotify_marks()and skip the test case instead of failing it.Quoted 7 lines
Quoted 1 line
Thanks for suggestion.
Is this still an issue? I didn't see anything happening in the fanotify10 test upstream. If the issue still happens, maybe something like the attached patch may improve the situation? Jan, do you have a chance to test it?
Jan,
Did you notice that the test already does
mount_cycle()
after setup and that there is no modification of any file during the test? I don't see howsyncfs()would make a difference.
Quoted 6 lines
Maybe it's an atime update of the executed file??
I think at some point in the discussion it was said that the issue only happens on the first run of the test loop.If it's atime update then
syncfs()might help and adding noatime mount flags to the test could also fix it.
Yes, I was suspecting atime update because by default LTP mounts filesystems with full atime support enabled. And I agree noatime should solve that as well but syncfs() just seemed as more robust and future-proof to me...
Honza
Signature · 5 lines
Jan Kara <[email protected]> SUSE Labs, CR -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
In reply to Jan KaraQuoted 158 lines · Jan Kara
Quoted 156 lines · Jan Stancek
Quoted 126 lines · Amir Goldstein
Quoted 88 lines · Jan Stancek
Quoted 86 lines · Amir Goldstein
Quoted 84 lines · Jan Stancek
Quoted 69 lines · Amir Goldstein
Test multiple groups with evictable mark with ignore mask
Signed-off-by Amir Goldstein <[email protected]>--- .../kernel/syscalls/fanotify/fanotify10.c | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+)testcases/kernel/syscalls/fanotify/fanotify10.c +26
-0@@ -71,6 +71,7 @@ static char event_buf[EVENT_BUF_LEN];static int exec_events_unsupported;static int fan_report_dfid_unsupported;static int filesystem_mark_unsupported; +static int evictable_mark_unsupported;#define MOUNT_PATH "fs_mnt"#define MNT2_PATH "mntpoint"@@ -90,6 +91,10 @@ static int filesystem_mark_unsupported;#define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP#define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2 +#define DROP_CACHES_FILE "/proc/sys/vm/drop_caches" +#define CACHE_PRESSURE_FILE "/proc/sys/vm/vfs_cache_pressure" + +static int old_cache_pressure;static pid_t child_pid;static int bind_mount_created;static unsigned int num_classes =NUM_CLASSES ;@@ -98,12 +103,14 @@ enum {FANOTIFY_INODE ,FANOTIFY_MOUNT ,FANOTIFY_FILESYSTEM , + FANOTIFY_EVICTABLE, };static struct fanotify_mark_type fanotify_mark_types[] = {INIT_FANOTIFY_MARK_TYPE (INODE ),INIT_FANOTIFY_MARK_TYPE (MOUNT ),INIT_FANOTIFY_MARK_TYPE (FILESYSTEM ), +INIT_FANOTIFY_MARK_TYPE (EVICTABLE ), }; static struct tcase {@@ -289,14 +296,59 @@ static struct tcase {0 ,FILE_PATH ,FAN_OPEN ,FAN_OPEN }, +/* Evictable ignore mark test cases */ + { +"don't ignore mount events created on file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created on a file with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +FILE_PATH ,FANOTIFY_EVICTABLE , +0 , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore mount events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_MOUNT , + DIR_PATH, FANOTIFY_EVICTABLE,testcases/kernel/syscalls/fanotify/fanotify10.c static struct tcase { · line 327
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify10.c +10
-0+FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + }, + { +"don't ignore fs events created inside a parent with evicted ignore mark" , +MOUNT_PATH ,FANOTIFY_FILESYSTEM , +DIR_PATH ,FANOTIFY_EVICTABLE , +FAN_EVENT_ON_CHILD , +FILE_PATH ,FAN_OPEN ,FAN_OPEN + },Hi,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
we are seeing some sporadic failures from this last testcase, with recent upstream kernels (v5.19-rc4-14-g941e3e791269).
Has anyone also ran into it and knows if it's bug on test side or kernel?Hi Jan,
I am traveling so I cannot work on solving the problem for the next week, but I can explain the problem and offer suggestions for short term solutions and maybe a longer term solution.
Quoted 19 lines
Quoted 19 lines
Quoted 8 lines
fanotify10.c:496: TINFO: Test #27: don't ignore fs events created inside a parent with evicted ignore mark fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:338: TPASS: No fanotify inode marks as expected fanotify10.c:340: TFAIL: Unexpected inode mark (mflags=240, mask=8000020 ignored_mask=20)
It is a test bug.
The problem is that we want to evict an inode, but there is no reliable mechanism to do that.This is the reason for this workaround in fanotify23:
/* Shrinkers on other fs do not work reliably enough to guarantee mark eviction on drop_caches */ .dev_fs_type = "ext2",Quoted 6 lines
Quoted 4 lines
I did not encounter the problem with fanotify10 myself, but it should be the same.
fanotify10 is not filesystem dependent, so if you can apply the same workaround from fanotify23 and it works on your systems we can do that.Test is using default fs type, which should already be ext2.
Quoted 8 lines
I see. You can try xfs on your system to see if it behaves better, because xfs has a specialized inode shriker.
Quoted 3 lines
Here's a more complete log from failed test:
https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/06/30/redhat:576928171/build_ppc64le_redhat:576928171_ppc64le/tests/1/results_0001/job.01/recipes/12221009/tasks/8/logs/syscalls.fail.logAre the failures only in the first test iteration?
I think so. It runs in automated environment, where we see failures about once a week. I haven't managed to reproduce it by hand yet.
Quoted 16 lines
As a long shot, I would try to remove
mount_cycle()fromsetup(). I see that fanotify23 does not have it and it is not really needed, so it may help
fanotify10 pass the first iteration.The problem is that the
drop_cachesknob is not a reliable way to evict inodes, so when a test like fanotify10 needs to evict an inode, random factors are mixed into the test run.As a quick band aid, I suggest to replace the TFAIL, "Unexpected inode mark" in
show_fanotify_marks()with TCONF, because the test failed to setup an "evictable ignored mark that gets evicted", propagate a failure return value fromcreate_fanotify_groups()=>show_fanotify_marks()and skip the test case instead of failing it.
Quoted 3 lines
Quoted 1 line
Thanks for suggestion.
Is this still an issue?
It still rarely fails - two instances in last 3 weeks:
6.0.0-0.rc1.13.test.eln
https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/08/15/redhat:613661619/build_x86_64_redhat:613661619_x86_64/tests/3/results_0001/job.01/recipes/12445146/tasks/10/logs/syscalls.fail.log
Quoted 4 lines
I didn't see anything happening in the fanotify10
test upstream. If the issue still happens, maybe something like the attached patch may improve the situation? Jan, do you have a chance to test it?
I can't reproduce failure on demand. If the patch doesn't have any side-effects, then let's apply it, and we'll see in couple weeks.
Regards,
Jan
Quoted 5 lines
Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Amir Goldstein
Acked-byRe: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
Quoted 9 lines
Quoted 1 line
Is this still an issue?
It still rarely fails - two instances in last 3 weeks:
6.0.0-0.rc1.13.test.eln
https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/08/15/redhat:613661619/build_x86_64_redhat:613661619_x86_64/tests/3/results_0001/job.01/recipes/12445146/tasks/10/logs/syscalls.fail.log
Quoted 8 lines
Quoted 4 lines
I didn't see anything happening in the fanotify10
test upstream. If the issue still happens, maybe something like the attached patch may improve the situation? Jan, do you have a chance to test it?I can't reproduce failure on demand. If the patch doesn't have any side-effects, then let's apply it, and we'll see in couple weeks.
Yes, let's do that please.
Thanks,
Amir.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
Quoted 14 lines · Amir Goldstein
Quoted 14 lines
Quoted 1 line
Is this still an issue?
It still rarely fails - two instances in last 3 weeks:
6.0.0-0.rc1.13.test.eln
https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/08/15/redhat:613661619/build_x86_64_redhat:613661619_x86_64/tests/3/results_0001/job.01/recipes/12445146/tasks/10/logs/syscalls.fail.logQuoted 4 lines
I didn't see anything happening in the fanotify10
test upstream. If the issue still happens, maybe something like the attached patch may improve the situation? Jan, do you have a chance to test it?
Quoted 7 lines
Quoted 3 lines
I can't reproduce failure on demand. If the patch doesn't have any side-effects, then let's apply it, and we'll see in couple weeks.
Yes, let's do that please.
Acked-by Amir Goldstein <[email protected]>
Agreed. Done official submission.
Honza
Signature · 5 lines
Jan Kara <[email protected]> SUSE Labs, CR -- Mailing list info: https://lists.linux.it/listinfo/ltp