DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Baineng Shou" <shoubaineng@gmail.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH] dmaengine: dmatest: Add optional per-stage latency profiling
Date: Tue, 01 Dec 2026 03:08:31 +0000	[thread overview]
Message-ID: <sashiko-outbox-242402@kernel.org> (raw)
In-Reply-To: <20261201025813.2994236-1-shoubaineng@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] dmaengine: dmatest: missing Signed-off-by trailer in commit
  message
- [Medium] dmaengine: dmatest: shared-channel race on PROFILE_EXECUTE in
  dmatest_func()
--

commit 62ef94a524c9e2bd5d0c52778b817c95279c83ab
Author: Baineng Shou <shoubaineng@gmail.com>

> dmaengine: dmatest: Add optional per-stage latency profiling
>
> The aggregate dmatest throughput does not show whether time is spent in
> DMA mapping, descriptor preparation, execution or completion delivery.
> This makes it difficult to investigate a low copy rate without adding
> ad-hoc instrumentation to a test client or a controller driver.
>
> Add a profile parameter to accumulate six consecutive latency intervals
> per test thread: map, prep, submit, issue-to-callback, callback-to-wait-
> return, and status-check/unmap. Report the average latency, elapsed time
> and percentage for each interval after the existing summary, together
> with the minimum, average and maximum map-to-unmap latency. Derive the
> effective and execution rates from aggregate bytes and aggregate time.
>
> Publish the callback timestamp before the completion flag using release
> and acquire ordering. Include issue_pending() in the issue-to-callback
> interval so that a callback running before the issue call returns does
> not create overlapping intervals. Stop accumulating samples after the
> first transfer error, verification failure or invalid timestamp sequence
> to avoid attributing late callbacks to subsequent samples. Leave the
> existing test flow and error handling in place.
>
> Keep profiling disabled by default and print only per-thread totals at
> test completion. Preserve the existing summary and verbose output, and
> report profiling as unavailable in polled mode. Document the boundaries,
> the accounting rules and the added measurement overhead. In particular,
> execution latency includes queueing, interrupt and driver completion
> processing; neither rate represents hardware-only or whole-run bandwidth.

[Severity: High]
The commit message is missing a Signed-off-by: trailer certifying the
Developer's Certificate of Origin, as required by
Documentation/process/submitting-patches.rst.

> diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
> index 2ae3469397f37..e692b41759d67 100644
> --- a/drivers/dma/dmatest.c
> +++ b/drivers/dma/dmatest.c

[ ... ]

> @@ -826,6 +960,8 @@ static int dmatest_func(void *data)
>  			tx->callback = dmatest_callback;
>  			tx->callback_param = done;
>  		}
> +		if (do_profile)
> +			ps.ts[PROFILE_SUBMIT] = ktime_get_ns();
>  		cookie = tx->tx_submit(tx);
>  
>  		if (dma_submit_error(cookie)) {
> @@ -841,12 +977,17 @@ static int dmatest_func(void *data)
>  			if (status == DMA_COMPLETE)
>  				done->done = true;
>  		} else {
> +			if (do_profile)
> +				ps.ts[PROFILE_EXECUTE] = ktime_get_ns();
>  			dma_async_issue_pending(chan);

[Severity: Medium]
Can a sibling thread sharing chan issue this thread's submitted descriptor
before ps.ts[PROFILE_EXECUTE] is recorded?

When multiple dmatest threads share a channel (via threads_per_chan > 1 or
when dmatest_add_channel() spawns threads for multiple transaction types on
the same channel), tx->tx_submit(tx) places the armed descriptor on the
shared channel queue before ps.ts[PROFILE_EXECUTE] is captured:

Thread 0                          Thread 1 (same chan)      <IRQ / tasklet>
dmatest_func()                    dmatest_func()
  tx->callback = dmatest_callback
  tx->tx_submit(tx)
                                  dma_async_issue_pending(chan)
                                                            dmatest_callback()
                                                              callback_ns =
                                                                ktime_get_ns()
  ps.ts[PROFILE_EXECUTE] =
    ktime_get_ns()  <-- after callback_ns

Because ps.ts[PROFILE_WAKEUP] is later set to done->callback_ns,
ps.ts[PROFILE_WAKEUP] < ps.ts[PROFILE_EXECUTE].  dmatest_profile_add() then
treats the sample as having an invalid timestamp sequence, sets
stats->aborted = true, and stops profiling for the remainder of the thread's
run.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201025813.2994236-1-shoubaineng@gmail.com?part=1

      reply	other threads:[~2026-12-01  3:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  2:58 [PATCH] dmaengine: dmatest: Add optional per-stage latency profiling Baineng Shou
2026-12-01  3:08 ` sashiko-bot [this message]

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=sashiko-outbox-242402@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shoubaineng@gmail.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