* [f2fs-dev] [PATCH] f2fs-tools: f2fs_io: no memcpy for mmap read
@ 2023-08-14 20:58 Jaegeuk Kim
2023-08-17 14:56 ` Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Jaegeuk Kim @ 2023-08-14 20:58 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim
This replaces the mmmap read flow to get the maximum performance.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
tools/f2fs_io/f2fs_io.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index 73ac700f8209..51baded4cb4b 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -684,6 +684,7 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd)
char *data;
char *print_buf = NULL;
unsigned bs, count, i, print_bytes;
+ u64 total_time = 0;
int flags = 0;
int do_mmap = 0;
int fd;
@@ -719,28 +720,29 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd)
fd = xopen(argv[6], O_RDONLY | flags, 0);
+ total_time = get_current_us();
if (do_mmap) {
data = mmap(NULL, count * buf_size, PROT_READ,
- MAP_SHARED, fd, offset);
+ MAP_SHARED | MAP_POPULATE, fd, offset);
if (data == MAP_FAILED)
die("Mmap failed");
}
-
- for (i = 0; i < count; i++) {
- if (do_mmap) {
- memcpy(buf, data + offset + buf_size * i, buf_size);
- ret = buf_size;
- } else {
+ if (!do_mmap) {
+ for (i = 0; i < count; i++) {
ret = pread(fd, buf, buf_size, offset + buf_size * i);
- }
- if (ret != buf_size)
- break;
+ if (ret != buf_size)
+ break;
- read_cnt += ret;
- if (i == 0)
- memcpy(print_buf, buf, print_bytes);
+ read_cnt += ret;
+ if (i == 0)
+ memcpy(print_buf, buf, print_bytes);
+ }
+ } else {
+ read_cnt = count * buf_size;
+ memcpy(print_buf, data, print_bytes);
}
- printf("Read %"PRIu64" bytes and print %u bytes:\n", read_cnt, print_bytes);
+ printf("Read %"PRIu64" bytes total_time = %"PRIu64" us, print %u bytes:\n",
+ read_cnt, get_current_us() - total_time, print_bytes);
printf("%08"PRIx64" : ", offset);
for (i = 1; i <= print_bytes; i++) {
printf("%02x", print_buf[i - 1]);
--
2.41.0.694.ge786442a9b-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] 2+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs-tools: f2fs_io: no memcpy for mmap read
2023-08-14 20:58 [f2fs-dev] [PATCH] f2fs-tools: f2fs_io: no memcpy for mmap read Jaegeuk Kim
@ 2023-08-17 14:56 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2023-08-17 14:56 UTC (permalink / raw)
To: Jaegeuk Kim, linux-f2fs-devel
On 2023/8/15 4:58, Jaegeuk Kim wrote:
> This replaces the mmmap read flow to get the maximum performance.
>
> 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] 2+ messages in thread
end of thread, other threads:[~2023-08-17 14:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-14 20:58 [f2fs-dev] [PATCH] f2fs-tools: f2fs_io: no memcpy for mmap read Jaegeuk Kim
2023-08-17 14:56 ` Chao Yu
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).