* [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
* [f2fs-dev] [PATCH 2/2] f2fs_io: add more description in read test
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 ` 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
1 sibling, 1 reply; 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 | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index 08f3c9b79cdf..390c9df26aff 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -937,10 +937,10 @@ static void do_write_advice(int argc, char **argv, const struct cmd_desc *cmd)
" buffered : buffered IO\n" \
" 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" \
+" mmap : mmap(MAP_POPULATE) + mlock()\n" \
+" mlock : mmap() + mlock()\n" \
+" madvise : mmap() + mlock2(MLOCK_ONFAULT) + madvise(MADV_POPULATE_READ)\n" \
+" fadvise : mmap() + fadvise(POSIX_FADV_WILLNEED) + mlock()\n" \
"advice can be\n" \
" 1 : set sequential|willneed\n" \
" 0 : none\n" \
--
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
* Re: [f2fs-dev] [PATCH 1/2] f2fs_io: add mlock() option in the read test
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:48 ` Chao Yu via Linux-f2fs-devel
2025-12-16 0:50 ` Jaegeuk Kim via Linux-f2fs-devel
2025-12-17 0:42 ` [f2fs-dev] [PATCH 1/2 v2] " Jaegeuk Kim via Linux-f2fs-devel
1 sibling, 2 replies; 9+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-12-15 1:48 UTC (permalink / raw)
To: Jaegeuk Kim, linux-f2fs-devel
On 12/12/25 08:55, Jaegeuk Kim via Linux-f2fs-devel wrote:
> 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();
mlock_time_start = get_current_us();
> + if (mlock(data, count * buf_size))
> + die_errno("mlock failed");
> + io_time_end = get_current_us();
mlock_time_end = get_current_us();
Thanks,
> + 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);
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH 2/2] f2fs_io: add more description in read test
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
0 siblings, 0 replies; 9+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-12-15 1:49 UTC (permalink / raw)
To: Jaegeuk Kim, linux-f2fs-devel
On 12/12/25 08:55, Jaegeuk Kim via Linux-f2fs-devel wrote:
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH 1/2] f2fs_io: add mlock() option in the read test
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-17 0:42 ` [f2fs-dev] [PATCH 1/2 v2] " Jaegeuk Kim via Linux-f2fs-devel
1 sibling, 1 reply; 9+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2025-12-16 0:50 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-f2fs-devel
On 12/15, Chao Yu wrote:
> On 12/12/25 08:55, Jaegeuk Kim via Linux-f2fs-devel wrote:
> > 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();
>
> mlock_time_start = get_current_us();
This is when IO happens, so IO.
>
> > + if (mlock(data, count * buf_size))
> > + die_errno("mlock failed");
> > + io_time_end = get_current_us();
>
> mlock_time_end = get_current_us();
>
> Thanks,
>
> > + 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);
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH 1/2] f2fs_io: add mlock() option in the read test
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
0 siblings, 1 reply; 9+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-12-16 6:33 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-f2fs-devel
On 12/16/25 08:50, Jaegeuk Kim wrote:
> On 12/15, Chao Yu wrote:
>> On 12/12/25 08:55, Jaegeuk Kim via Linux-f2fs-devel wrote:
>>> 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();
>>
>> mlock_time_start = get_current_us();
>
> This is when IO happens, so IO.
Okay, but it seems later we will print "mlock time = 0" which doesn't match the code?
Thanks,
>
>>
>>> + if (mlock(data, count * buf_size))
>>> + die_errno("mlock failed");
>>> + io_time_end = get_current_us();
>>
>> mlock_time_end = get_current_us();
>>
>> Thanks,
>>
>>> + 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);
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH 1/2] f2fs_io: add mlock() option in the read test
2025-12-16 6:33 ` Chao Yu via Linux-f2fs-devel
@ 2025-12-16 19:12 ` Jaegeuk Kim via Linux-f2fs-devel
0 siblings, 0 replies; 9+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2025-12-16 19:12 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-f2fs-devel
On 12/16, Chao Yu wrote:
> On 12/16/25 08:50, Jaegeuk Kim wrote:
> > On 12/15, Chao Yu wrote:
> >> On 12/12/25 08:55, Jaegeuk Kim via Linux-f2fs-devel wrote:
> >>> 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();
> >>
> >> mlock_time_start = get_current_us();
> >
> > This is when IO happens, so IO.
>
> Okay, but it seems later we will print "mlock time = 0" which doesn't match the code?
It may be okay to show the same time on IO and mlock?
>
> Thanks,
>
> >
> >>
> >>> + if (mlock(data, count * buf_size))
> >>> + die_errno("mlock failed");
> >>> + io_time_end = get_current_us();
> >>
> >> mlock_time_end = get_current_us();
> >>
> >> Thanks,
> >>
> >>> + 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);
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [f2fs-dev] [PATCH 1/2 v2] f2fs_io: add mlock() option in the read test
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-17 0:42 ` Jaegeuk Kim via Linux-f2fs-devel
2025-12-19 3:05 ` Chao Yu via Linux-f2fs-devel
1 sibling, 1 reply; 9+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2025-12-17 0:42 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-f2fs-devel
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
Change log from v1:
- give mlock/io time together
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..1b290bc669f8 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 = mlock_time_start = get_current_us();
+ if (mlock(data, count * buf_size))
+ die_errno("mlock failed");
+ io_time_end = 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);
--
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
* Re: [f2fs-dev] [PATCH 1/2 v2] f2fs_io: add mlock() option in the read test
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
0 siblings, 0 replies; 9+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-12-19 3:05 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-f2fs-devel
On 12/17/2025 8:42 AM, Jaegeuk Kim wrote:
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).