From: Luis Chamberlain <mcgrof@kernel.org>
To: vkoul@kernel.org, chenxiang66@hisilicon.com,
m.szyprowski@samsung.com, robin.murphy@arm.com, leon@kernel.org,
jgg@nvidia.com, alex.williamson@redhat.com,
joel.granados@kernel.org
Cc: iommu@lists.linux.dev, dmaengine@vger.kernel.org,
linux-block@vger.kernel.org, gost.dev@samsung.com,
mcgrof@kernel.org
Subject: [PATCH 3/6] dmatest: move printing to its own routine
Date: Tue, 20 May 2025 15:39:10 -0700 [thread overview]
Message-ID: <20250520223913.3407136-4-mcgrof@kernel.org> (raw)
In-Reply-To: <20250520223913.3407136-1-mcgrof@kernel.org>
Move statistics printing to its own routine, and while at it, put
the test counters into the struct dmatest_thread for the streaming DMA
API to allow us to later add IOVA DMA API support and be able to
differentiate.
While at it, use a mutex to serialize output so we don't get garbled
messages between different threads.
This makes no functional changes other than serializing the output
and prepping us for IOVA DMA API support.
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/dma/dmatest.c | 77 ++++++++++++++++++++++++++++++++-----------
1 file changed, 58 insertions(+), 19 deletions(-)
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 921d89b4d2ed..b4c129e688e3 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -92,6 +92,8 @@ static bool polled;
module_param(polled, bool, 0644);
MODULE_PARM_DESC(polled, "Use polling for completion instead of interrupts");
+static DEFINE_MUTEX(stats_mutex);
+
/**
* struct dmatest_params - test parameters.
* @nobounce: prevent using swiotlb buffer
@@ -239,6 +241,12 @@ struct dmatest_thread {
bool done;
bool pending;
u8 *pq_coefs;
+
+ /* Streaming DMA statistics */
+ unsigned int streaming_tests;
+ unsigned int streaming_failures;
+ unsigned long long streaming_total_len;
+ ktime_t streaming_runtime;
};
struct dmatest_chan {
@@ -898,6 +906,30 @@ static int dmatest_do_dma_test(struct dmatest_thread *thread,
return ret;
}
+static void dmatest_print_detailed_stats(struct dmatest_thread *thread)
+{
+ unsigned long long streaming_iops, streaming_kbs;
+ s64 streaming_runtime_us;
+
+ mutex_lock(&stats_mutex);
+
+ streaming_runtime_us = ktime_to_us(thread->streaming_runtime);
+ streaming_iops = dmatest_persec(streaming_runtime_us, thread->streaming_tests);
+ streaming_kbs = dmatest_KBs(streaming_runtime_us, thread->streaming_total_len);
+
+ pr_info("=== %s: DMA Test Results ===\n", current->comm);
+
+ /* Streaming DMA statistics */
+ pr_info("%s: STREAMINMG DMA: %u tests, %u failures\n",
+ current->comm, thread->streaming_tests, thread->streaming_failures);
+ pr_info("%s: STREAMING DMA: %llu.%02llu iops, %llu KB/s, %lld us total\n",
+ current->comm, FIXPT_TO_INT(streaming_iops), FIXPT_GET_FRAC(streaming_iops),
+ streaming_kbs, streaming_runtime_us);
+
+ pr_info("=== %s: End Results ===\n", current->comm);
+ mutex_unlock(&stats_mutex);
+}
+
/*
* This function repeatedly tests DMA transfers of various lengths and
* offsets for a given operation type until it is told to exit by
@@ -921,20 +953,22 @@ static int dmatest_func(void *data)
unsigned int buf_size;
u8 align;
bool is_memset;
- unsigned int failed_tests = 0;
- unsigned int total_tests = 0;
- ktime_t ktime, start;
+ unsigned int total_iterations = 0;
+ ktime_t start_time, streaming_start;
ktime_t filltime = 0;
ktime_t comparetime = 0;
- s64 runtime = 0;
- unsigned long long total_len = 0;
- unsigned long long iops = 0;
int ret;
set_freezable();
smp_rmb();
thread->pending = false;
+ /* Initialize statistics */
+ thread->streaming_tests = 0;
+ thread->streaming_failures = 0;
+ thread->streaming_total_len = 0;
+ thread->streaming_runtime = 0;
+
/* Setup test parameters and allocate buffers */
ret = dmatest_setup_test(thread, &buf_size, &align, &is_memset);
if (ret)
@@ -942,34 +976,39 @@ static int dmatest_func(void *data)
set_user_nice(current, 10);
- ktime = start = ktime_get();
+ start_time = ktime_get();
while (!(kthread_should_stop() ||
- (params->iterations && total_tests >= params->iterations))) {
+ (params->iterations && total_iterations >= params->iterations))) {
+ /* Test streaming DMA path */
+ streaming_start = ktime_get();
ret = dmatest_do_dma_test(thread, buf_size, align, is_memset,
- &total_tests, &failed_tests, &total_len,
+ &thread->streaming_tests, &thread->streaming_failures,
+ &thread->streaming_total_len,
&filltime, &comparetime);
+ thread->streaming_runtime = ktime_add(thread->streaming_runtime,
+ ktime_sub(ktime_get(), streaming_start));
if (ret < 0)
break;
+
+ total_iterations++;
}
- ktime = ktime_sub(ktime_get(), ktime);
- ktime = ktime_sub(ktime, comparetime);
- ktime = ktime_sub(ktime, filltime);
- runtime = ktime_to_us(ktime);
+ /* Subtract fill and compare time from both paths */
+ thread->streaming_runtime = ktime_sub(thread->streaming_runtime,
+ ktime_divns(filltime, 2));
+ thread->streaming_runtime = ktime_sub(thread->streaming_runtime,
+ ktime_divns(comparetime, 2));
ret = 0;
dmatest_cleanup_test(thread);
err_thread_type:
- iops = dmatest_persec(runtime, total_tests);
- pr_info("%s: summary %u tests, %u failures %llu.%02llu iops %llu KB/s (%d)\n",
- current->comm, total_tests, failed_tests,
- FIXPT_TO_INT(iops), FIXPT_GET_FRAC(iops),
- dmatest_KBs(runtime, total_len), ret);
+ /* Print detailed statistics */
+ dmatest_print_detailed_stats(thread);
/* terminate all transfers on specified channels */
- if (ret || failed_tests)
+ if (ret || (thread->streaming_failures))
dmaengine_terminate_sync(chan);
thread->done = true;
--
2.47.2
next prev parent reply other threads:[~2025-05-20 22:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 22:39 [PATCH 0/6] dma: fake-dma and IOVA tests Luis Chamberlain
2025-05-20 22:39 ` [PATCH 1/6] fake-dma: add fake dma engine driver Luis Chamberlain
2025-05-21 14:20 ` Robin Murphy
2025-05-21 17:07 ` Luis Chamberlain
2025-05-22 11:18 ` Marek Szyprowski
2025-05-22 16:59 ` Luis Chamberlain
2025-05-22 19:38 ` Luis Chamberlain
2025-05-21 23:40 ` kernel test robot
2025-05-20 22:39 ` [PATCH 2/6] dmatest: split dmatest_func() into helpers Luis Chamberlain
2025-05-20 22:39 ` Luis Chamberlain [this message]
2025-05-21 14:41 ` [PATCH 3/6] dmatest: move printing to its own routine Robin Murphy
2025-05-21 17:10 ` Luis Chamberlain
2025-05-21 22:26 ` kernel test robot
2025-05-20 22:39 ` [PATCH 4/6] dmatest: add IOVA tests Luis Chamberlain
2025-05-20 22:39 ` [PATCH 5/6] dma-mapping: benchmark: move validation parameters into a helper Luis Chamberlain
2025-05-20 22:39 ` [PATCH 6/6] dma-mapping: benchmark: add IOVA support Luis Chamberlain
2025-05-21 11:58 ` kernel test robot
2025-05-21 16:08 ` Robin Murphy
2025-05-21 17:17 ` Luis Chamberlain
2025-05-21 11:17 ` [PATCH 0/6] dma: fake-dma and IOVA tests Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250520223913.3407136-4-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=alex.williamson@redhat.com \
--cc=chenxiang66@hisilicon.com \
--cc=dmaengine@vger.kernel.org \
--cc=gost.dev@samsung.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joel.granados@kernel.org \
--cc=leon@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=robin.murphy@arm.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox