Thread (39 messages) 39 messages, 7 authors, 2025-08-20

Re: [PATCH 06/14] vdso/gettimeofday: Return bool from clock_gettime() helpers

From: Marek Szyprowski <m.szyprowski@samsung.com>
Date: 2025-07-09 08:04:25
Also in: linux-arch, linux-kselftest, lkml

On 09.07.2025 09:34, Thomas Weißschuh wrote:
On Tue, Jul 08, 2025 at 05:49:18PM +0200, Marek Szyprowski wrote:
quoted
On 08.07.2025 17:17, Marek Szyprowski wrote:
quoted
On 01.07.2025 10:58, Thomas Weißschuh wrote:
quoted
The internal helpers are effectively using boolean results,
while pretending to use error numbers.

Switch the return type to bool for more clarity.

Signed-off-by: Thomas Weißschuh <redacted>
---
   lib/vdso/gettimeofday.c | 58
+++++++++++++++++++++++++------------------------
   1 file changed, 30 insertions(+), 28 deletions(-)
This patch landed in today's linux-next as commit fcc8e46f768f
("vdso/gettimeofday: Return bool from clock_gettime() helpers"). In my
tests I found that it causes serious problem with hwclock operation on
some of my ARM 32bit test boards. I observe that calling "hwclock -w
-f /dev/rtc0" never ends on those boards. Disabling vdso support (by
removing ARM architected timer) fixes this issue.
I spent some time analyzing the code refactored in this patch and it
looks that the following change is missing:
Thanks for the report and investigation!
quoted
diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
index c5266532a097..7e79b02839b0 100644
--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -344,7 +344,7 @@ __cvdso_gettimeofday_data(const struct
vdso_time_data *vd,
          if (likely(tv != NULL)) {
                  struct __kernel_timespec ts;

-               if (do_hres(vd, &vc[CS_HRES_COARSE], CLOCK_REALTIME, &ts))
+               if (!do_hres(vd, &vc[CS_HRES_COARSE], CLOCK_REALTIME, &ts))
                          return gettimeofday_fallback(tv, tz);

                  tv->tv_sec = ts.tv_sec;


In my tests this fixed the hwclock issue on the mentioned boards.
This fix looks correct to me.


tglx:

Are you going to fold the fix into the commit or do you want a proper patch?


Marek:

If a new patch is required, do you want to send it? You found and fixed the
issue after all. If not, I'll take care of it.
If it is possible to fold it into original patch then go ahead, it would 
make less noise imho. If you need a formal patch, I can send it in a few 
minutes.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help