All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] blkparse: split off the timestamp correction code in to a separate function
@ 2019-09-24 22:32 Hiroaki Mihara
  2019-09-25  6:22 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Hiroaki Mihara @ 2019-09-24 22:32 UTC (permalink / raw)
  To: linux-btrace

find_genesis() function has code to correct abs_start_time, which is
later used to calculate the absolute timestamps of each traced
records.

Put this code in a separate function, so that it can be used later by
the blkparse code. No functional change.

Signed-off-by: Hiroaki Mihara <hmihara@redhat.com>
---
 blkparse.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/blkparse.c b/blkparse.c
index 3de2ebe..cf7a87b 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2022,6 +2022,22 @@ static void show_device_and_cpu_stats(void)
 	}
 }
 
+static void correct_abs_start_time(void)
+{
+	long delta = genesis_time - start_timestamp;
+
+	abs_start_time.tv_sec  += SECONDS(delta);
+	abs_start_time.tv_nsec += NANO_SECONDS(delta);
+	if (abs_start_time.tv_nsec < 0) {
+		abs_start_time.tv_nsec += 1000000000;
+		abs_start_time.tv_sec -= 1;
+	} else
+	if (abs_start_time.tv_nsec > 1000000000) {
+		abs_start_time.tv_nsec -= 1000000000;
+		abs_start_time.tv_sec += 1;
+	}
+}
+
 static void find_genesis(void)
 {
 	struct trace *t = trace_list;
@@ -2039,18 +2055,7 @@ static void find_genesis(void)
 	 */
 	if (start_timestamp
 	 && start_timestamp != genesis_time) {
-		long delta = genesis_time - start_timestamp;
-
-		abs_start_time.tv_sec  += SECONDS(delta);
-		abs_start_time.tv_nsec += NANO_SECONDS(delta);
-		if (abs_start_time.tv_nsec < 0) {
-			abs_start_time.tv_nsec += 1000000000;
-			abs_start_time.tv_sec -= 1;
-		} else
-		if (abs_start_time.tv_nsec > 1000000000) {
-			abs_start_time.tv_nsec -= 1000000000;
-			abs_start_time.tv_sec += 1;
-		}
+		correct_abs_start_time();
 	}
 }
 
-- 
2.21.0

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

* Re: [PATCH 1/3] blkparse: split off the timestamp correction code in to a separate function
  2019-09-24 22:32 [PATCH 1/3] blkparse: split off the timestamp correction code in to a separate function Hiroaki Mihara
@ 2019-09-25  6:22 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2019-09-25  6:22 UTC (permalink / raw)
  To: linux-btrace

On 9/25/19 12:32 AM, Hiroaki Mihara wrote:
> find_genesis() function has code to correct abs_start_time, which is
> later used to calculate the absolute timestamps of each traced
> records.
> 
> Put this code in a separate function, so that it can be used later by
> the blkparse code. No functional change.

Applied this, and the other 2. Thanks.

-- 
Jens Axboe

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

end of thread, other threads:[~2019-09-25  6:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24 22:32 [PATCH 1/3] blkparse: split off the timestamp correction code in to a separate function Hiroaki Mihara
2019-09-25  6:22 ` Jens Axboe

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.