lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <170873668021.1860949.13792887319624615306.stgit@frogsfrogsfrogs>
Date: Fri, 23 Feb 2024 17:11:23 -0800
From: "Darrick J. Wong" <djwong@...nel.org>
To: akpm@...ux-foundation.org, daniel@...o.nz, kent.overstreet@...ux.dev,
 djwong@...nel.org
Cc: linux-xfs@...r.kernel.org, linux-bcachefs@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: [PATCH 05/10] time_stats: don't print any output if event count is
 zero

From: Darrick J. Wong <djwong@...nel.org>

There's no point in printing an empty report for no data, so add a flag
that allows us to do that.

Signed-off-by: Darrick J. Wong <djwong@...nel.org>
Signed-off-by: Kent Overstreet <kent.overstreet@...ux.dev>
---
 include/linux/time_stats.h |    4 +++-
 lib/time_stats.c           |   10 ++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)


diff --git a/include/linux/time_stats.h b/include/linux/time_stats.h
index 1c1ba8efa7bfe..994823c17bca9 100644
--- a/include/linux/time_stats.h
+++ b/include/linux/time_stats.h
@@ -148,8 +148,10 @@ static inline bool track_event_change(struct time_stats *stats, bool v)
 	return false;
 }
 
+#define TIME_STATS_PRINT_NO_ZEROES	(1U << 0)	/* print nothing if zero count */
 struct seq_buf;
-void time_stats_to_seq_buf(struct seq_buf *, struct time_stats *);
+void time_stats_to_seq_buf(struct seq_buf *, struct time_stats *,
+		unsigned int flags);
 
 void time_stats_exit(struct time_stats *);
 void time_stats_init(struct time_stats *);
diff --git a/lib/time_stats.c b/lib/time_stats.c
index 43106bda43a92..382935979f8f7 100644
--- a/lib/time_stats.c
+++ b/lib/time_stats.c
@@ -168,7 +168,8 @@ static inline u64 time_stats_lifetime(const struct time_stats *stats)
 	return local_clock() - (stats->start_time & ~TIME_STATS_HAVE_QUANTILES);
 }
 
-void time_stats_to_seq_buf(struct seq_buf *out, struct time_stats *stats)
+void time_stats_to_seq_buf(struct seq_buf *out, struct time_stats *stats,
+		unsigned int flags)
 {
 	struct quantiles *quantiles = time_stats_to_quantiles(stats);
 	s64 f_mean = 0, d_mean = 0;
@@ -184,14 +185,15 @@ void time_stats_to_seq_buf(struct seq_buf *out, struct time_stats *stats)
 		spin_unlock_irq(&stats->lock);
 	}
 
-	/*
-	 * avoid divide by zero
-	 */
 	if (stats->freq_stats.n) {
+		/* avoid divide by zero */
 		f_mean = mean_and_variance_get_mean(stats->freq_stats);
 		f_stddev = mean_and_variance_get_stddev(stats->freq_stats);
 		d_mean = mean_and_variance_get_mean(stats->duration_stats);
 		d_stddev = mean_and_variance_get_stddev(stats->duration_stats);
+	} else if (flags & TIME_STATS_PRINT_NO_ZEROES) {
+		/* unless we didn't want zeroes anyway */
+		return;
 	}
 
 	seq_buf_printf(out, "count: %llu\n", stats->duration_stats.n);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ