From: Graeme Harker <graeme.harker@gmail.com>
To: fthain@linux-m68k.org
Cc: geert@linux-m68k.org, linux-m68k@lists.linux-m68k.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] m68k: delay: Fix rounding of short udelay() and ndelay()
Date: Wed, 18 Nov 2026 21:00:08 +0000 [thread overview]
Message-ID: <20261118210008.927764-1-graeme.harker@gmail.com> (raw)
In-Reply-To: <ae768ed3-a517-3223-5c86-a1599ff6c8e5@linux-m68k.org>
Hi Finn,
Thanks for testing it on real hardware, and with a better method than
mine.
> Which clocksource driver are you using for jiffies?
The jiffies clocksource itself; the board has no sub-tick clocksource
yet. The tick is a periodic clock_event_device on the DUART's
counter/timer (GENERIC_CLOCKEVENTS, not LEGACY_TIMER_TICK), and my
figures were 1 s of each call timed by jiffies with interrupts on, so
they include the tick's own cost. Yours are the better numbers.
> ndelay(400) 536E-09 -> 239E-09 seconds
I think the patched ndelay() count has wrapped your 16-bit timer. The
patched ndelay(400) asks __delay() for at least 466 ns of calibrated
loops whatever loops_per_jiffy is (8000 * loops_per_jiffy * 25 / 2^32
loops, plus the one __delay() adds), and it now does a mulu.l on every
call, which the old code did not (its arithmetic is plain C, so GCC can
hoist it out of your unrolled loop). If a call takes about 1.08 us,
100000 calls take 107.6 ms, more than the 83.7 ms that T2 can count at
783360 Hz, and what is left after one wrap is 23.9 ms, or 239 ns a
call.
Could you try ndelay(400) with 40000 invocations instead of 100000? If
I'm right it should come out at about 1.08 us. That would mean it is
longer than before, not shorter. As the commit message says, ndelay()
now pays for the 64-bit multiply, so very short ndelay()s cost more.
If that cost matters on the 040, I could keep the old ndelay() and
only fix udelay().
Your udelay(1000) at 978 us is still 2 % short with interrupts off. I
believe that is calibrate_delay() running with the tick enabled, so the
tick's time is counted as loop time. That is separate from this patch,
and I have left it alone.
Graeme
prev parent reply other threads:[~2026-11-18 21:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 14:38 Graeme Harker
2026-11-18 9:52 ` Finn Thain
2026-11-18 21:00 ` Graeme Harker [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=20261118210008.927764-1-graeme.harker@gmail.com \
--to=graeme.harker@gmail.com \
--cc=fthain@linux-m68k.org \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.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
all inboxes | Powered by JetHome®