Skip to content

Commit cddb82d

Browse files
anna-marialxKAGA-KOKO
authored andcommitted
vdso/gettimeofday: Prepare introduction of struct vdso_clock
To support multiple PTP clocks, the VDSO data structure needs to be reworked. All clock specific data will end up in struct vdso_clock and in struct vdso_time_data there will be array of VDSO clocks. At the moment, vdso_clock is simply a define which maps vdso_clock to vdso_time_data. Prepare all functions which need the pointer to the vdso_clock array to work correctly after introducing the new struct. Where applicable, replace the struct vdso_time_data pointer by a struct vdso_clock pointer. No functional change. Signed-off-by: Anna-Maria Behnsen <[email protected]> Signed-off-by: Nam Cao <[email protected]> Signed-off-by: Thomas Weißschuh <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent e15bf9e commit cddb82d

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

lib/vdso/gettimeofday.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ static __always_inline int
257257
__cvdso_clock_gettime_common(const struct vdso_time_data *vd, clockid_t clock,
258258
struct __kernel_timespec *ts)
259259
{
260+
const struct vdso_clock *vc = vd;
260261
u32 msk;
261262

262263
/* Check for negative values or invalid clocks */
@@ -269,15 +270,15 @@ __cvdso_clock_gettime_common(const struct vdso_time_data *vd, clockid_t clock,
269270
*/
270271
msk = 1U << clock;
271272
if (likely(msk & VDSO_HRES))
272-
vd = &vd[CS_HRES_COARSE];
273+
vc = &vc[CS_HRES_COARSE];
273274
else if (msk & VDSO_COARSE)
274-
return do_coarse(&vd[CS_HRES_COARSE], clock, ts);
275+
return do_coarse(&vc[CS_HRES_COARSE], clock, ts);
275276
else if (msk & VDSO_RAW)
276-
vd = &vd[CS_RAW];
277+
vc = &vc[CS_RAW];
277278
else
278279
return -1;
279280

280-
return do_hres(vd, clock, ts);
281+
return do_hres(vc, clock, ts);
281282
}
282283

283284
static __maybe_unused int
@@ -328,11 +329,12 @@ static __maybe_unused int
328329
__cvdso_gettimeofday_data(const struct vdso_time_data *vd,
329330
struct __kernel_old_timeval *tv, struct timezone *tz)
330331
{
332+
const struct vdso_clock *vc = vd;
331333

332334
if (likely(tv != NULL)) {
333335
struct __kernel_timespec ts;
334336

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

338340
tv->tv_sec = ts.tv_sec;
@@ -341,7 +343,7 @@ __cvdso_gettimeofday_data(const struct vdso_time_data *vd,
341343

342344
if (unlikely(tz != NULL)) {
343345
if (IS_ENABLED(CONFIG_TIME_NS) &&
344-
vd->clock_mode == VDSO_CLOCKMODE_TIMENS)
346+
vc->clock_mode == VDSO_CLOCKMODE_TIMENS)
345347
vd = __arch_get_vdso_u_timens_data(vd);
346348

347349
tz->tz_minuteswest = vd[CS_HRES_COARSE].tz_minuteswest;
@@ -361,13 +363,16 @@ __cvdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
361363
static __maybe_unused __kernel_old_time_t
362364
__cvdso_time_data(const struct vdso_time_data *vd, __kernel_old_time_t *time)
363365
{
366+
const struct vdso_clock *vc = vd;
364367
__kernel_old_time_t t;
365368

366369
if (IS_ENABLED(CONFIG_TIME_NS) &&
367-
vd->clock_mode == VDSO_CLOCKMODE_TIMENS)
370+
vc->clock_mode == VDSO_CLOCKMODE_TIMENS) {
368371
vd = __arch_get_vdso_u_timens_data(vd);
372+
vc = vd;
373+
}
369374

370-
t = READ_ONCE(vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec);
375+
t = READ_ONCE(vc[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec);
371376

372377
if (time)
373378
*time = t;
@@ -386,6 +391,7 @@ static __maybe_unused
386391
int __cvdso_clock_getres_common(const struct vdso_time_data *vd, clockid_t clock,
387392
struct __kernel_timespec *res)
388393
{
394+
const struct vdso_clock *vc = vd;
389395
u32 msk;
390396
u64 ns;
391397

@@ -394,7 +400,7 @@ int __cvdso_clock_getres_common(const struct vdso_time_data *vd, clockid_t clock
394400
return -1;
395401

396402
if (IS_ENABLED(CONFIG_TIME_NS) &&
397-
vd->clock_mode == VDSO_CLOCKMODE_TIMENS)
403+
vc->clock_mode == VDSO_CLOCKMODE_TIMENS)
398404
vd = __arch_get_vdso_u_timens_data(vd);
399405

400406
/*

0 commit comments

Comments
 (0)