Skip to content

Commit b54bdb9

Browse files
ikegami-tigaw
authored andcommitted
logging: Split to output ioctl latency by log info level
This is for only output latency but not output other debugging info. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent df11a0e commit b54bdb9

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

util/logging.c

+16-12
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,22 @@ static void nvme_show_common(struct nvme_passthru_cmd *cmd)
6565
printf("timeout_ms : %08x\n", cmd->timeout_ms);
6666
}
6767

68-
static void nvme_show_command(struct nvme_passthru_cmd *cmd, int err, struct timeval start,
69-
struct timeval end)
68+
static void nvme_show_command(struct nvme_passthru_cmd *cmd, int err)
7069
{
7170
nvme_show_common(cmd);
7271
printf("result : %08x\n", cmd->result);
7372
printf("err : %d\n", err);
74-
printf("latency : %lu us\n",
75-
(end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec));
7673
}
7774

78-
static void nvme_show_command64(struct nvme_passthru_cmd64 *cmd, int err, struct timeval start,
79-
struct timeval end)
75+
static void nvme_show_command64(struct nvme_passthru_cmd64 *cmd, int err)
8076
{
8177
nvme_show_common((struct nvme_passthru_cmd *)cmd);
8278
printf("result : %"PRIx64"\n", (uint64_t)(uintptr_t)cmd->result);
8379
printf("err : %d\n", err);
80+
}
81+
82+
static void nvme_show_latency(struct timeval start, struct timeval end)
83+
{
8484
printf("latency : %lu us\n",
8585
(end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec));
8686
}
@@ -92,14 +92,16 @@ int nvme_submit_passthru(int fd, unsigned long ioctl_cmd,
9292
struct timeval end;
9393
int err;
9494

95-
if (log_level >= LOG_DEBUG)
95+
if (log_level >= LOG_INFO)
9696
gettimeofday(&start, NULL);
9797

9898
err = ioctl(fd, ioctl_cmd, cmd);
9999

100-
if (log_level >= LOG_DEBUG) {
100+
if (log_level >= LOG_INFO) {
101101
gettimeofday(&end, NULL);
102-
nvme_show_command(cmd, err, start, end);
102+
if (log_level >= LOG_DEBUG)
103+
nvme_show_command(cmd, err);
104+
nvme_show_latency(start, end);
103105
}
104106

105107
if (err >= 0 && result)
@@ -116,15 +118,17 @@ int nvme_submit_passthru64(int fd, unsigned long ioctl_cmd,
116118
struct timeval end;
117119
int err;
118120

119-
if (log_level >= LOG_DEBUG)
121+
if (log_level >= LOG_INFO)
120122
gettimeofday(&start, NULL);
121123

122124

123125
err = ioctl(fd, ioctl_cmd, cmd);
124126

125-
if (log_level >= LOG_DEBUG) {
127+
if (log_level >= LOG_INFO) {
126128
gettimeofday(&end, NULL);
127-
nvme_show_command64(cmd, err, start, end);
129+
if (log_level >= LOG_DEBUG)
130+
nvme_show_command64(cmd, err);
131+
nvme_show_latency(start, end);
128132
}
129133

130134
if (err >= 0 && result)

0 commit comments

Comments
 (0)