Commit 86727443a04fdb25397041188efd2527f2b7237b

Authored by Dan Williams
1 parent e3b9c34731

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>

Showing 2 changed files with 37 additions and 2 deletions Side-by-side Diff

Documentation/dmatest.txt
... ... @@ -77,6 +77,10 @@
77 77 or status. A test thread also emits a summary line at completion listing the
78 78 number of tests executed, number that failed, and a result code.
79 79  
  80 +Example:
  81 + % dmesg | tail -n 1
  82 + dmatest: dma3chan0-copy0: summary 400000 tests, 0 failures iops: 61524 KB/s 246098 (0)
  83 +
80 84 The details of a data miscompare error are also emitted, but do not follow the
81 85 above format.
drivers/dma/dmatest.c
... ... @@ -325,6 +325,29 @@
325 325 current->comm, n, err, src_off, dst_off, len, data);
326 326 }
327 327  
  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 +
328 351 /*
329 352 * This function repeatedly tests DMA transfers of various lengths and
330 353 * offsets for a given operation type until it is told to exit by
... ... @@ -360,6 +383,9 @@
360 383 int src_cnt;
361 384 int dst_cnt;
362 385 int i;
  386 + ktime_t ktime;
  387 + s64 runtime = 0;
  388 + unsigned long long total_len = 0;
363 389  
364 390 set_freezable();
365 391  
... ... @@ -417,6 +443,7 @@
417 443 */
418 444 flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
419 445  
  446 + ktime = ktime_get();
420 447 while (!kthread_should_stop()
421 448 && !(params->iterations && total_tests >= params->iterations)) {
422 449 struct dma_async_tx_descriptor *tx = NULL;
... ... @@ -464,6 +491,7 @@
464 491 len = (len >> align) << align;
465 492 if (!len)
466 493 len = 1 << align;
  494 + total_len += len;
467 495  
468 496 for (i = 0; i < src_cnt; i++) {
469 497 u8 *buf = thread->srcs[i] + src_off;
... ... @@ -607,6 +635,7 @@
607 635 len, 0);
608 636 }
609 637 }
  638 + runtime = ktime_us_delta(ktime_get(), ktime);
610 639  
611 640 ret = 0;
612 641 for (i = 0; thread->dsts[i]; i++)
... ... @@ -621,8 +650,10 @@
621 650 err_srcs:
622 651 kfree(pq_coefs);
623 652 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);
626 657  
627 658 /* terminate all transfers on specified channels */
628 659 if (ret)