代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/blktrace 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From ea086768766f3bf56eec789ba160c90e99a3e622 Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <agruenba@redhat.com>
Date: Mon, 13 Apr 2020 21:01:51 +0200
Subject: [PATCH 15/15] blkparse: Initialize and test for undefined request
tracking timestamps
Currently, event tracking timestamps aren't initialized at all even though some
places in the code assume that a value of 0 indicates 'undefined'. However, 0
is the timestamp of the first event, so use -1ULL for 'undefined' instead.
In addition, make sure timestamps are only initialized once, and always check
if timestamps are defined before using them.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
blkparse.c | 46 +++++++++++++++++++++++++++++++++++++++-------
1 file changed, 39 insertions(+), 7 deletions(-)
diff --git a/blkparse.c b/blkparse.c
index 2d89bc5..5b3f83a 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <string.h>
#include <getopt.h>
#include <errno.h>
@@ -306,6 +307,21 @@ static int have_drv_data = 0;
#define CPU_IDX(cpu) ((cpu) / CPUS_PER_LONG)
#define CPU_BIT(cpu) ((cpu) & (CPUS_PER_LONG - 1))
+static void io_warn_unless(struct blk_io_trace *t, int condition,
+ const char *fmt, ...)
+{
+ va_list ap;
+
+ if (condition)
+ return;
+ va_start(ap, fmt);
+ printf("(%d,%d) request %llu + %u: ",
+ MAJOR(t->device), MINOR(t->device),
+ t->sector, t->bytes);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
static void output_binary(void *buf, int len)
{
if (dump_binary) {
@@ -968,6 +984,10 @@ static struct io_track *find_track(struct per_dev_info *pdi, pid_t pid,
if (!iot->ppm)
iot->ppm = add_ppm_hash(pid, "unknown");
iot->sector = sector;
+ iot->allocation_time = -1ULL;
+ iot->queue_time = -1ULL;
+ iot->dispatch_time = -1ULL;
+ iot->completion_time = -1ULL;
track_rb_insert(pdi, iot);
}
@@ -1004,6 +1024,8 @@ static void log_track_getrq(struct per_dev_info *pdi, struct blk_io_trace *t)
return;
iot = find_track(pdi, t->pid, t->sector);
+ io_warn_unless(t, iot->allocation_time == -1ULL,
+ "confused about %s time", "allocation");
iot->allocation_time = t->time;
}
@@ -1019,6 +1041,8 @@ static void log_track_queue(struct per_dev_info *pdi, struct blk_io_trace *t)
return;
iot = find_track(pdi, t->pid, t->sector);
+ io_warn_unless(t, iot->dispatch_time == -1ULL,
+ "confused about %s time", "dispatch");
iot->dispatch_time = t->time;
}
@@ -1035,9 +1059,11 @@ static unsigned long long log_track_insert(struct per_dev_info *pdi,
return -1;
iot = find_track(pdi, t->pid, t->sector);
+ io_warn_unless(t, iot->queue_time == -1ULL,
+ "confused about %s time", "queue");
iot->queue_time = t->time;
- if (!iot->allocation_time)
+ if (iot->allocation_time == -1ULL)
return -1;
elapsed = iot->queue_time - iot->allocation_time;
@@ -1059,7 +1085,7 @@ static unsigned long long log_track_insert(struct per_dev_info *pdi,
static unsigned long long log_track_issue(struct per_dev_info *pdi,
struct blk_io_trace *t)
{
- unsigned long long elapsed;
+ unsigned long long elapsed = -1ULL;
struct io_track *iot;
if (!track_ios)
@@ -1076,10 +1102,13 @@ static unsigned long long log_track_issue(struct per_dev_info *pdi,
return -1;
}
+ io_warn_unless(t, iot->dispatch_time == -1ULL,
+ "confused about %s time", "dispatch");
iot->dispatch_time = t->time;
- elapsed = iot->dispatch_time - iot->queue_time;
+ if (iot->queue_time != -1ULL)
+ elapsed = iot->dispatch_time - iot->queue_time;
- if (per_process_stats) {
+ if (elapsed != -1ULL && per_process_stats) {
struct per_process_info *ppi = find_ppi(iot->ppm->pid);
int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
@@ -1096,7 +1125,7 @@ static unsigned long long log_track_issue(struct per_dev_info *pdi,
static unsigned long long log_track_complete(struct per_dev_info *pdi,
struct blk_io_trace *t)
{
- unsigned long long elapsed;
+ unsigned long long elapsed = -1ULL;
struct io_track *iot;
if (!track_ios)
@@ -1111,10 +1140,13 @@ static unsigned long long log_track_complete(struct per_dev_info *pdi,
return -1;
}
+ io_warn_unless(t, iot->completion_time == -1ULL,
+ "confused about %s time", "completion");
iot->completion_time = t->time;
- elapsed = iot->completion_time - iot->dispatch_time;
+ if (iot->dispatch_time != -1ULL)
+ elapsed = iot->completion_time - iot->dispatch_time;
- if (per_process_stats) {
+ if (elapsed != -1ULL && per_process_stats) {
struct per_process_info *ppi = find_ppi(iot->ppm->pid);
int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
--
1.8.3.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。