[lustre-devel] [PATCH 08/24] lustre: statahead: add total hit/miss count stats

James Simmons jsimmons at infradead.org
Mon Sep 5 18:55:21 PDT 2022


From: Qian Yingjin <qian at ddn.com>

In this patch, it adds total hit/miss count stats for statahead.
These statistics are updated when the statahead thread terminated.

This patch also adds support to clear all statahead stats:
  $LCTL set_param llite.*.statahead_stats=0

WC-bug-id: https://jira.whamcloud.com/browse/LU-14139
Lustre-commit: b9167201a00e38ce8 ("LU-14139 statahead: add total hit/miss count stats")
Signed-off-by: Qian Yingjin <qian at ddn.com>
Reviewed-on: https://review.whamcloud.com/46309
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao at whamcloud.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/llite/llite_internal.h |  2 ++
 fs/lustre/llite/llite_lib.c      |  2 ++
 fs/lustre/llite/lproc_llite.c    | 26 +++++++++++++++++++++++---
 fs/lustre/llite/statahead.c      |  3 +++
 4 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h
index e7f703a..227b944 100644
--- a/fs/lustre/llite/llite_internal.h
+++ b/fs/lustre/llite/llite_internal.h
@@ -749,6 +749,8 @@ struct ll_sb_info {
 						 * count
 						 */
 	atomic_t		ll_agl_total;	/* AGL thread started count */
+	atomic_t		ll_sa_hit_total;  /* total hit count */
+	atomic_t		ll_sa_miss_total; /* total miss count */
 
 	dev_t			ll_sdev_orig;	/* save s_dev before assign for
 						 * clustered nfs
diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c
index 0bffe5e..191a83c 100644
--- a/fs/lustre/llite/llite_lib.c
+++ b/fs/lustre/llite/llite_lib.c
@@ -168,6 +168,8 @@ static struct ll_sb_info *ll_init_sbi(void)
 	atomic_set(&sbi->ll_sa_wrong, 0);
 	atomic_set(&sbi->ll_sa_running, 0);
 	atomic_set(&sbi->ll_agl_total, 0);
+	atomic_set(&sbi->ll_sa_hit_total, 0);
+	atomic_set(&sbi->ll_sa_miss_total, 0);
 	set_bit(LL_SBI_AGL_ENABLED, sbi->ll_flags);
 	set_bit(LL_SBI_FAST_READ, sbi->ll_flags);
 	set_bit(LL_SBI_TINY_WRITE, sbi->ll_flags);
diff --git a/fs/lustre/llite/lproc_llite.c b/fs/lustre/llite/lproc_llite.c
index 095b696..1391828 100644
--- a/fs/lustre/llite/lproc_llite.c
+++ b/fs/lustre/llite/lproc_llite.c
@@ -843,14 +843,34 @@ static int ll_statahead_stats_seq_show(struct seq_file *m, void *v)
 	seq_printf(m,
 		   "statahead total: %u\n"
 		   "statahead wrong: %u\n"
-		   "agl total: %u\n",
+		   "agl total: %u\n"
+		   "hit_total: %u\n"
+		   "miss_total: %u\n",
 		   atomic_read(&sbi->ll_sa_total),
 		   atomic_read(&sbi->ll_sa_wrong),
-		   atomic_read(&sbi->ll_agl_total));
+		   atomic_read(&sbi->ll_agl_total),
+		   atomic_read(&sbi->ll_sa_hit_total),
+		   atomic_read(&sbi->ll_sa_miss_total));
 	return 0;
 }
 
-LDEBUGFS_SEQ_FOPS_RO(ll_statahead_stats);
+static ssize_t ll_statahead_stats_seq_write(struct file *file,
+					    const char __user *buffer,
+					    size_t count, loff_t *off)
+{
+	struct seq_file *m = file->private_data;
+	struct super_block *sb = m->private;
+	struct ll_sb_info *sbi = ll_s2sbi(sb);
+
+	atomic_set(&sbi->ll_sa_total, 0);
+	atomic_set(&sbi->ll_sa_wrong, 0);
+	atomic_set(&sbi->ll_agl_total, 0);
+	atomic_set(&sbi->ll_sa_hit_total, 0);
+	atomic_set(&sbi->ll_sa_miss_total, 0);
+
+	return count;
+}
+LDEBUGFS_SEQ_FOPS(ll_statahead_stats);
 
 static ssize_t lazystatfs_show(struct kobject *kobj,
 			       struct attribute *attr,
diff --git a/fs/lustre/llite/statahead.c b/fs/lustre/llite/statahead.c
index 5662f44..1f1fafd 100644
--- a/fs/lustre/llite/statahead.c
+++ b/fs/lustre/llite/statahead.c
@@ -1224,6 +1224,9 @@ static int ll_statahead_thread(void *arg)
 	spin_unlock(&lli->lli_sa_lock);
 	wake_up(&sai->sai_waitq);
 
+	atomic_add(sai->sai_hit, &sbi->ll_sa_hit_total);
+	atomic_add(sai->sai_miss, &sbi->ll_sa_miss_total);
+
 	ll_sai_put(sai);
 
 	return rc;
-- 
1.8.3.1



More information about the lustre-devel mailing list