f2fs_io: measure the start time explicitly
PATCH 1/3 f2fs_io: measure the start time explicitly
Let's measure the start time more precisely.
--- tools/f2fs_io/f2fs_io.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/f2fs_io/f2fs_io.c +4 -1
@@ -1009,8 +1009,8 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd)printf ("fadvise SEQUENTIAL|WILLNEED to a file: %s\n" , argv[7 ]); } - io_time_start =get_current_us ();if (do_mmap) { + io_time_start =get_current_us (); data =mmap (NULL , count * buf_size,PROT_READ ,MAP_SHARED |MAP_POPULATE , fd, offset);if (data ==MAP_FAILED )
@@ -1028,6 +1028,8 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd) MAP_SHARED, fd, offset);if (data ==MAP_FAILED )die ("Mmap failed" ); + + io_time_start =get_current_us ();if (posix_fadvise (fd, offset, count * buf_size,POSIX_FADV_WILLNEED ) !=0 )die_errno ("fadvise failed" );
@@ -1040,6 +1042,7 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd) read_cnt = count * buf_size;memcpy (print_buf, data, print_bytes); }else { + io_time_start =get_current_us ();for (i =0 ; i < count; i++) {if (!do_dontcache) { ret =pread (fd, buf, buf_size, offset + buf_size * i);
Signature · 8 lines
2.52.0.107.ga0afd4fd5b-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 2/3 f2fs_io: add read test with mlock2 and madvise
Add a method to read out pages into unevictable mapping by mmap(), mlock2(), and madvise()
--- tools/f2fs_io/f2fs_io.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
tools/f2fs_io/f2fs_io.c +23 -1
@@ -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" \ +" madvise : mmap + mlock2 + madvise\n" \" mlock : mmap + mlock\n" \"advice can be\n" \" 1 : set sequential|willneed\n" \
@@ -956,6 +957,7 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd)int flags =0 ;int do_mmap =0 ;int do_mlock =0 ; +int do_madvise =0 ;int do_dontcache =0 ;int fd, advice;
@@ -979,6 +981,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], "madvise")) + do_madvise =1 ; else if (!strcmp(argv[4], "mlock")) do_mlock =1 ; else if (!strcmp(argv[4], "dontcache"))
@@ -1021,6 +1025,24 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd)if (mlock (data, count * buf_size))die_errno ("mlock failed" ); mlock_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); +if (data ==MAP_FAILED ) +die ("Mmap failed" ); + + mlock_time_start =get_current_us (); +if (mlock2 (data, count * buf_size,MLOCK_ONFAULT )) +die_errno ("mlock2 failed" ); + mlock_time_end =get_current_us (); + + io_time_start =get_current_us (); +if (madvise (data, count * buf_size,MADV_POPULATE_READ ) !=0 ) +die_errno ("madvise failed" ); + io_time_end =get_current_us (); + read_cnt = count * buf_size;memcpy (print_buf, data, print_bytes); }else if (do_mlock) {
@@ -1085,7 +1107,7 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd) }if (do_mmap) {munmap (data, count * buf_size); - }else if (do_mlock) { + }else if (do_mlock || do_madvise) {munlock (data, count * buf_size);munmap (data, count * buf_size); }
Signature · 8 lines
2.52.0.107.ga0afd4fd5b-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 2/3] f2fs_io: add read test with mlock2 and madvise
Quoted 4 lines · On 2025/12/2 04:46, Jaegeuk Kim via Linux-f2fs-devel wrote:
Add a method to read out pages into unevictable mapping by
mmap(),mlock2(), andmadvise()Signed-off-by Jaegeuk Kim <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 3/3 f2fs_io: rename mlock to fadvise
In reply to Jaegeuk Kim via Linux-f2fs-develfadvise is better to describe the read method.
--- tools/f2fs_io/f2fs_io.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/f2fs_io/f2fs_io.c +6 -6
@@ -939,7 +939,7 @@ static void do_write_advice(int argc, char **argv, const struct cmd_desc *cmd)" dio : direct IO\n" \" mmap : mmap IO\n" \" madvise : mmap + mlock2 + madvise\n" \ -" mlock : mmap + mlock\n" \ +" fadvise : mmap + fadvise + mlock\n" \"advice can be\n" \" 1 : set sequential|willneed\n" \" 0 : none\n" \
@@ -956,7 +956,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 ;int fd, advice;
@@ -983,8 +983,8 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd) do_mmap =1 ; else if (!strcmp(argv[4], "madvise")) do_madvise =1 ; - else if (!strcmp(argv[4], "mlock")) - do_mlock =1 ; + else if (!strcmp(argv[4], "fadvise")) + do_fadvise =1 ; else if (!strcmp(argv[4], "dontcache")) #ifdef HAVE_PREADV2 do_dontcache =1 ;
@@ -1045,7 +1045,7 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd) read_cnt = count * buf_size;memcpy (print_buf, data, print_bytes); - }else if (do_mlock) { + }else if (do_fadvise) { data =mmap (NULL , count * buf_size,PROT_READ ,MAP_SHARED , fd, offset);if (data ==MAP_FAILED )
@@ -1107,7 +1107,7 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd) }if (do_mmap) {munmap (data, count * buf_size); - }else if (do_mlock || do_madvise) { + }else if (do_fadvise || do_madvise) {munlock (data, count * buf_size);munmap (data, count * buf_size); }
Signature · 8 lines
2.52.0.107.ga0afd4fd5b-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 3/3] f2fs_io: rename mlock to fadvise
Quoted 3 lines · On 2025/12/2 04:46, Jaegeuk Kim via Linux-f2fs-devel wrote:
fadvise is better to describe the read method.
Signed-off-by Jaegeuk Kim <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 3 lines · On 2025/12/2 04:46, Jaegeuk Kim via Linux-f2fs-devel wrote:
Let's measure the start time more precisely.
Signed-off-by Jaegeuk Kim <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel