All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 1/2] f2fs_io: add mlock() option in the read test
@ 2025-12-12  0:55 Jaegeuk Kim via Linux-f2fs-devel
  2025-12-12  0:55 ` [f2fs-dev] [PATCH 2/2] f2fs_io: add more description in " Jaegeuk Kim via Linux-f2fs-devel
  2025-12-15  1:48 ` [f2fs-dev] [PATCH 1/2] f2fs_io: add mlock() option in the " Chao Yu via Linux-f2fs-devel
  0 siblings, 2 replies; 9+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2025-12-12  0:55 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 tools/f2fs_io/f2fs_io.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index 4429e0b0459c..08f3c9b79cdf 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -938,6 +938,7 @@ static void do_write_advice(int argc, char **argv, const struct cmd_desc *cmd)
 "  dontcache: buffered IO + dontcache\n"		\
 "  dio      : direct IO\n"				\
 "  mmap     : mmap IO\n"				\
+"  mlock    : mmap + mlock\n"				\
 "  madvise  : mmap + mlock2 + madvise\n"		\
 "  fadvise  : mmap + fadvise + mlock\n"			\
 "advice can be\n"					\
@@ -956,6 +957,7 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd)
 	u64 mlock_time_start = 0, mlock_time_end = 0;
 	int flags = 0;
 	int do_mmap = 0;
+	int do_mlock = 0;
 	int do_fadvise = 0;
 	int do_madvise = 0;
 	int do_dontcache = 0;
@@ -981,6 +983,8 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd)
 		flags |= O_DIRECT;
 	else if (!strcmp(argv[4], "mmap"))
 		do_mmap = 1;
+	else if (!strcmp(argv[4], "mlock"))
+		do_mlock = 1;
 	else if (!strcmp(argv[4], "madvise"))
 		do_madvise = 1;
 	else if (!strcmp(argv[4], "fadvise"))
@@ -1027,6 +1031,18 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd)
 		mlock_time_end = get_current_us();
 		read_cnt = count * buf_size;
 		memcpy(print_buf, data, print_bytes);
+	} else if (do_mlock) {
+		data = mmap(NULL, count * buf_size, PROT_READ,
+				MAP_SHARED, fd, offset);
+		if (data == MAP_FAILED)
+			die("Mmap failed");
+
+		io_time_start = get_current_us();
+		if (mlock(data, count * buf_size))
+			die_errno("mlock failed");
+		io_time_end = get_current_us();
+		read_cnt = count * buf_size;
+		memcpy(print_buf, data, print_bytes);
 	} else if (do_madvise) {
 		data = mmap(NULL, count * buf_size, PROT_READ,
 				MAP_SHARED, fd, offset);
-- 
2.52.0.305.g3fc767764a-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2025-12-19  3:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-12  0:55 [f2fs-dev] [PATCH 1/2] f2fs_io: add mlock() option in the read test Jaegeuk Kim via Linux-f2fs-devel
2025-12-12  0:55 ` [f2fs-dev] [PATCH 2/2] f2fs_io: add more description in " Jaegeuk Kim via Linux-f2fs-devel
2025-12-15  1:49   ` Chao Yu via Linux-f2fs-devel
2025-12-15  1:48 ` [f2fs-dev] [PATCH 1/2] f2fs_io: add mlock() option in the " Chao Yu via Linux-f2fs-devel
2025-12-16  0:50   ` Jaegeuk Kim via Linux-f2fs-devel
2025-12-16  6:33     ` Chao Yu via Linux-f2fs-devel
2025-12-16 19:12       ` Jaegeuk Kim via Linux-f2fs-devel
2025-12-17  0:42   ` [f2fs-dev] [PATCH 1/2 v2] " Jaegeuk Kim via Linux-f2fs-devel
2025-12-19  3:05     ` Chao Yu via Linux-f2fs-devel

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.