diff mbox

[08/10] dmatest: add basic performance metrics

Message ID 20131107021823.15120.92673.stgit@viggo.jf.intel.com (mailing list archive)
State Accepted
Commit 86727443a04fdb25397041188efd2527f2b7237b
Delegated to: Dan Williams
Headers show

Commit Message

Dan Williams Nov. 7, 2013, 2:18 a.m. UTC
Add iops and throughput to the summary output.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 Documentation/dmatest.txt |    4 ++++
 drivers/dma/dmatest.c     |   35 +++++++++++++++++++++++++++++++++--
 2 files changed, 37 insertions(+), 2 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Andy Shevchenko Nov. 12, 2013, 12:09 p.m. UTC | #1
On Wed, 2013-11-06 at 18:18 -0800, Dan Williams wrote:
> 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>
> ---
>  Documentation/dmatest.txt |    4 ++++
>  drivers/dma/dmatest.c     |   35 +++++++++++++++++++++++++++++++++--
>  2 files changed, 37 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/dmatest.txt b/Documentation/dmatest.txt
> index 3bf5f915212f..d89628331c2a 100644
> --- a/Documentation/dmatest.txt
> +++ b/Documentation/dmatest.txt
> @@ -73,5 +73,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
>  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
>  above format.
> diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
> index d07b73275d0f..26b502069638 100644
> --- a/drivers/dma/dmatest.c
> +++ b/drivers/dma/dmatest.c
> @@ -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);
>  }
>  
> +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
>   * 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			dst_cnt;
>  	int			i;
> +	ktime_t			ktime;
> +	s64			runtime = 0;
> +	unsigned long long	total_len = 0;
>  
>  	set_freezable();
>  
> @@ -417,6 +443,7 @@ static int dmatest_func(void *data)
>  	 */
>  	flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
>  
> +	ktime = ktime_get();
>  	while (!kthread_should_stop()
>  	       && !(params->iterations && total_tests >= params->iterations)) {
>  		struct dma_async_tx_descriptor *tx = NULL;
> @@ -464,6 +491,7 @@ static int dmatest_func(void *data)
>  		len = (len >> align) << align;
>  		if (!len)
>  			len = 1 << align;
> +		total_len += len;
>  
>  		for (i = 0; i < src_cnt; i++) {
>  			u8 *buf = thread->srcs[i] + src_off;
> @@ -607,6 +635,7 @@ static int dmatest_func(void *data)
>  				   len, 0);
>  		}
>  	}
> +	runtime = ktime_us_delta(ktime_get(), ktime);
>  
>  	ret = 0;
>  	for (i = 0; thread->dsts[i]; i++)
> @@ -621,8 +650,10 @@ err_srcbuf:
>  err_srcs:
>  	kfree(pq_coefs);
>  err_thread_type:
> -	pr_info("%s: terminating after %u tests, %u failures (status %d)\n",
> -		current->comm, total_tests, failed_tests, ret);
> +	pr_info("%s: summary %u tests, %u failures %llu iops %llu KB/s (%d)\n",
> +		current->comm, total_tests, failed_tests,
> +		dmatest_persec(runtime, total_tests),
> +		dmatest_KBs(runtime, total_len), ret);
>  
>  	/* terminate all transfers on specified channels */
>  	if (ret)
>
diff mbox

Patch

diff --git a/Documentation/dmatest.txt b/Documentation/dmatest.txt
index 3bf5f915212f..d89628331c2a 100644
--- a/Documentation/dmatest.txt
+++ b/Documentation/dmatest.txt
@@ -73,5 +73,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
 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
 above format.
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index d07b73275d0f..26b502069638 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -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);
 }
 
+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
  * 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			dst_cnt;
 	int			i;
+	ktime_t			ktime;
+	s64			runtime = 0;
+	unsigned long long	total_len = 0;
 
 	set_freezable();
 
@@ -417,6 +443,7 @@  static int dmatest_func(void *data)
 	 */
 	flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
 
+	ktime = ktime_get();
 	while (!kthread_should_stop()
 	       && !(params->iterations && total_tests >= params->iterations)) {
 		struct dma_async_tx_descriptor *tx = NULL;
@@ -464,6 +491,7 @@  static int dmatest_func(void *data)
 		len = (len >> align) << align;
 		if (!len)
 			len = 1 << align;
+		total_len += len;
 
 		for (i = 0; i < src_cnt; i++) {
 			u8 *buf = thread->srcs[i] + src_off;
@@ -607,6 +635,7 @@  static int dmatest_func(void *data)
 				   len, 0);
 		}
 	}
+	runtime = ktime_us_delta(ktime_get(), ktime);
 
 	ret = 0;
 	for (i = 0; thread->dsts[i]; i++)
@@ -621,8 +650,10 @@  err_srcbuf:
 err_srcs:
 	kfree(pq_coefs);
 err_thread_type:
-	pr_info("%s: terminating after %u tests, %u failures (status %d)\n",
-		current->comm, total_tests, failed_tests, ret);
+	pr_info("%s: summary %u tests, %u failures %llu iops %llu KB/s (%d)\n",
+		current->comm, total_tests, failed_tests,
+		dmatest_persec(runtime, total_tests),
+		dmatest_KBs(runtime, total_len), ret);
 
 	/* terminate all transfers on specified channels */
 	if (ret)