Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4385782ybb; Tue, 14 Apr 2020 06:21:17 -0700 (PDT) X-Google-Smtp-Source: APiQypIhnBYYnfAU0Z+nD/iT3R6amAJFWzXykiSX1DzonW4t0o4VoSi9xYOy8cProoGHqlIVXUV9 X-Received: by 2002:a17:906:d14b:: with SMTP id br11mr30487ejb.213.1586870477018; Tue, 14 Apr 2020 06:21:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586870477; cv=none; d=google.com; s=arc-20160816; b=LAmPAVC6Nr+AG4ZqB6iXT6PjQWSioi8bJ/aCGZ3TH32hwcN9QLW3JD/tmExyNeLEvr eT/UnnxfpByizZsrKbNllBT/YmD28i6av/9fwJdaQrVsnS3/uCUxLqsz7Hq6LMli9FrO UDJpXSWxF2UCzX5AK0VR8sRNC6/NNqLx94FRBnicCfC997fymkuZIypwe1FFTl3XVWfW njMFOICmwzzy8wKx2hwkzbcNJjZHRymVNLLCXwly+EbndNfheEAYk4nnPbBEdpeyhjZ5 nHK9TlNCtOssw1AoYa/rCC+P2f7HlRPqiQUr+BWhTmwirboFekFM2d7fbjTFrWLgJB9U VMHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Yiz3bK3sjJz3E8LEF5YJot3DsXNpvV5m8eoPYztP8CU=; b=rOage7RQABYNxhbFF0LosFWmKvs7bDPnK/o/rdNnjQaUWNg9pARAWHx+j0XRW37Lss lyj6dia5is030FTWIHGBtR+SMRYagkcKX++Nr1SQbstWlnRCBhix2LfCYYv+1jEUYxH1 gTsu2YKbWK0H47k8qBWiKDS3Zb5fCtvHgxCUp4LRjl0/8sU63Tri4trDhPduqwzAjnVN rhwc9l/ctcHIkgkp+sNlwN3b/8JH8ZQsERyQGozEdxxsUhkOLm1r9Pp+MOgg5sLfyA2J yJ4HfVyu5RB5qBbrcGUrRdQpgpYbtYIuX7Ls2GG2wOv3BpxPkdHyK1xBa4+6eRo6dtk3 1zOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IONbqX8E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i3si8176482ejx.334.2020.04.14.06.20.52; Tue, 14 Apr 2020 06:21:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IONbqX8E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731417AbgDMQQw (ORCPT + 99 others); Mon, 13 Apr 2020 12:16:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:43770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731412AbgDMQQv (ORCPT ); Mon, 13 Apr 2020 12:16:51 -0400 Received: from localhost (unknown [104.132.1.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 356612072C; Mon, 13 Apr 2020 16:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586794610; bh=00NfhYZ8RL0JxCpNolUpraJn5ePTrwODtHaKcWmumkM=; h=From:To:Cc:Subject:Date:From; b=IONbqX8E0ThhePaqxTvRFuFNjKhxQbD2iIOQReMMU0IDGKXLH/BAk1q3o2iAkvmFY qhb667+CauT1QoL4Tnib3bkDyegY05vSk8KzkDlE/y4N8Xh5mMzrxmPNw3XMlqy7uK VHNcwBNIaxnQxs0Ni0L6cgfWluE+cfbYWjFgjX9I= From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Cc: Daeho Jeong Subject: [PATCH] f2fs: add tracepoint for f2fs iostat Date: Mon, 13 Apr 2020 09:16:49 -0700 Message-Id: <20200413161649.38177-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.26.0.110.g2183baf09c-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daeho Jeong Added a tracepoint to see iostat of f2fs. Default period of that is 3 second. This tracepoint can be used to be monitoring I/O statistics periodically. Bug: 152162885 Change-Id: I6fbe010b9cf1a90caa0f4793a6dab77c4cba7da6 Signed-off-by: Daeho Jeong --- fs/f2fs/f2fs.h | 10 ++++++- fs/f2fs/sysfs.c | 34 ++++++++++++++++++++++++ include/trace/events/f2fs.h | 52 +++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index c2788738aa0d4..87baa09f76fb2 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -2999,16 +2999,22 @@ static inline int get_inline_xattr_addrs(struct inode *inode) sizeof((f2fs_inode)->field)) \ <= (F2FS_OLD_ATTRIBUTE_SIZE + (extra_isize))) \ +extern unsigned long long f2fs_prev_iostat[NR_IO_TYPE]; + static inline void f2fs_reset_iostat(struct f2fs_sb_info *sbi) { int i; spin_lock(&sbi->iostat_lock); - for (i = 0; i < NR_IO_TYPE; i++) + for (i = 0; i < NR_IO_TYPE; i++) { sbi->write_iostat[i] = 0; + f2fs_prev_iostat[i] = 0; + } spin_unlock(&sbi->iostat_lock); } +extern void f2fs_record_iostat(struct f2fs_sb_info *sbi); + static inline void f2fs_update_iostat(struct f2fs_sb_info *sbi, enum iostat_type type, unsigned long long io_bytes) { @@ -3022,6 +3028,8 @@ static inline void f2fs_update_iostat(struct f2fs_sb_info *sbi, sbi->write_iostat[APP_WRITE_IO] - sbi->write_iostat[APP_DIRECT_IO]; spin_unlock(&sbi->iostat_lock); + + f2fs_record_iostat(sbi); } #define __is_large_section(sbi) ((sbi)->segs_per_sec > 1) diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index aeebfb5024a22..f34cb75cd039c 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -15,6 +15,7 @@ #include "f2fs.h" #include "segment.h" #include "gc.h" +#include static struct proc_dir_entry *f2fs_proc_root; @@ -751,6 +752,39 @@ static int __maybe_unused segment_bits_seq_show(struct seq_file *seq, return 0; } +static const unsigned long period_ms = 3000; +static unsigned long next_period; +unsigned long long f2fs_prev_iostat[NR_IO_TYPE] = {0}; + +static DEFINE_SPINLOCK(iostat_lock); + +void f2fs_record_iostat(struct f2fs_sb_info *sbi) +{ + unsigned long long iostat_diff[NR_IO_TYPE]; + int i; + + if (time_is_after_jiffies(next_period)) + return; + + /* Need double check under the lock */ + spin_lock(&iostat_lock); + if (time_is_after_jiffies(next_period)) { + spin_unlock(&iostat_lock); + return; + } + next_period = jiffies + msecs_to_jiffies(period_ms); + spin_unlock(&iostat_lock); + + spin_lock(&sbi->iostat_lock); + for (i = 0; i < NR_IO_TYPE; i++) { + iostat_diff[i] = sbi->write_iostat[i] - f2fs_prev_iostat[i]; + f2fs_prev_iostat[i] = sbi->write_iostat[i]; + } + spin_unlock(&sbi->iostat_lock); + + trace_f2fs_iostat(sbi, iostat_diff); +} + static int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset) { diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h index d97adfc327f03..e78c8696e2adc 100644 --- a/include/trace/events/f2fs.h +++ b/include/trace/events/f2fs.h @@ -1812,6 +1812,58 @@ DEFINE_EVENT(f2fs_zip_end, f2fs_decompress_pages_end, TP_ARGS(inode, cluster_idx, compressed_size, ret) ); +TRACE_EVENT(f2fs_iostat, + + TP_PROTO(struct f2fs_sb_info *sbi, unsigned long long *iostat), + + TP_ARGS(sbi, iostat), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(unsigned long long, app_dio) + __field(unsigned long long, app_bio) + __field(unsigned long long, app_wio) + __field(unsigned long long, app_mio) + __field(unsigned long long, fs_dio) + __field(unsigned long long, fs_nio) + __field(unsigned long long, fs_mio) + __field(unsigned long long, fs_gc_dio) + __field(unsigned long long, fs_gc_nio) + __field(unsigned long long, fs_cp_dio) + __field(unsigned long long, fs_cp_nio) + __field(unsigned long long, fs_cp_mio) + __field(unsigned long long, fs_discard) + ), + + TP_fast_assign( + __entry->dev = sbi->sb->s_dev; + __entry->app_dio = iostat[APP_DIRECT_IO]; + __entry->app_bio = iostat[APP_BUFFERED_IO]; + __entry->app_wio = iostat[APP_WRITE_IO]; + __entry->app_mio = iostat[APP_MAPPED_IO]; + __entry->fs_dio = iostat[FS_DATA_IO]; + __entry->fs_nio = iostat[FS_NODE_IO]; + __entry->fs_mio = iostat[FS_META_IO]; + __entry->fs_gc_dio = iostat[FS_GC_DATA_IO]; + __entry->fs_gc_nio = iostat[FS_GC_NODE_IO]; + __entry->fs_cp_dio = iostat[FS_CP_DATA_IO]; + __entry->fs_cp_nio = iostat[FS_CP_NODE_IO]; + __entry->fs_cp_mio = iostat[FS_CP_META_IO]; + __entry->fs_discard = iostat[FS_DISCARD]; + ), + + TP_printk("dev = (%d,%d), " + "app [write=%llu (direct=%llu, buffered=%llu), mapped=%llu], " + "fs [data=%llu, node=%llu, meta=%llu, discard=%llu], " + "gc [data=%llu, node=%llu], " + "cp [data=%llu, node=%llu, meta=%llu]", + show_dev(__entry->dev), __entry->app_wio, __entry->app_dio, + __entry->app_bio, __entry->app_mio, __entry->fs_dio, + __entry->fs_nio, __entry->fs_mio, __entry->fs_discard, + __entry->fs_gc_dio, __entry->fs_gc_nio, __entry->fs_cp_dio, + __entry->fs_cp_nio, __entry->fs_cp_mio) +); + #endif /* _TRACE_F2FS_H */ /* This part must be outside protection */ -- 2.26.0.110.g2183baf09c-goog