All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/5] Fanotify tests for FAN_MARK_EVICTABLE
@ 2022-06-13 14:38 Amir Goldstein
  2022-06-13 14:38 ` [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags Amir Goldstein
                   ` (4 more replies)
  0 siblings, 5 replies; 35+ messages in thread
From: Amir Goldstein @ 2022-06-13 14:38 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Matthew Bobrowski, Jan Kara, ltp

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

-- 
2.25.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
  2022-06-13 14:38 [LTP] [PATCH 0/5] Fanotify tests for FAN_MARK_EVICTABLE Amir Goldstein
@ 2022-06-13 14:38 ` Amir Goldstein
  2022-06-13 14:58   ` Amir Goldstein
                     ` (2 more replies)
  2022-06-13 14:38 ` [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test Amir Goldstein
                   ` (3 subsequent siblings)
  4 siblings, 3 replies; 35+ messages in thread
From: Amir Goldstein @ 2022-06-13 14:38 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Matthew Bobrowski, Jan Kara, ltp

Test behavior of IN_ONESHOT and IN_EXCL_UNLINK.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 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

diff --git a/runtest/syscalls b/runtest/syscalls
index 3b26d19e6..1259e41f1 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -588,6 +588,7 @@ inotify08 inotify08
 inotify09 inotify09
 inotify10 inotify10
 inotify11 inotify11
+inotify12 inotify12
 
 fanotify01 fanotify01
 fanotify02 fanotify02
diff --git a/testcases/kernel/syscalls/inotify/.gitignore b/testcases/kernel/syscalls/inotify/.gitignore
index 593cf6c04..f6e5c546a 100644
--- a/testcases/kernel/syscalls/inotify/.gitignore
+++ b/testcases/kernel/syscalls/inotify/.gitignore
@@ -9,3 +9,4 @@
 /inotify09
 /inotify10
 /inotify11
+/inotify12
diff --git a/testcases/kernel/syscalls/inotify/inotify12.c b/testcases/kernel/syscalls/inotify/inotify12.c
new file mode 100644
index 000000000..fe72771c5
--- /dev/null
+++ b/testcases/kernel/syscalls/inotify/inotify12.c
@@ -0,0 +1,168 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2022 CTERA Networks. All Rights Reserved.
+ *
+ * Author: Amir Goldstein <amir73il@gmail.com>
+ */
+
+/*\
+ * [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
-- 
2.25.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test
  2022-06-13 14:38 [LTP] [PATCH 0/5] Fanotify tests for FAN_MARK_EVICTABLE Amir Goldstein
  2022-06-13 14:38 ` [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags Amir Goldstein
@ 2022-06-13 14:38 ` Amir Goldstein
  2022-06-14 10:19   ` Jan Kara
  2022-06-16  8:36   ` Petr Vorel
  2022-06-13 14:38 ` [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path Amir Goldstein
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 35+ messages in thread
From: Amir Goldstein @ 2022-06-13 14:38 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Matthew Bobrowski, Jan Kara, ltp

Verify 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.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 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

diff --git a/runtest/syscalls b/runtest/syscalls
index 1259e41f1..e9ee6e5ba 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -612,6 +612,7 @@ fanotify19 fanotify19
 fanotify20 fanotify20
 fanotify21 fanotify21
 fanotify22 fanotify22
+fanotify23 fanotify23
 
 ioperm01 ioperm01
 ioperm02 ioperm02
diff --git a/testcases/kernel/syscalls/fanotify/.gitignore b/testcases/kernel/syscalls/fanotify/.gitignore
index 6d4ab4ca3..a0a7d20d3 100644
--- a/testcases/kernel/syscalls/fanotify/.gitignore
+++ b/testcases/kernel/syscalls/fanotify/.gitignore
@@ -20,4 +20,5 @@
 /fanotify20
 /fanotify21
 /fanotify22
+/fanotify23
 /fanotify_child
diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
index eb690e332..0ad7ef21b 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify.h
+++ b/testcases/kernel/syscalls/fanotify/fanotify.h
@@ -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
diff --git a/testcases/kernel/syscalls/fanotify/fanotify23.c b/testcases/kernel/syscalls/fanotify/fanotify23.c
new file mode 100644
index 000000000..64787d627
--- /dev/null
+++ b/testcases/kernel/syscalls/fanotify/fanotify23.c
@@ -0,0 +1,258 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2022 CTERA Networks.  All Rights Reserved.
+ *
+ * Author: Amir Goldstein <amir73il@gmail.com>
+ */
+
+/*\
+ * [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
-- 
2.25.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path
  2022-06-13 14:38 [LTP] [PATCH 0/5] Fanotify tests for FAN_MARK_EVICTABLE Amir Goldstein
  2022-06-13 14:38 ` [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags Amir Goldstein
  2022-06-13 14:38 ` [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test Amir Goldstein
@ 2022-06-13 14:38 ` Amir Goldstein
  2022-06-14 10:26   ` Jan Kara
  2022-06-13 14:38 ` [LTP] [PATCH 4/5] syscalls/fanotify10: Mount cycle between test cases Amir Goldstein
  2022-06-13 14:38 ` [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark Amir Goldstein
  4 siblings, 1 reply; 35+ messages in thread
From: Amir Goldstein @ 2022-06-13 14:38 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Matthew Bobrowski, Jan Kara, ltp

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 <amir73il@gmail.com>
---
 .../kernel/syscalls/fanotify/fanotify10.c     | 28 +++++++++++--------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
index 067dd65ae..efef25135 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify10.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
@@ -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");
 
-- 
2.25.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH 4/5] syscalls/fanotify10: Mount cycle between test cases
  2022-06-13 14:38 [LTP] [PATCH 0/5] Fanotify tests for FAN_MARK_EVICTABLE Amir Goldstein
                   ` (2 preceding siblings ...)
  2022-06-13 14:38 ` [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path Amir Goldstein
@ 2022-06-13 14:38 ` Amir Goldstein
  2022-06-14 10:47   ` Jan Kara
  2022-06-13 14:38 ` [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark Amir Goldstein
  4 siblings, 1 reply; 35+ messages in thread
From: Amir Goldstein @ 2022-06-13 14:38 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Matthew Bobrowski, Jan Kara, ltp

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 <amir73il@gmail.com>
---
 .../kernel/syscalls/fanotify/fanotify10.c     | 25 +++++++++++++------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
index efef25135..b9a50672d 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify10.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
@@ -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[] = {
-- 
2.25.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
  2022-06-13 14:38 [LTP] [PATCH 0/5] Fanotify tests for FAN_MARK_EVICTABLE Amir Goldstein
                   ` (3 preceding siblings ...)
  2022-06-13 14:38 ` [LTP] [PATCH 4/5] syscalls/fanotify10: Mount cycle between test cases Amir Goldstein
@ 2022-06-13 14:38 ` Amir Goldstein
  2022-06-14 13:04   ` Jan Kara
  2022-06-30  6:27   ` Jan Stancek
  4 siblings, 2 replies; 35+ messages in thread
From: Amir Goldstein @ 2022-06-13 14:38 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Matthew Bobrowski, Jan Kara, ltp

Test multiple groups with evictable mark with ignore mask

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 .../kernel/syscalls/fanotify/fanotify10.c     | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
index b9a50672d..52277d0b7 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify10.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
@@ -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[] = {
-- 
2.25.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
  2022-06-13 14:38 ` [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags Amir Goldstein
@ 2022-06-13 14:58   ` Amir Goldstein
  2022-06-13 15:23     ` Petr Vorel
  2022-06-13 15:48   ` Petr Vorel
  2022-06-14 10:19   ` Jan Kara
  2 siblings, 1 reply; 35+ messages in thread
From: Amir Goldstein @ 2022-06-13 14:58 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Matthew Bobrowski, Jan Kara, LTP List

On Mon, Jun 13, 2022 at 5:38 PM Amir Goldstein <amir73il@gmail.com> wrote:
>
> Test behavior of IN_ONESHOT and IN_EXCL_UNLINK.
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>  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
>
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 3b26d19e6..1259e41f1 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -588,6 +588,7 @@ inotify08 inotify08
>  inotify09 inotify09
>  inotify10 inotify10
>  inotify11 inotify11
> +inotify12 inotify12
>
>  fanotify01 fanotify01
>  fanotify02 fanotify02
> diff --git a/testcases/kernel/syscalls/inotify/.gitignore b/testcases/kernel/syscalls/inotify/.gitignore
> index 593cf6c04..f6e5c546a 100644
> --- a/testcases/kernel/syscalls/inotify/.gitignore
> +++ b/testcases/kernel/syscalls/inotify/.gitignore
> @@ -9,3 +9,4 @@
>  /inotify09
>  /inotify10
>  /inotify11
> +/inotify12
> diff --git a/testcases/kernel/syscalls/inotify/inotify12.c b/testcases/kernel/syscalls/inotify/inotify12.c
> new file mode 100644
> index 000000000..fe72771c5
> --- /dev/null
> +++ b/testcases/kernel/syscalls/inotify/inotify12.c
> @@ -0,0 +1,168 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2022 CTERA Networks. All Rights Reserved.
> + *
> + * Author: Amir Goldstein <amir73il@gmail.com>
> + */
> +
> +/*\
> + * [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,

OOPS should be changed to .max_runtime = 10

> +       .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.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
  2022-06-13 14:58   ` Amir Goldstein
@ 2022-06-13 15:23     ` Petr Vorel
  2022-06-13 16:03       ` Amir Goldstein
  0 siblings, 1 reply; 35+ messages in thread
From: Petr Vorel @ 2022-06-13 15:23 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Matthew Bobrowski, Jan Kara, LTP List, Richard Palethorpe

Hi Amir,

> > diff --git a/testcases/kernel/syscalls/inotify/inotify12.c b/testcases/kernel/syscalls/inotify/inotify12.c
...
> > +static struct tst_test test = {
> > +       .timeout = 10,

> OOPS should be changed to .max_runtime = 10

> > +       .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.

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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
  2022-06-13 14:38 ` [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags Amir Goldstein
  2022-06-13 14:58   ` Amir Goldstein
@ 2022-06-13 15:48   ` Petr Vorel
  2022-06-14 10:19   ` Jan Kara
  2 siblings, 0 replies; 35+ messages in thread
From: Petr Vorel @ 2022-06-13 15:48 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Matthew Bobrowski, Jan Kara, ltp

Hi Amir,

...
> +/*\
> + * [Description]
> + * Test special inotify mask flags.
> + *
> + * Regression test for kernel commit a32e697cda27:
> + *
> + *     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.

...
> +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;
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!
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
  2022-06-13 15:23     ` Petr Vorel
@ 2022-06-13 16:03       ` Amir Goldstein
  2022-06-13 16:05         ` Petr Vorel
  0 siblings, 1 reply; 35+ messages in thread
From: Amir Goldstein @ 2022-06-13 16:03 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Matthew Bobrowski, Jan Kara, LTP List, Richard Palethorpe

On Mon, Jun 13, 2022 at 6:23 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Amir,
>
> > > diff --git a/testcases/kernel/syscalls/inotify/inotify12.c b/testcases/kernel/syscalls/inotify/inotify12.c
> ...
> > > +static struct tst_test test = {
> > > +       .timeout = 10,
>
> > OOPS should be changed to .max_runtime = 10
>
> > > +       .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.
>
> 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.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
  2022-06-13 16:03       ` Amir Goldstein
@ 2022-06-13 16:05         ` Petr Vorel
  0 siblings, 0 replies; 35+ messages in thread
From: Petr Vorel @ 2022-06-13 16:05 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Matthew Bobrowski, Jan Kara, LTP List, Richard Palethorpe

> On Mon, Jun 13, 2022 at 6:23 PM Petr Vorel <pvorel@suse.cz> wrote:

> > Hi Amir,

> > > > diff --git a/testcases/kernel/syscalls/inotify/inotify12.c b/testcases/kernel/syscalls/inotify/inotify12.c
> > ...
> > > > +static struct tst_test test = {
> > > > +       .timeout = 10,

> > > OOPS should be changed to .max_runtime = 10

> > > > +       .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.

> > 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

> Thanks,
> Amir.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
  2022-06-13 14:38 ` [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags Amir Goldstein
  2022-06-13 14:58   ` Amir Goldstein
  2022-06-13 15:48   ` Petr Vorel
@ 2022-06-14 10:19   ` Jan Kara
  2022-06-14 11:28     ` Petr Vorel
  2 siblings, 1 reply; 35+ messages in thread
From: Jan Kara @ 2022-06-14 10:19 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Jan Kara, ltp, Matthew Bobrowski

On Mon 13-06-22 17:38:22, Amir Goldstein wrote:
> Test behavior of IN_ONESHOT and IN_EXCL_UNLINK.
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>

Looks good to me after fixing those small bugs you've found. Feel free to
add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  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
> 
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 3b26d19e6..1259e41f1 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -588,6 +588,7 @@ inotify08 inotify08
>  inotify09 inotify09
>  inotify10 inotify10
>  inotify11 inotify11
> +inotify12 inotify12
>  
>  fanotify01 fanotify01
>  fanotify02 fanotify02
> diff --git a/testcases/kernel/syscalls/inotify/.gitignore b/testcases/kernel/syscalls/inotify/.gitignore
> index 593cf6c04..f6e5c546a 100644
> --- a/testcases/kernel/syscalls/inotify/.gitignore
> +++ b/testcases/kernel/syscalls/inotify/.gitignore
> @@ -9,3 +9,4 @@
>  /inotify09
>  /inotify10
>  /inotify11
> +/inotify12
> diff --git a/testcases/kernel/syscalls/inotify/inotify12.c b/testcases/kernel/syscalls/inotify/inotify12.c
> new file mode 100644
> index 000000000..fe72771c5
> --- /dev/null
> +++ b/testcases/kernel/syscalls/inotify/inotify12.c
> @@ -0,0 +1,168 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2022 CTERA Networks. All Rights Reserved.
> + *
> + * Author: Amir Goldstein <amir73il@gmail.com>
> + */
> +
> +/*\
> + * [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
> -- 
> 2.25.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test
  2022-06-13 14:38 ` [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test Amir Goldstein
@ 2022-06-14 10:19   ` Jan Kara
  2022-06-16  8:36   ` Petr Vorel
  1 sibling, 0 replies; 35+ messages in thread
From: Jan Kara @ 2022-06-14 10:19 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Jan Kara, ltp, Matthew Bobrowski

On Mon 13-06-22 17:38:23, Amir Goldstein wrote:
> Verify 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.
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  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
> 
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 1259e41f1..e9ee6e5ba 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -612,6 +612,7 @@ fanotify19 fanotify19
>  fanotify20 fanotify20
>  fanotify21 fanotify21
>  fanotify22 fanotify22
> +fanotify23 fanotify23
>  
>  ioperm01 ioperm01
>  ioperm02 ioperm02
> diff --git a/testcases/kernel/syscalls/fanotify/.gitignore b/testcases/kernel/syscalls/fanotify/.gitignore
> index 6d4ab4ca3..a0a7d20d3 100644
> --- a/testcases/kernel/syscalls/fanotify/.gitignore
> +++ b/testcases/kernel/syscalls/fanotify/.gitignore
> @@ -20,4 +20,5 @@
>  /fanotify20
>  /fanotify21
>  /fanotify22
> +/fanotify23
>  /fanotify_child
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
> index eb690e332..0ad7ef21b 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify.h
> +++ b/testcases/kernel/syscalls/fanotify/fanotify.h
> @@ -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
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify23.c b/testcases/kernel/syscalls/fanotify/fanotify23.c
> new file mode 100644
> index 000000000..64787d627
> --- /dev/null
> +++ b/testcases/kernel/syscalls/fanotify/fanotify23.c
> @@ -0,0 +1,258 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2022 CTERA Networks.  All Rights Reserved.
> + *
> + * Author: Amir Goldstein <amir73il@gmail.com>
> + */
> +
> +/*\
> + * [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
> -- 
> 2.25.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path
  2022-06-13 14:38 ` [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path Amir Goldstein
@ 2022-06-14 10:26   ` Jan Kara
  2022-06-14 11:10     ` Amir Goldstein
  0 siblings, 1 reply; 35+ messages in thread
From: Jan Kara @ 2022-06-14 10:26 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Jan Kara, ltp, Matthew Bobrowski

On Mon 13-06-22 17:38:24, Amir Goldstein wrote:
> 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 <amir73il@gmail.com>

One question below...

> diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> index 067dd65ae..efef25135 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> @@ -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,

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

>  		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");
>  
> -- 
> 2.25.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 4/5] syscalls/fanotify10: Mount cycle between test cases
  2022-06-13 14:38 ` [LTP] [PATCH 4/5] syscalls/fanotify10: Mount cycle between test cases Amir Goldstein
@ 2022-06-14 10:47   ` Jan Kara
  0 siblings, 0 replies; 35+ messages in thread
From: Jan Kara @ 2022-06-14 10:47 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Jan Kara, ltp, Matthew Bobrowski

On Mon 13-06-22 17:38:25, Amir Goldstein wrote:
> 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 <amir73il@gmail.com>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  .../kernel/syscalls/fanotify/fanotify10.c     | 25 +++++++++++++------
>  1 file changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> index efef25135..b9a50672d 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> @@ -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[] = {
> -- 
> 2.25.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path
  2022-06-14 10:26   ` Jan Kara
@ 2022-06-14 11:10     ` Amir Goldstein
  2022-06-16 13:31       ` Petr Vorel
  0 siblings, 1 reply; 35+ messages in thread
From: Amir Goldstein @ 2022-06-14 11:10 UTC (permalink / raw)
  To: Jan Kara; +Cc: LTP List, Matthew Bobrowski

On Tue, Jun 14, 2022 at 1:26 PM Jan Kara <jack@suse.cz> wrote:
>
> On Mon 13-06-22 17:38:24, Amir Goldstein wrote:
> > 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 <amir73il@gmail.com>
>
> One question below...
>
> > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > index 067dd65ae..efef25135 100644
> > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > @@ -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
> >       },
>
> 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.
>

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.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags
  2022-06-14 10:19   ` Jan Kara
@ 2022-06-14 11:28     ` Petr Vorel
  0 siblings, 0 replies; 35+ messages in thread
From: Petr Vorel @ 2022-06-14 11:28 UTC (permalink / raw)
  To: Jan Kara; +Cc: Matthew Bobrowski, ltp

Hi all,

> Looks good to me after fixing those small bugs you've found. Feel free to
> add:

> Reviewed-by: Jan Kara <jack@suse.cz>

> 								Honza

Jan, thanks for your review!
Patch merged.

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
  2022-06-13 14:38 ` [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark Amir Goldstein
@ 2022-06-14 13:04   ` Jan Kara
  2022-06-30  6:27   ` Jan Stancek
  1 sibling, 0 replies; 35+ messages in thread
From: Jan Kara @ 2022-06-14 13:04 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Jan Kara, ltp, Matthew Bobrowski

On Mon 13-06-22 17:38:26, Amir Goldstein wrote:
> Test multiple groups with evictable mark with ignore mask
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  .../kernel/syscalls/fanotify/fanotify10.c     | 78 +++++++++++++++++++
>  1 file changed, 78 insertions(+)
> 
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> index b9a50672d..52277d0b7 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> @@ -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[] = {
> -- 
> 2.25.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test
  2022-06-13 14:38 ` [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test Amir Goldstein
  2022-06-14 10:19   ` Jan Kara
@ 2022-06-16  8:36   ` Petr Vorel
  2022-06-16  8:50     ` Amir Goldstein
  1 sibling, 1 reply; 35+ messages in thread
From: Petr Vorel @ 2022-06-16  8:36 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Matthew Bobrowski, Jan Kara, ltp

Hi Amir, Jan, all,

> Verify 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.

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")


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test
  2022-06-16  8:36   ` Petr Vorel
@ 2022-06-16  8:50     ` Amir Goldstein
  2022-06-16 13:28       ` Petr Vorel
  0 siblings, 1 reply; 35+ messages in thread
From: Amir Goldstein @ 2022-06-16  8:50 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Matthew Bobrowski, Jan Kara, LTP List

On Thu, Jun 16, 2022 at 11:36 AM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Amir, Jan, all,
>
> > Verify 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.
>
> 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 :)

>
> 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 flag
FAN_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.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test
  2022-06-16  8:50     ` Amir Goldstein
@ 2022-06-16 13:28       ` Petr Vorel
  0 siblings, 0 replies; 35+ messages in thread
From: Petr Vorel @ 2022-06-16 13:28 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Matthew Bobrowski, Jan Kara, LTP List

Hi all,

> On Thu, Jun 16, 2022 at 11:36 AM Petr Vorel <pvorel@suse.cz> wrote:

> > Hi Amir, Jan, all,

> > > Verify 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.

> > 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.


> > 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 flag
> FAN_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?)

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.

> 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.
Sure.

Kind regards,
Petr

> Thanks,
> Amir.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path
  2022-06-14 11:10     ` Amir Goldstein
@ 2022-06-16 13:31       ` Petr Vorel
  2022-06-16 13:46         ` Amir Goldstein
  0 siblings, 1 reply; 35+ messages in thread
From: Petr Vorel @ 2022-06-16 13:31 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Matthew Bobrowski, Jan Kara, LTP List

> On Tue, Jun 14, 2022 at 1:26 PM Jan Kara <jack@suse.cz> wrote:

> > On Mon 13-06-22 17:38:24, Amir Goldstein wrote:
> > > 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 <amir73il@gmail.com>

> > One question below...

> > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > index 067dd65ae..efef25135 100644
> > > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > @@ -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
> > >       },

> > 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.


> 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?

Both ways work for me. Could you please rebase your LTP fork, do either of these
changes and ping me to pull?

Thx!

Petr

> Thanks,
> Amir.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path
  2022-06-16 13:31       ` Petr Vorel
@ 2022-06-16 13:46         ` Amir Goldstein
  2022-06-16 16:57           ` Petr Vorel
  0 siblings, 1 reply; 35+ messages in thread
From: Amir Goldstein @ 2022-06-16 13:46 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Matthew Bobrowski, Jan Kara, LTP List

On Thu, Jun 16, 2022 at 4:31 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> > On Tue, Jun 14, 2022 at 1:26 PM Jan Kara <jack@suse.cz> wrote:
>
> > > On Mon 13-06-22 17:38:24, Amir Goldstein wrote:
> > > > 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 <amir73il@gmail.com>
>
> > > One question below...
>
> > > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > index 067dd65ae..efef25135 100644
> > > > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > @@ -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
> > > >       },
>
> > > 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.
>
>
> > 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?
>
> 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.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path
  2022-06-16 13:46         ` Amir Goldstein
@ 2022-06-16 16:57           ` Petr Vorel
  0 siblings, 0 replies; 35+ messages in thread
From: Petr Vorel @ 2022-06-16 16:57 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Matthew Bobrowski, Jan Kara, LTP List

Hi Amir,

...
> > 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 a lot, merged!

Kind regards,
Petr

> Thanks,
> Amir.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
  2022-06-13 14:38 ` [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark Amir Goldstein
  2022-06-14 13:04   ` Jan Kara
@ 2022-06-30  6:27   ` Jan Stancek
  2022-06-30  8:20     ` Amir Goldstein
  1 sibling, 1 reply; 35+ messages in thread
From: Jan Stancek @ 2022-06-30  6:27 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Jan Kara, LTP List, Matthew Bobrowski

On Mon, Jun 13, 2022 at 4:39 PM Amir Goldstein <amir73il@gmail.com> wrote:
>
> Test multiple groups with evictable mark with ignore mask
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>  .../kernel/syscalls/fanotify/fanotify10.c     | 78 +++++++++++++++++++
>  1 file changed, 78 insertions(+)
>
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> index b9a50672d..52277d0b7 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> @@ -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
> +       },

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
  2022-06-30  6:27   ` Jan Stancek
@ 2022-06-30  8:20     ` Amir Goldstein
  2022-07-07 12:49       ` Jan Stancek
  0 siblings, 1 reply; 35+ messages in thread
From: Amir Goldstein @ 2022-06-30  8:20 UTC (permalink / raw)
  To: Jan Stancek; +Cc: Jan Kara, LTP List, Matthew Bobrowski

On Thu, Jun 30, 2022 at 9:27 AM Jan Stancek <jstancek@redhat.com> wrote:
>
> On Mon, Jun 13, 2022 at 4:39 PM Amir Goldstein <amir73il@gmail.com> wrote:
> >
> > Test multiple groups with evictable mark with ignore mask
> >
> > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > ---
> >  .../kernel/syscalls/fanotify/fanotify10.c     | 78 +++++++++++++++++++
> >  1 file changed, 78 insertions(+)
> >
> > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > index b9a50672d..52277d0b7 100644
> > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > @@ -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
> > +       },
>
> 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)

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.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
  2022-06-30  8:20     ` Amir Goldstein
@ 2022-07-07 12:49       ` Jan Stancek
  2022-07-09 10:09         ` Amir Goldstein
  0 siblings, 1 reply; 35+ messages in thread
From: Jan Stancek @ 2022-07-07 12:49 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Jan Kara, LTP List, Matthew Bobrowski

On Thu, Jun 30, 2022 at 10:21 AM Amir Goldstein <amir73il@gmail.com> wrote:
>
> On Thu, Jun 30, 2022 at 9:27 AM Jan Stancek <jstancek@redhat.com> wrote:
> >
> > On Mon, Jun 13, 2022 at 4:39 PM Amir Goldstein <amir73il@gmail.com> wrote:
> > >
> > > Test multiple groups with evictable mark with ignore mask
> > >
> > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > > ---
> > >  .../kernel/syscalls/fanotify/fanotify10.c     | 78 +++++++++++++++++++
> > >  1 file changed, 78 insertions(+)
> > >
> > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > index b9a50672d..52277d0b7 100644
> > > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > @@ -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
> > > +       },
> >
> > 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)
>
> 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.

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
  2022-07-07 12:49       ` Jan Stancek
@ 2022-07-09 10:09         ` Amir Goldstein
  2022-07-12  8:19           ` Jan Stancek
  0 siblings, 1 reply; 35+ messages in thread
From: Amir Goldstein @ 2022-07-09 10:09 UTC (permalink / raw)
  To: Jan Stancek; +Cc: Jan Kara, LTP List, Matthew Bobrowski

On Thu, Jul 7, 2022 at 3:49 PM Jan Stancek <jstancek@redhat.com> wrote:
>
> On Thu, Jun 30, 2022 at 10:21 AM Amir Goldstein <amir73il@gmail.com> wrote:
> >
> > On Thu, Jun 30, 2022 at 9:27 AM Jan Stancek <jstancek@redhat.com> wrote:
> > >
> > > On Mon, Jun 13, 2022 at 4:39 PM Amir Goldstein <amir73il@gmail.com> wrote:
> > > >
> > > > Test multiple groups with evictable mark with ignore mask
> > > >
> > > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > > > ---
> > > >  .../kernel/syscalls/fanotify/fanotify10.c     | 78 +++++++++++++++++++
> > > >  1 file changed, 78 insertions(+)
> > > >
> > > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > index b9a50672d..52277d0b7 100644
> > > > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > @@ -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
> > > > +       },
> > >
> > > 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?

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.

> > >
> > > 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.
>
> 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.

> 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 from
create_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.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
  2022-07-09 10:09         ` Amir Goldstein
@ 2022-07-12  8:19           ` Jan Stancek
  2022-08-24 15:24             ` Jan Kara
  0 siblings, 1 reply; 35+ messages in thread
From: Jan Stancek @ 2022-07-12  8:19 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Jan Kara, LTP List, Matthew Bobrowski

On Sat, Jul 9, 2022 at 12:09 PM Amir Goldstein <amir73il@gmail.com> wrote:
>
> On Thu, Jul 7, 2022 at 3:49 PM Jan Stancek <jstancek@redhat.com> wrote:
> >
> > On Thu, Jun 30, 2022 at 10:21 AM Amir Goldstein <amir73il@gmail.com> wrote:
> > >
> > > On Thu, Jun 30, 2022 at 9:27 AM Jan Stancek <jstancek@redhat.com> wrote:
> > > >
> > > > On Mon, Jun 13, 2022 at 4:39 PM Amir Goldstein <amir73il@gmail.com> wrote:
> > > > >
> > > > > Test multiple groups with evictable mark with ignore mask
> > > > >
> > > > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > > > > ---
> > > > >  .../kernel/syscalls/fanotify/fanotify10.c     | 78 +++++++++++++++++++
> > > > >  1 file changed, 78 insertions(+)
> > > > >
> > > > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > index b9a50672d..52277d0b7 100644
> > > > > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > @@ -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
> > > > > +       },
> > > >
> > > > 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?
>
> 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.
>
> > > >
> > > > 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.
> >
> > 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.
>
> > 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?

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.

>
> 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 from
> create_fanotify_groups() => show_fanotify_marks() and skip the test case
> instead of failing it.

Thanks for suggestion.

>
> 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.
>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
  2022-07-12  8:19           ` Jan Stancek
@ 2022-08-24 15:24             ` Jan Kara
  2022-08-24 18:13               ` Amir Goldstein
  2022-08-25 12:53               ` Jan Stancek
  0 siblings, 2 replies; 35+ messages in thread
From: Jan Kara @ 2022-08-24 15:24 UTC (permalink / raw)
  To: Jan Stancek; +Cc: Jan Kara, LTP List, Matthew Bobrowski

[-- Attachment #1: Type: text/plain, Size: 7596 bytes --]

On Tue 12-07-22 10:19:19, Jan Stancek wrote:
> On Sat, Jul 9, 2022 at 12:09 PM Amir Goldstein <amir73il@gmail.com> wrote:
> >
> > On Thu, Jul 7, 2022 at 3:49 PM Jan Stancek <jstancek@redhat.com> wrote:
> > >
> > > On Thu, Jun 30, 2022 at 10:21 AM Amir Goldstein <amir73il@gmail.com> wrote:
> > > >
> > > > On Thu, Jun 30, 2022 at 9:27 AM Jan Stancek <jstancek@redhat.com> wrote:
> > > > >
> > > > > On Mon, Jun 13, 2022 at 4:39 PM Amir Goldstein <amir73il@gmail.com> wrote:
> > > > > >
> > > > > > Test multiple groups with evictable mark with ignore mask
> > > > > >
> > > > > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > > > > > ---
> > > > > >  .../kernel/syscalls/fanotify/fanotify10.c     | 78 +++++++++++++++++++
> > > > > >  1 file changed, 78 insertions(+)
> > > > > >
> > > > > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > > index b9a50672d..52277d0b7 100644
> > > > > > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > > @@ -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
> > > > > > +       },
> > > > >
> > > > > 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?
> >
> > 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.
> >
> > > > >
> > > > > 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.
> > >
> > > 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.
> >
> > > 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?
> 
> 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.
> 
> >
> > 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 from
> > create_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
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

[-- Attachment #2: 0001-syscalls-fanotify10-Make-evictable-marks-test-more-r.patch --]
[-- Type: text/x-patch, Size: 1591 bytes --]

From 988e3eb2ac0cdffa447c9ffc71256f460ae01a94 Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
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.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 testcases/kernel/syscalls/fanotify/fanotify10.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
index 19e43d2c2762..54636ce2ddd4 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify10.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
@@ -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)
-- 
2.35.3


[-- Attachment #3: Type: text/plain, Size: 60 bytes --]


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
  2022-08-24 15:24             ` Jan Kara
@ 2022-08-24 18:13               ` Amir Goldstein
  2022-08-25  9:33                 ` Jan Kara
  2022-08-25 12:53               ` Jan Stancek
  1 sibling, 1 reply; 35+ messages in thread
From: Amir Goldstein @ 2022-08-24 18:13 UTC (permalink / raw)
  To: Jan Kara; +Cc: LTP List, Matthew Bobrowski

On Wed, Aug 24, 2022 at 6:24 PM Jan Kara <jack@suse.cz> wrote:
>
> On Tue 12-07-22 10:19:19, Jan Stancek wrote:
> > On Sat, Jul 9, 2022 at 12:09 PM Amir Goldstein <amir73il@gmail.com> wrote:
> > >
> > > On Thu, Jul 7, 2022 at 3:49 PM Jan Stancek <jstancek@redhat.com> wrote:
> > > >
> > > > On Thu, Jun 30, 2022 at 10:21 AM Amir Goldstein <amir73il@gmail.com> wrote:
> > > > >
> > > > > On Thu, Jun 30, 2022 at 9:27 AM Jan Stancek <jstancek@redhat.com> wrote:
> > > > > >
> > > > > > On Mon, Jun 13, 2022 at 4:39 PM Amir Goldstein <amir73il@gmail.com> wrote:
> > > > > > >
> > > > > > > Test multiple groups with evictable mark with ignore mask
> > > > > > >
> > > > > > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > > > > > > ---
> > > > > > >  .../kernel/syscalls/fanotify/fanotify10.c     | 78 +++++++++++++++++++
> > > > > > >  1 file changed, 78 insertions(+)
> > > > > > >
> > > > > > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > > > index b9a50672d..52277d0b7 100644
> > > > > > > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > > > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > > > @@ -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
> > > > > > > +       },
> > > > > >
> > > > > > 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?
> > >
> > > 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.
> > >
> > > > > >
> > > > > > 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.
> > > >
> > > > 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.
> > >
> > > > 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?
> >
> > 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.
> >
> > >
> > > 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 from
> > > create_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?
>

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.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
  2022-08-24 18:13               ` Amir Goldstein
@ 2022-08-25  9:33                 ` Jan Kara
  0 siblings, 0 replies; 35+ messages in thread
From: Jan Kara @ 2022-08-25  9:33 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Jan Kara, LTP List, Matthew Bobrowski

On Wed 24-08-22 21:13:59, Amir Goldstein wrote:
> On Wed, Aug 24, 2022 at 6:24 PM Jan Kara <jack@suse.cz> wrote:
> >
> > On Tue 12-07-22 10:19:19, Jan Stancek wrote:
> > > On Sat, Jul 9, 2022 at 12:09 PM Amir Goldstein <amir73il@gmail.com> wrote:
> > > >
> > > > On Thu, Jul 7, 2022 at 3:49 PM Jan Stancek <jstancek@redhat.com> wrote:
> > > > >
> > > > > On Thu, Jun 30, 2022 at 10:21 AM Amir Goldstein <amir73il@gmail.com> wrote:
> > > > > >
> > > > > > On Thu, Jun 30, 2022 at 9:27 AM Jan Stancek <jstancek@redhat.com> wrote:
> > > > > > >
> > > > > > > On Mon, Jun 13, 2022 at 4:39 PM Amir Goldstein <amir73il@gmail.com> wrote:
> > > > > > > >
> > > > > > > > Test multiple groups with evictable mark with ignore mask
> > > > > > > >
> > > > > > > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > > > > > > > ---
> > > > > > > >  .../kernel/syscalls/fanotify/fanotify10.c     | 78 +++++++++++++++++++
> > > > > > > >  1 file changed, 78 insertions(+)
> > > > > > > >
> > > > > > > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > > > > index b9a50672d..52277d0b7 100644
> > > > > > > > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > > > > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > > > > @@ -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
> > > > > > > > +       },
> > > > > > >
> > > > > > > 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?
> > > >
> > > > 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.
> > > >
> > > > > > >
> > > > > > > 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.
> > > > >
> > > > > 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.
> > > >
> > > > > 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?
> > >
> > > 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.
> > >
> > > >
> > > > 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 from
> > > > create_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?
> >
> 
> 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.

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
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
  2022-08-24 15:24             ` Jan Kara
  2022-08-24 18:13               ` Amir Goldstein
@ 2022-08-25 12:53               ` Jan Stancek
  2022-08-25 13:47                 ` Amir Goldstein
  1 sibling, 1 reply; 35+ messages in thread
From: Jan Stancek @ 2022-08-25 12:53 UTC (permalink / raw)
  To: Jan Kara; +Cc: LTP List, Matthew Bobrowski

On Wed, Aug 24, 2022 at 5:24 PM Jan Kara <jack@suse.cz> wrote:
>
> On Tue 12-07-22 10:19:19, Jan Stancek wrote:
> > On Sat, Jul 9, 2022 at 12:09 PM Amir Goldstein <amir73il@gmail.com> wrote:
> > >
> > > On Thu, Jul 7, 2022 at 3:49 PM Jan Stancek <jstancek@redhat.com> wrote:
> > > >
> > > > On Thu, Jun 30, 2022 at 10:21 AM Amir Goldstein <amir73il@gmail.com> wrote:
> > > > >
> > > > > On Thu, Jun 30, 2022 at 9:27 AM Jan Stancek <jstancek@redhat.com> wrote:
> > > > > >
> > > > > > On Mon, Jun 13, 2022 at 4:39 PM Amir Goldstein <amir73il@gmail.com> wrote:
> > > > > > >
> > > > > > > Test multiple groups with evictable mark with ignore mask
> > > > > > >
> > > > > > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> > > > > > > ---
> > > > > > >  .../kernel/syscalls/fanotify/fanotify10.c     | 78 +++++++++++++++++++
> > > > > > >  1 file changed, 78 insertions(+)
> > > > > > >
> > > > > > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > > > index b9a50672d..52277d0b7 100644
> > > > > > > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > > > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > > > > @@ -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
> > > > > > > +       },
> > > > > >
> > > > > > 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?
> > >
> > > 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.
> > >
> > > > > >
> > > > > > 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.
> > > >
> > > > 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.
> > >
> > > > 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?
> >
> > 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.
> >
> > >
> > > 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 from
> > > create_fanotify_groups() => show_fanotify_marks() and skip the test case
> > > instead of failing it.
> >
> > 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

5.20.0-0.rc0.aea23e7c464b
https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/08/14/redhat:613063904/build_x86_64_redhat:613063904_x86_64_debug/tests/2/results_0001/job.01/recipes/12440847/tasks/9/logs/syscalls.fail.log

> 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

>
>                                                                 Honza
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
  2022-08-25 12:53               ` Jan Stancek
@ 2022-08-25 13:47                 ` Amir Goldstein
  2022-08-25 14:03                   ` Jan Kara
  0 siblings, 1 reply; 35+ messages in thread
From: Amir Goldstein @ 2022-08-25 13:47 UTC (permalink / raw)
  To: Jan Stancek; +Cc: Jan Kara, LTP List, Matthew Bobrowski

> > 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
>
> 5.20.0-0.rc0.aea23e7c464b
> https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/08/14/redhat:613063904/build_x86_64_redhat:613063904_x86_64_debug/tests/2/results_0001/job.01/recipes/12440847/tasks/9/logs/syscalls.fail.log
>
> > 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.

Acked-by: Amir Goldstein <amir73il@gmail.com>

Thanks,
Amir.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark
  2022-08-25 13:47                 ` Amir Goldstein
@ 2022-08-25 14:03                   ` Jan Kara
  0 siblings, 0 replies; 35+ messages in thread
From: Jan Kara @ 2022-08-25 14:03 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: Jan Kara, LTP List, Matthew Bobrowski

On Thu 25-08-22 16:47:53, Amir Goldstein wrote:
> > > 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
> >
> > 5.20.0-0.rc0.aea23e7c464b
> > https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/08/14/redhat:613063904/build_x86_64_redhat:613063904_x86_64_debug/tests/2/results_0001/job.01/recipes/12440847/tasks/9/logs/syscalls.fail.log
> >
> > > 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.
> 
> Acked-by: Amir Goldstein <amir73il@gmail.com>

Agreed. Done official submission.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2022-08-25 14:03 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 14:38 [LTP] [PATCH 0/5] Fanotify tests for FAN_MARK_EVICTABLE Amir Goldstein
2022-06-13 14:38 ` [LTP] [PATCH 1/5] syscalls/inotify12: Introduce test for inotify mask flags Amir Goldstein
2022-06-13 14:58   ` Amir Goldstein
2022-06-13 15:23     ` Petr Vorel
2022-06-13 16:03       ` Amir Goldstein
2022-06-13 16:05         ` Petr Vorel
2022-06-13 15:48   ` Petr Vorel
2022-06-14 10:19   ` Jan Kara
2022-06-14 11:28     ` Petr Vorel
2022-06-13 14:38 ` [LTP] [PATCH 2/5] syscalls/fanotify23: Introduce FAN_MARK_EVICTABLE test Amir Goldstein
2022-06-14 10:19   ` Jan Kara
2022-06-16  8:36   ` Petr Vorel
2022-06-16  8:50     ` Amir Goldstein
2022-06-16 13:28       ` Petr Vorel
2022-06-13 14:38 ` [LTP] [PATCH 3/5] syscalls/fanotify10: Watch directory that is not the mount path Amir Goldstein
2022-06-14 10:26   ` Jan Kara
2022-06-14 11:10     ` Amir Goldstein
2022-06-16 13:31       ` Petr Vorel
2022-06-16 13:46         ` Amir Goldstein
2022-06-16 16:57           ` Petr Vorel
2022-06-13 14:38 ` [LTP] [PATCH 4/5] syscalls/fanotify10: Mount cycle between test cases Amir Goldstein
2022-06-14 10:47   ` Jan Kara
2022-06-13 14:38 ` [LTP] [PATCH 5/5] syscalls/fanotify10: Add test cases for evictable ignore mark Amir Goldstein
2022-06-14 13:04   ` Jan Kara
2022-06-30  6:27   ` Jan Stancek
2022-06-30  8:20     ` Amir Goldstein
2022-07-07 12:49       ` Jan Stancek
2022-07-09 10:09         ` Amir Goldstein
2022-07-12  8:19           ` Jan Stancek
2022-08-24 15:24             ` Jan Kara
2022-08-24 18:13               ` Amir Goldstein
2022-08-25  9:33                 ` Jan Kara
2022-08-25 12:53               ` Jan Stancek
2022-08-25 13:47                 ` Amir Goldstein
2022-08-25 14:03                   ` Jan Kara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.