Skip to content

Commit 83a2a6b

Browse files
anna-marialxKAGA-KOKO
authored andcommitted
vdso/gettimeofday: Prepare do_hres_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_hres_timens(), 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 64c3613 commit 83a2a6b

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

lib/vdso/gettimeofday.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,36 +81,36 @@ const struct vdso_time_data *__arch_get_vdso_u_timens_data(const struct vdso_tim
8181
}
8282
#endif /* CONFIG_GENERIC_VDSO_DATA_STORE */
8383

84-
static __always_inline int do_hres_timens(const struct vdso_time_data *vdns, clockid_t clk,
85-
struct __kernel_timespec *ts)
84+
static __always_inline
85+
int do_hres_timens(const struct vdso_time_data *vdns, const struct vdso_clock *vcns,
86+
clockid_t clk, struct __kernel_timespec *ts)
8687
{
87-
const struct timens_offset *offs = &vdns->offset[clk];
88+
const struct vdso_time_data *vd = __arch_get_vdso_u_timens_data(vdns);
89+
const struct timens_offset *offs = &vcns->offset[clk];
8890
const struct vdso_timestamp *vdso_ts;
89-
const struct vdso_time_data *vd;
91+
const struct vdso_clock *vc = vd;
9092
u64 cycles, ns;
9193
u32 seq;
9294
s64 sec;
9395

94-
vd = vdns - (clk == CLOCK_MONOTONIC_RAW ? CS_RAW : CS_HRES_COARSE);
95-
vd = __arch_get_vdso_u_timens_data(vd);
9696
if (clk != CLOCK_MONOTONIC_RAW)
97-
vd = &vd[CS_HRES_COARSE];
97+
vc = &vc[CS_HRES_COARSE];
9898
else
99-
vd = &vd[CS_RAW];
100-
vdso_ts = &vd->basetime[clk];
99+
vc = &vc[CS_RAW];
100+
vdso_ts = &vc->basetime[clk];
101101

102102
do {
103-
seq = vdso_read_begin(vd);
103+
seq = vdso_read_begin(vc);
104104

105-
if (unlikely(!vdso_clocksource_ok(vd)))
105+
if (unlikely(!vdso_clocksource_ok(vc)))
106106
return -1;
107107

108-
cycles = __arch_get_hw_counter(vd->clock_mode, vd);
108+
cycles = __arch_get_hw_counter(vc->clock_mode, vd);
109109
if (unlikely(!vdso_cycles_ok(cycles)))
110110
return -1;
111-
ns = vdso_calc_ns(vd, cycles, vdso_ts->nsec);
111+
ns = vdso_calc_ns(vc, cycles, vdso_ts->nsec);
112112
sec = vdso_ts->sec;
113-
} while (unlikely(vdso_read_retry(vd, seq)));
113+
} while (unlikely(vdso_read_retry(vc, seq)));
114114

115115
/* Add the namespace offset */
116116
sec += offs->sec;
@@ -132,8 +132,9 @@ const struct vdso_time_data *__arch_get_vdso_u_timens_data(const struct vdso_tim
132132
return NULL;
133133
}
134134

135-
static __always_inline int do_hres_timens(const struct vdso_time_data *vdns, clockid_t clk,
136-
struct __kernel_timespec *ts)
135+
static __always_inline
136+
int do_hres_timens(const struct vdso_time_data *vdns, const struct vdso_clock *vcns,
137+
clockid_t clk, struct __kernel_timespec *ts)
137138
{
138139
return -EINVAL;
139140
}
@@ -166,7 +167,7 @@ int do_hres(const struct vdso_time_data *vd, const struct vdso_clock *vc,
166167
while (unlikely((seq = READ_ONCE(vc->seq)) & 1)) {
167168
if (IS_ENABLED(CONFIG_TIME_NS) &&
168169
vc->clock_mode == VDSO_CLOCKMODE_TIMENS)
169-
return do_hres_timens(vd, clk, ts);
170+
return do_hres_timens(vd, vc, clk, ts);
170171
cpu_relax();
171172
}
172173
smp_rmb();

0 commit comments

Comments
 (0)