All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 7/9] fio: flush log files on test end
@ 2014-02-20 13:20 ehrhardt
  0 siblings, 0 replies; 10+ messages in thread
From: ehrhardt @ 2014-02-20 13:20 UTC (permalink / raw)
  To: fio; +Cc: oberpar, Christian Ehrhardt

*Resend with hopefully non mangled patches*
References: <20140220131958.965092001@linux.vnet.ibm.com>
Content-Disposition: inline; filename=flush_log.diff

From: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>

Ensure proper flushing of all logs at the end of tests.

Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>

---
[diffstat]
 backend.c |    1 
 iolog.h   |    1 
 stat.c    |   73 ++++++++++++++++++++++++++++++++++++++++----------------------
 3 files changed, 50 insertions(+), 25 deletions(-)

--- a/backend.c
+++ b/backend.c
@@ -1461,6 +1461,7 @@ static void *thread_main(void *data)
 	fio_unpin_memory(td);
 
 	fio_mutex_down(writeout_mutex);
+	finalize_logs(td);
 	if (td->bw_log) {
 		if (o->bw_log_file) {
 			finish_log_named(td, td->bw_log,
--- a/iolog.h
+++ b/iolog.h
@@ -117,6 +117,7 @@ extern void write_iolog_close(struct thr
 /*
  * Logging
  */
+extern void finalize_logs(struct thread_data *td);
 extern void add_lat_sample(struct thread_data *, enum fio_ddir, unsigned long,
 				unsigned int);
 extern void add_clat_sample(struct thread_data *, enum fio_ddir, unsigned long,
--- a/stat.c
+++ b/stat.c
@@ -1579,6 +1579,37 @@ static inline void reset_io_stat(struct
 	ios->mean.u.f = ios->S.u.f = 0;
 }
 
+static void _add_stat_to_log(struct io_log *iolog, unsigned long elapsed)
+{
+	/*
+	 * Note an entry in the log. Use the mean from the logged samples,
+	 * making sure to properly round up. Only write a log entry if we
+	 * had actual samples done.
+	 */
+	if (iolog->avg_window[DDIR_READ].samples) {
+		unsigned long mr;
+
+		mr = iolog->avg_window[DDIR_READ].mean.u.f + 0.50;
+		__add_log_sample(iolog, mr, DDIR_READ, 0, elapsed);
+	}
+	if (iolog->avg_window[DDIR_WRITE].samples) {
+		unsigned long mw;
+
+		mw = iolog->avg_window[DDIR_WRITE].mean.u.f + 0.50;
+		__add_log_sample(iolog, mw, DDIR_WRITE, 0, elapsed);
+	}
+	if (iolog->avg_window[DDIR_TRIM].samples) {
+		unsigned long mw;
+
+		mw = iolog->avg_window[DDIR_TRIM].mean.u.f + 0.50;
+		__add_log_sample(iolog, mw, DDIR_TRIM, 0, elapsed);
+	}
+
+	reset_io_stat(&iolog->avg_window[DDIR_READ]);
+	reset_io_stat(&iolog->avg_window[DDIR_WRITE]);
+	reset_io_stat(&iolog->avg_window[DDIR_TRIM]);
+}
+
 static void add_log_sample(struct thread_data *td, struct io_log *iolog,
 			   unsigned long val, enum fio_ddir ddir,
 			   unsigned int bs)
@@ -1612,35 +1643,27 @@ static void add_log_sample(struct thread
 	if (this_window < iolog->avg_msec)
 		return;
 
-	/*
-	 * Note an entry in the log. Use the mean from the logged samples,
-	 * making sure to properly round up. Only write a log entry if we
-	 * had actual samples done.
-	 */
-	if (iolog->avg_window[DDIR_READ].samples) {
-		unsigned long mr;
+	_add_stat_to_log(iolog, elapsed);
 
-		mr = iolog->avg_window[DDIR_READ].mean.u.f + 0.50;
-		__add_log_sample(iolog, mr, DDIR_READ, 0, elapsed);
-	}
-	if (iolog->avg_window[DDIR_WRITE].samples) {
-		unsigned long mw;
-
-		mw = iolog->avg_window[DDIR_WRITE].mean.u.f + 0.50;
-		__add_log_sample(iolog, mw, DDIR_WRITE, 0, elapsed);
-	}
-	if (iolog->avg_window[DDIR_TRIM].samples) {
-		unsigned long mw;
+	iolog->avg_last = elapsed;
+}
 
-		mw = iolog->avg_window[DDIR_TRIM].mean.u.f + 0.50;
-		__add_log_sample(iolog, mw, DDIR_TRIM, 0, elapsed);
-	}
+void finalize_logs(struct thread_data *td)
+{
+	unsigned long elapsed;
 
+	elapsed = mtime_since_now(&td->epoch);
 
-	reset_io_stat(&iolog->avg_window[DDIR_READ]);
-	reset_io_stat(&iolog->avg_window[DDIR_WRITE]);
-	reset_io_stat(&iolog->avg_window[DDIR_TRIM]);
-	iolog->avg_last = elapsed;
+	if (td->clat_log)
+		_add_stat_to_log(td->clat_log, elapsed);
+	if (td->slat_log)
+		_add_stat_to_log(td->slat_log, elapsed);
+	if (td->lat_log)
+		_add_stat_to_log(td->lat_log, elapsed);
+	if (td->bw_log)
+		_add_stat_to_log(td->bw_log, elapsed);
+	if (td->iops_log)
+		_add_stat_to_log(td->iops_log, elapsed);
 }
 
 void add_agg_sample(unsigned long val, enum fio_ddir ddir, unsigned int bs)


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-02-20 13:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20140219143639.168501090@linux.vnet.ibm.com>
2014-02-19 15:12 ` [patch 1/9] fio: fix job clone mem leak Christian Ehrhardt
2014-02-19 15:12 ` [patch 2/9] fio: allow general repeatability Christian Ehrhardt
2014-02-19 15:12 ` [patch 3/9] fio: allow milliseconds on all time specifiers Christian Ehrhardt
2014-02-19 15:12 ` [patch 4/9] fio: provide an option for a startdelay range Christian Ehrhardt
2014-02-19 15:12 ` [patch 5/9] fio: add multi directory support Christian Ehrhardt
2014-02-19 15:12 ` [patch 6/9] fio: allow to combine terse output with any selected output type Christian Ehrhardt
2014-02-19 15:12 ` [patch 7/9] fio: flush log files on test end Christian Ehrhardt
2014-02-19 15:12 ` [patch 8/9] fio: fix last block never being touched by random offsets Christian Ehrhardt
2014-02-19 15:12 ` [patch 9/9] fio: allow 0 as compress percentage Christian Ehrhardt
2014-02-20 13:20 [patch 7/9] fio: flush log files on test end ehrhardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.