[PATCH 12/13] HW-latency: Add sample unit in sample data
From: Luming Yu
Date: Sun Nov 04 2012 - 08:00:50 EST
ns and us
Signed-off-by: Luming Yu <luming.yu@xxxxxxxxx>
---
drivers/misc/hw_latency_test.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/misc/hw_latency_test.c b/drivers/misc/hw_latency_test.c
index bcce8f4..0b79b5e 100644
--- a/drivers/misc/hw_latency_test.c
+++ b/drivers/misc/hw_latency_test.c
@@ -60,6 +60,7 @@ struct sample {
u64 duration;
struct timespec timestamp;
u64 addr;
+ u8 unit; /*0: ns 1:us*/
unsigned long lost;
};
@@ -130,7 +131,7 @@ static struct sample *buffer_get_sample(struct sample *sample)
return sample;
}
-static int buffer_add_sample(u64 sample)
+static int buffer_add_sample(u64 sample, u8 unit)
{
int ret = 0;
unsigned int cpu = smp_processor_id();
@@ -144,6 +145,7 @@ static int buffer_add_sample(u64 sample)
s.duration = sample;
s.timestamp = CURRENT_TIME;
s.addr = (u64) __start;
+ s.unit = unit;
ret = __buffer_add_sample(&s);
if (sample > data.max_sample)
@@ -184,7 +186,7 @@ static int get_random_bytes_sample(void *unused)
} while (total <= data.sample_width);
- ret = buffer_add_sample(sample);
+ ret = buffer_add_sample(sample, 1);
out:
kfree(buffer);
return ret;
@@ -219,7 +221,7 @@ static int get_freq_sample(void *unused)
} while (total <= data.sample_width);
- ret = buffer_add_sample(sample);
+ ret = buffer_add_sample(sample, 1);
out:
return ret;
}
@@ -252,7 +254,7 @@ static int get_tsc_sample(void *unused)
} while (total <= data.sample_width);
- ret = buffer_add_sample(sample);
+ ret = buffer_add_sample(sample, 0);
out:
return ret;
}
@@ -289,7 +291,7 @@ static int get_mem_sample(void *unused)
} while (total <= data.sample_width);
- ret = buffer_add_sample(sample);
+ ret = buffer_add_sample(sample, 0);
out:
return ret;
}
@@ -669,11 +671,12 @@ static ssize_t debug_sample_fread(struct file *filp, char __user *ubuf,
goto out;
}
}
- len = snprintf(buf, sizeof(buf), "[%d]%010lu.%010lu\t%llu\t[%llx]\n",
+ len = snprintf(buf, sizeof(buf), "[%d]%010lu.%010lu\t%llu%2s\t[%llx]\n",
sample->cpu,
sample->timestamp.tv_sec,
sample->timestamp.tv_nsec,
sample->duration,
+ sample->unit ? "us":"ns",
sample->addr);
if (len > cnt)
goto out;
--
1.7.12.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/