Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AFF1DCAC5BD for ; Tue, 30 Sep 2025 02:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:References:In-Reply-To: Message-ID:Date:To:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PUZfNkQEu97UnPZfoLyB3RJuDRtqgbJOwKRv658s+lY=; b=ZF00WBNIwJT6pECvUY+IK4AP48 DyjQqTQWdMDF8gMNKo+4pYauhsGBMJnibr7XRsQBW2gHxZjtXTBxN1bFLKucl7IB3IQOKrPEIeb7y 6WrMxo3N293DnDTgbgJ9kx7zkJ2TN3WJdl4HTcy/g0iTn3EJ6mXBoGEmm3XPojBJ6KeA=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1v3QF2-0005JO-O7; Tue, 30 Sep 2025 02:37:24 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1v3QEz-0005JG-N3 for linux-f2fs-devel@lists.sourceforge.net; Tue, 30 Sep 2025 02:37:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=VJIRto2wfEplTCqpvHZh+vd/5+qoX8bnz6uer0PAGx4=; b=kkSpZwphpR3p7KEh/HyaoPo1Yd 9Jzg0QQCqHVvLvmurkN+N+pmL8xeYXurFfnVP1JBTLnjz4EL49dmxBCqFtv2lrdnCvR9cMBhjffyn t1uaddRFwgPcOlxdyW1kAgrlKMIp0M0Wy0Qei7VTjB9S+KUoFgK0FGimSyF3XdTSXZLs=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=VJIRto2wfEplTCqpvHZh+vd/5+qoX8bnz6uer0PAGx4=; b=GPxfL8N6MP4ElAz8p6Dgk8PTbR FAPXp9n5uGTIDJwA0DNy+pTREAy1SyXkIVf26b4S1t6oRjpzF6TCQIUR41gz8zCp74YKVMUQmuA98 Zq65N4CQZNS26B6Cv0/xQia74psuoG71aVAtbDrC609+j6N/uAJ38r1VFU9pDHIkye/s=; Received: from sea.source.kernel.org ([172.234.252.31]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1v3QEz-0004Sy-8o for linux-f2fs-devel@lists.sourceforge.net; Tue, 30 Sep 2025 02:37:21 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id E91D645B3D for ; Tue, 30 Sep 2025 02:37:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7634C116C6; Tue, 30 Sep 2025 02:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759199830; bh=B8+dSZWGnM31jtS6BLhtWnr7abeLIk24WnGIpnF9JCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D8SUE22fLpZVahbvQZoneOgnqoPkJyhqT7PUGfegbZ9pgxepWLRTPWTEsNLhWJ7xr DipZFhD/bJxhX6hp2beVLAWoRp9yMATACVpHgQELfRhwfnQrwjX6C4k0/nwemy5Glv dpkZSOQEQBytElCjncT99W+WMqfaHpJHzc5NP3N291iGt4SFX28mEsWrkrjdyRxQYK lPiemOKpunn0WUCHICfmQGSokO4PVtzHIXVSrgdIMC49h66yU7QaPKKnSA2JIXdOOt lH347+x431c8FhR55onp/1ipqOO6jt5/dD04/l4gAtxHh1aWj8jj58xbGlJb44L3OB 3dpY8hdveI7pQ== To: linux-f2fs-devel@lists.sourceforge.net Date: Tue, 30 Sep 2025 02:37:01 +0000 Message-ID: <20250930023704.3019074-2-jaegeuk@kernel.org> X-Mailer: git-send-email 2.51.0.618.g983fd99d29-goog In-Reply-To: <20250930023704.3019074-1-jaegeuk@kernel.org> References: <20250930023704.3019074-1-jaegeuk@kernel.org> MIME-Version: 1.0 X-Headers-End: 1v3QEz-0004Sy-8o Subject: [f2fs-dev] [PATCH 2/5] f2fs_io: measure atomic operation latency with random write X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Jaegeuk Kim via Linux-f2fs-devel Reply-To: Jaegeuk Kim Cc: Jaegeuk Kim Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net If we give a negative offset, let's do random writes. > f2fs_io write 1 -400 10 rand atomic_commit ./test conducts 10 random writes by picking addresses between 0 and 400 * 4KB. Signed-off-by: Jaegeuk Kim --- tools/f2fs_io/f2fs_io.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c index 1f6bfcfff556..b9bf9bc5f797 100644 --- a/tools/f2fs_io/f2fs_io.c +++ b/tools/f2fs_io/f2fs_io.c @@ -710,7 +710,8 @@ static void do_write_with_advice(int argc, char **argv, const struct cmd_desc *cmd, bool with_advice) { u64 buf_size = 0, inc_num = 0, written = 0; - u64 offset; + u64 offset, offset_byte; + bool random_offset = false; char *buf = NULL; unsigned bs, count, i; int flags = 0; @@ -727,7 +728,11 @@ static void do_write_with_advice(int argc, char **argv, buf_size = bs * F2FS_DEFAULT_BLKSIZE; - offset = atoi(argv[2]) * buf_size; + offset = atoi(argv[2]); + if (atoi(argv[2]) < 0) { + random_offset = true; + offset = -offset; + } buf = aligned_xalloc(F2FS_DEFAULT_BLKSIZE, buf_size); count = atoi(argv[3]); @@ -812,10 +817,14 @@ static void do_write_with_advice(int argc, char **argv, else if (!strcmp(argv[4], "rand")) *(int *)buf = rand(); + offset_byte = (random_offset ? rand() % offset : + offset + i) * buf_size; + /* write data */ max_time_t = get_current_us(); - ret = pwrite(fd, buf, buf_size, offset + buf_size * i); + ret = pwrite(fd, buf, buf_size, offset_byte); max_time_t = get_current_us() - max_time_t; + if (max_time < max_time_t) max_time = max_time_t; if (ret != buf_size) @@ -844,7 +853,7 @@ static void do_write_with_advice(int argc, char **argv, } } - printf("Written %"PRIu64" bytes with pattern=%s, total_time=%"PRIu64" us, max_latency=%"PRIu64" us\n", + printf("Written %"PRIu64" bytes with pattern = %s, total_time = %"PRIu64" us, max_latency = %"PRIu64" us\n", written, argv[4], get_current_us() - total_time, max_time); @@ -855,6 +864,8 @@ static void do_write_with_advice(int argc, char **argv, #define write_help \ "f2fs_io write [chunk_size in 4kb] [offset in chunk_size] [count] [pattern] [IO] [file_path] {delay}\n\n" \ "Write given patten data in file_path\n" \ +"Offset can be a negative number which\n" \ +" indicates random write range for atomic operations.\n" \ "pattern can be\n" \ " zero : zeros\n" \ " inc_num : incrementing numbers\n" \ -- 2.51.0.618.g983fd99d29-goog _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel