Skip to content

Commit 8672744

Browse files
committed
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>
1 parent e3b9c34 commit 8672744

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

Documentation/dmatest.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,9 @@ the parens represents additional information, e.g. error code, error counter,
7777
or status. A test thread also emits a summary line at completion listing the
7878
number of tests executed, number that failed, and a result code.
7979

80+
Example:
81+
% dmesg | tail -n 1
82+
dmatest: dma3chan0-copy0: summary 400000 tests, 0 failures iops: 61524 KB/s 246098 (0)
83+
8084
The details of a data miscompare error are also emitted, but do not follow the
8185
above format.

drivers/dma/dmatest.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,29 @@ static void dbg_result(const char *err, unsigned int n, unsigned int src_off,
325325
current->comm, n, err, src_off, dst_off, len, data);
326326
}
327327

328+
static unsigned long long dmatest_persec(s64 runtime, unsigned int val)
329+
{
330+
unsigned long long per_sec = 1000000;
331+
332+
if (runtime <= 0)
333+
return 0;
334+
335+
/* drop precision until runtime is 32-bits */
336+
while (runtime > UINT_MAX) {
337+
runtime >>= 1;
338+
per_sec <<= 1;
339+
}
340+
341+
per_sec *= val;
342+
do_div(per_sec, runtime);
343+
return per_sec;
344+
}
345+
346+
static unsigned long long dmatest_KBs(s64 runtime, unsigned long long len)
347+
{
348+
return dmatest_persec(runtime, len >> 10);
349+
}
350+
328351
/*
329352
* This function repeatedly tests DMA transfers of various lengths and
330353
* offsets for a given operation type until it is told to exit by
@@ -360,6 +383,9 @@ static int dmatest_func(void *data)
360383
int src_cnt;
361384
int dst_cnt;
362385
int i;
386+
ktime_t ktime;
387+
s64 runtime = 0;
388+
unsigned long long total_len = 0;
363389

364390
set_freezable();
365391

@@ -417,6 +443,7 @@ static int dmatest_func(void *data)
417443
*/
418444
flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
419445

446+
ktime = ktime_get();
420447
while (!kthread_should_stop()
421448
&& !(params->iterations && total_tests >= params->iterations)) {
422449
struct dma_async_tx_descriptor *tx = NULL;
@@ -464,6 +491,7 @@ static int dmatest_func(void *data)
464491
len = (len >> align) << align;
465492
if (!len)
466493
len = 1 << align;
494+
total_len += len;
467495

468496
for (i = 0; i < src_cnt; i++) {
469497
u8 *buf = thread->srcs[i] + src_off;
@@ -607,6 +635,7 @@ static int dmatest_func(void *data)
607635
len, 0);
608636
}
609637
}
638+
runtime = ktime_us_delta(ktime_get(), ktime);
610639

611640
ret = 0;
612641
for (i = 0; thread->dsts[i]; i++)
@@ -621,8 +650,10 @@ static int dmatest_func(void *data)
621650
err_srcs:
622651
kfree(pq_coefs);
623652
err_thread_type:
624-
pr_info("%s: terminating after %u tests, %u failures (status %d)\n",
625-
current->comm, total_tests, failed_tests, ret);
653+
pr_info("%s: summary %u tests, %u failures %llu iops %llu KB/s (%d)\n",
654+
current->comm, total_tests, failed_tests,
655+
dmatest_persec(runtime, total_tests),
656+
dmatest_KBs(runtime, total_len), ret);
626657

627658
/* terminate all transfers on specified channels */
628659
if (ret)

0 commit comments

Comments
 (0)