dmatest: add basic performance metrics

Add iops and throughput to the summary output.

Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
Dan Williams 2013-11-06 16:30:07 -08:00
parent e3b9c34731
commit 86727443a0
2 changed files with 37 additions and 2 deletions

View file

@ -77,5 +77,9 @@ the parens represents additional information, e.g. error code, error counter,
or status. A test thread also emits a summary line at completion listing the or status. A test thread also emits a summary line at completion listing the
number of tests executed, number that failed, and a result code. number of tests executed, number that failed, and a result code.
Example:
% dmesg | tail -n 1
dmatest: dma3chan0-copy0: summary 400000 tests, 0 failures iops: 61524 KB/s 246098 (0)
The details of a data miscompare error are also emitted, but do not follow the The details of a data miscompare error are also emitted, but do not follow the
above format. above format.

View file

@ -325,6 +325,29 @@ static void dbg_result(const char *err, unsigned int n, unsigned int src_off,
current->comm, n, err, src_off, dst_off, len, data); current->comm, n, err, src_off, dst_off, len, data);
} }
static unsigned long long dmatest_persec(s64 runtime, unsigned int val)
{
unsigned long long per_sec = 1000000;
if (runtime <= 0)
return 0;
/* drop precision until runtime is 32-bits */
while (runtime > UINT_MAX) {
runtime >>= 1;
per_sec <<= 1;
}
per_sec *= val;
do_div(per_sec, runtime);
return per_sec;
}
static unsigned long long dmatest_KBs(s64 runtime, unsigned long long len)
{
return dmatest_persec(runtime, len >> 10);
}
/* /*
* This function repeatedly tests DMA transfers of various lengths and * This function repeatedly tests DMA transfers of various lengths and
* offsets for a given operation type until it is told to exit by * offsets for a given operation type until it is told to exit by
@ -360,6 +383,9 @@ static int dmatest_func(void *data)
int src_cnt; int src_cnt;
int dst_cnt; int dst_cnt;
int i; int i;
ktime_t ktime;
s64 runtime = 0;
unsigned long long total_len = 0;
set_freezable(); set_freezable();
@ -417,6 +443,7 @@ static int dmatest_func(void *data)
*/ */
flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT; flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
ktime = ktime_get();
while (!kthread_should_stop() while (!kthread_should_stop()
&& !(params->iterations && total_tests >= params->iterations)) { && !(params->iterations && total_tests >= params->iterations)) {
struct dma_async_tx_descriptor *tx = NULL; struct dma_async_tx_descriptor *tx = NULL;
@ -464,6 +491,7 @@ static int dmatest_func(void *data)
len = (len >> align) << align; len = (len >> align) << align;
if (!len) if (!len)
len = 1 << align; len = 1 << align;
total_len += len;
for (i = 0; i < src_cnt; i++) { for (i = 0; i < src_cnt; i++) {
u8 *buf = thread->srcs[i] + src_off; u8 *buf = thread->srcs[i] + src_off;
@ -607,6 +635,7 @@ static int dmatest_func(void *data)
len, 0); len, 0);
} }
} }
runtime = ktime_us_delta(ktime_get(), ktime);
ret = 0; ret = 0;
for (i = 0; thread->dsts[i]; i++) for (i = 0; thread->dsts[i]; i++)
@ -621,8 +650,10 @@ err_srcbuf:
err_srcs: err_srcs:
kfree(pq_coefs); kfree(pq_coefs);
err_thread_type: err_thread_type:
pr_info("%s: terminating after %u tests, %u failures (status %d)\n", pr_info("%s: summary %u tests, %u failures %llu iops %llu KB/s (%d)\n",
current->comm, total_tests, failed_tests, ret); current->comm, total_tests, failed_tests,
dmatest_persec(runtime, total_tests),
dmatest_KBs(runtime, total_len), ret);
/* terminate all transfers on specified channels */ /* terminate all transfers on specified channels */
if (ret) if (ret)