Skip to content

Commit b5afbc1

Browse files
anna-marialxKAGA-KOKO
authored andcommitted
vdso/vsyscall: 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. To prepare for the rework of the data structures, replace the struct vdso_time_data pointer with a struct vdso_clock pointer 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 8080197 commit b5afbc1

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

kernel/time/vsyscall.c

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,26 @@
1818
static inline void update_vdso_time_data(struct vdso_time_data *vdata, struct timekeeper *tk)
1919
{
2020
struct vdso_timestamp *vdso_ts;
21+
struct vdso_clock *vc = vdata;
2122
u64 nsec, sec;
2223

23-
vdata[CS_HRES_COARSE].cycle_last = tk->tkr_mono.cycle_last;
24+
vc[CS_HRES_COARSE].cycle_last = tk->tkr_mono.cycle_last;
2425
#ifdef CONFIG_GENERIC_VDSO_OVERFLOW_PROTECT
25-
vdata[CS_HRES_COARSE].max_cycles = tk->tkr_mono.clock->max_cycles;
26+
vc[CS_HRES_COARSE].max_cycles = tk->tkr_mono.clock->max_cycles;
2627
#endif
27-
vdata[CS_HRES_COARSE].mask = tk->tkr_mono.mask;
28-
vdata[CS_HRES_COARSE].mult = tk->tkr_mono.mult;
29-
vdata[CS_HRES_COARSE].shift = tk->tkr_mono.shift;
30-
vdata[CS_RAW].cycle_last = tk->tkr_raw.cycle_last;
28+
vc[CS_HRES_COARSE].mask = tk->tkr_mono.mask;
29+
vc[CS_HRES_COARSE].mult = tk->tkr_mono.mult;
30+
vc[CS_HRES_COARSE].shift = tk->tkr_mono.shift;
31+
vc[CS_RAW].cycle_last = tk->tkr_raw.cycle_last;
3132
#ifdef CONFIG_GENERIC_VDSO_OVERFLOW_PROTECT
32-
vdata[CS_RAW].max_cycles = tk->tkr_raw.clock->max_cycles;
33+
vc[CS_RAW].max_cycles = tk->tkr_raw.clock->max_cycles;
3334
#endif
34-
vdata[CS_RAW].mask = tk->tkr_raw.mask;
35-
vdata[CS_RAW].mult = tk->tkr_raw.mult;
36-
vdata[CS_RAW].shift = tk->tkr_raw.shift;
35+
vc[CS_RAW].mask = tk->tkr_raw.mask;
36+
vc[CS_RAW].mult = tk->tkr_raw.mult;
37+
vc[CS_RAW].shift = tk->tkr_raw.shift;
3738

3839
/* CLOCK_MONOTONIC */
39-
vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_MONOTONIC];
40+
vdso_ts = &vc[CS_HRES_COARSE].basetime[CLOCK_MONOTONIC];
4041
vdso_ts->sec = tk->xtime_sec + tk->wall_to_monotonic.tv_sec;
4142

4243
nsec = tk->tkr_mono.xtime_nsec;
@@ -54,7 +55,7 @@ static inline void update_vdso_time_data(struct vdso_time_data *vdata, struct ti
5455
nsec += (u64)tk->monotonic_to_boot.tv_nsec << tk->tkr_mono.shift;
5556

5657
/* CLOCK_BOOTTIME */
57-
vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_BOOTTIME];
58+
vdso_ts = &vc[CS_HRES_COARSE].basetime[CLOCK_BOOTTIME];
5859
vdso_ts->sec = sec;
5960

6061
while (nsec >= (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift)) {
@@ -64,12 +65,12 @@ static inline void update_vdso_time_data(struct vdso_time_data *vdata, struct ti
6465
vdso_ts->nsec = nsec;
6566

6667
/* CLOCK_MONOTONIC_RAW */
67-
vdso_ts = &vdata[CS_RAW].basetime[CLOCK_MONOTONIC_RAW];
68+
vdso_ts = &vc[CS_RAW].basetime[CLOCK_MONOTONIC_RAW];
6869
vdso_ts->sec = tk->raw_sec;
6970
vdso_ts->nsec = tk->tkr_raw.xtime_nsec;
7071

7172
/* CLOCK_TAI */
72-
vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_TAI];
73+
vdso_ts = &vc[CS_HRES_COARSE].basetime[CLOCK_TAI];
7374
vdso_ts->sec = tk->xtime_sec + (s64)tk->tai_offset;
7475
vdso_ts->nsec = tk->tkr_mono.xtime_nsec;
7576
}
@@ -78,28 +79,29 @@ void update_vsyscall(struct timekeeper *tk)
7879
{
7980
struct vdso_time_data *vdata = vdso_k_time_data;
8081
struct vdso_timestamp *vdso_ts;
82+
struct vdso_clock *vc = vdata;
8183
s32 clock_mode;
8284
u64 nsec;
8385

8486
/* copy vsyscall data */
8587
vdso_write_begin(vdata);
8688

8789
clock_mode = tk->tkr_mono.clock->vdso_clock_mode;
88-
vdata[CS_HRES_COARSE].clock_mode = clock_mode;
89-
vdata[CS_RAW].clock_mode = clock_mode;
90+
vc[CS_HRES_COARSE].clock_mode = clock_mode;
91+
vc[CS_RAW].clock_mode = clock_mode;
9092

9193
/* CLOCK_REALTIME also required for time() */
92-
vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_REALTIME];
94+
vdso_ts = &vc[CS_HRES_COARSE].basetime[CLOCK_REALTIME];
9395
vdso_ts->sec = tk->xtime_sec;
9496
vdso_ts->nsec = tk->tkr_mono.xtime_nsec;
9597

9698
/* CLOCK_REALTIME_COARSE */
97-
vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_REALTIME_COARSE];
99+
vdso_ts = &vc[CS_HRES_COARSE].basetime[CLOCK_REALTIME_COARSE];
98100
vdso_ts->sec = tk->xtime_sec;
99101
vdso_ts->nsec = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift;
100102

101103
/* CLOCK_MONOTONIC_COARSE */
102-
vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_MONOTONIC_COARSE];
104+
vdso_ts = &vc[CS_HRES_COARSE].basetime[CLOCK_MONOTONIC_COARSE];
103105
vdso_ts->sec = tk->xtime_sec + tk->wall_to_monotonic.tv_sec;
104106
nsec = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift;
105107
nsec = nsec + tk->wall_to_monotonic.tv_nsec;

0 commit comments

Comments
 (0)