Skip to content

Commit 8c3f5cb

Browse files
anna-marialxKAGA-KOKO
authored andcommitted
vdso/gettimeofday: Prepare do_coarse_timens() for 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 for the rework of these structures by adding a struct vdso_clock pointer argument to do_coarse_time_ns(), and replace the struct vdso_time_data pointer with the new pointer argument where applicable. 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 70067ae commit 8c3f5cb

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

lib/vdso/gettimeofday.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,21 +193,25 @@ int do_hres(const struct vdso_time_data *vd, const struct vdso_clock *vc,
193193
}
194194

195195
#ifdef CONFIG_TIME_NS
196-
static __always_inline int do_coarse_timens(const struct vdso_time_data *vdns, clockid_t clk,
197-
struct __kernel_timespec *ts)
196+
static __always_inline
197+
int do_coarse_timens(const struct vdso_time_data *vdns, const struct vdso_clock *vcns,
198+
clockid_t clk, struct __kernel_timespec *ts)
198199
{
199200
const struct vdso_time_data *vd = __arch_get_vdso_u_timens_data(vdns);
200-
const struct vdso_timestamp *vdso_ts = &vd->basetime[clk];
201-
const struct timens_offset *offs = &vdns->offset[clk];
201+
const struct timens_offset *offs = &vcns->offset[clk];
202+
const struct vdso_timestamp *vdso_ts;
203+
const struct vdso_clock *vc = vd;
202204
u64 nsec;
203205
s64 sec;
204206
s32 seq;
205207

208+
vdso_ts = &vc->basetime[clk];
209+
206210
do {
207-
seq = vdso_read_begin(vd);
211+
seq = vdso_read_begin(vc);
208212
sec = vdso_ts->sec;
209213
nsec = vdso_ts->nsec;
210-
} while (unlikely(vdso_read_retry(vd, seq)));
214+
} while (unlikely(vdso_read_retry(vc, seq)));
211215

212216
/* Add the namespace offset */
213217
sec += offs->sec;
@@ -222,8 +226,9 @@ static __always_inline int do_coarse_timens(const struct vdso_time_data *vdns, c
222226
return 0;
223227
}
224228
#else
225-
static __always_inline int do_coarse_timens(const struct vdso_time_data *vdns, clockid_t clk,
226-
struct __kernel_timespec *ts)
229+
static __always_inline
230+
int do_coarse_timens(const struct vdso_time_data *vdns, const struct vdso_clock *vcns,
231+
clockid_t clk, struct __kernel_timespec *ts)
227232
{
228233
return -1;
229234
}
@@ -244,7 +249,7 @@ int do_coarse(const struct vdso_time_data *vd, const struct vdso_clock *vc,
244249
while ((seq = READ_ONCE(vc->seq)) & 1) {
245250
if (IS_ENABLED(CONFIG_TIME_NS) &&
246251
vc->clock_mode == VDSO_CLOCKMODE_TIMENS)
247-
return do_coarse_timens(vc, clk, ts);
252+
return do_coarse_timens(vd, vc, clk, ts);
248253
cpu_relax();
249254
}
250255
smp_rmb();

0 commit comments

Comments
 (0)