Skip to content

Commit 2d6b01b

Browse files
committed
lib/vdso: Move VCLOCK_TIMENS to vdso_clock_modes
Move the time namespace indicator clock mode to the other ones for consistency sake. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com> Link: https://lkml.kernel.org/r/20200207124403.656097274@linutronix.de
1 parent c7a1810 commit 2d6b01b

4 files changed

Lines changed: 17 additions & 13 deletions

File tree

‎include/linux/clocksource.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ enum vdso_clock_mode {
3434
VDSO_ARCH_CLOCKMODES,
3535
#endif
3636
VDSO_CLOCKMODE_MAX,
37+
38+
/* Indicator for time namespace VDSO */
39+
VDSO_CLOCKMODE_TIMENS = INT_MAX
3740
};
3841

3942
/**

‎include/vdso/datapage.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
#define CS_RAW 1
2222
#define CS_BASES (CS_RAW + 1)
2323

24-
#define VCLOCK_TIMENS UINT_MAX
25-
2624
/**
2725
* struct vdso_timestamp - basetime per clock_id
2826
* @sec: seconds

‎kernel/time/namespace.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/user_namespace.h>
99
#include <linux/sched/signal.h>
1010
#include <linux/sched/task.h>
11+
#include <linux/clocksource.h>
1112
#include <linux/seq_file.h>
1213
#include <linux/proc_ns.h>
1314
#include <linux/export.h>
@@ -172,8 +173,8 @@ static struct timens_offset offset_from_ts(struct timespec64 off)
172173
* for vdso_data->clock_mode is a non-issue. The task is spin waiting for the
173174
* update to finish and for 'seq' to become even anyway.
174175
*
175-
* Timens page has vdso_data->clock_mode set to VCLOCK_TIMENS which enforces
176-
* the time namespace handling path.
176+
* Timens page has vdso_data->clock_mode set to VDSO_CLOCKMODE_TIMENS which
177+
* enforces the time namespace handling path.
177178
*/
178179
static void timens_setup_vdso_data(struct vdso_data *vdata,
179180
struct time_namespace *ns)
@@ -183,7 +184,7 @@ static void timens_setup_vdso_data(struct vdso_data *vdata,
183184
struct timens_offset boottime = offset_from_ts(ns->offsets.boottime);
184185

185186
vdata->seq = 1;
186-
vdata->clock_mode = VCLOCK_TIMENS;
187+
vdata->clock_mode = VDSO_CLOCKMODE_TIMENS;
187188
offset[CLOCK_MONOTONIC] = monotonic;
188189
offset[CLOCK_MONOTONIC_RAW] = monotonic;
189190
offset[CLOCK_MONOTONIC_COARSE] = monotonic;

‎lib/vdso/gettimeofday.c‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ static __always_inline int do_hres(const struct vdso_data *vd, clockid_t clk,
116116

117117
do {
118118
/*
119-
* Open coded to handle VCLOCK_TIMENS. Time namespace
119+
* Open coded to handle VDSO_CLOCKMODE_TIMENS. Time namespace
120120
* enabled tasks have a special VVAR page installed which
121121
* has vd->seq set to 1 and vd->clock_mode set to
122-
* VCLOCK_TIMENS. For non time namespace affected tasks
122+
* VDSO_CLOCKMODE_TIMENS. For non time namespace affected tasks
123123
* this does not affect performance because if vd->seq is
124124
* odd, i.e. a concurrent update is in progress the extra
125125
* check for vd->clock_mode is just a few extra
@@ -128,7 +128,7 @@ static __always_inline int do_hres(const struct vdso_data *vd, clockid_t clk,
128128
*/
129129
while (unlikely((seq = READ_ONCE(vd->seq)) & 1)) {
130130
if (IS_ENABLED(CONFIG_TIME_NS) &&
131-
vd->clock_mode == VCLOCK_TIMENS)
131+
vd->clock_mode == VDSO_CLOCKMODE_TIMENS)
132132
return do_hres_timens(vd, clk, ts);
133133
cpu_relax();
134134
}
@@ -200,12 +200,12 @@ static __always_inline int do_coarse(const struct vdso_data *vd, clockid_t clk,
200200

201201
do {
202202
/*
203-
* Open coded to handle VCLOCK_TIMENS. See comment in
203+
* Open coded to handle VDSO_CLOCK_TIMENS. See comment in
204204
* do_hres().
205205
*/
206206
while ((seq = READ_ONCE(vd->seq)) & 1) {
207207
if (IS_ENABLED(CONFIG_TIME_NS) &&
208-
vd->clock_mode == VCLOCK_TIMENS)
208+
vd->clock_mode == VDSO_CLOCKMODE_TIMENS)
209209
return do_coarse_timens(vd, clk, ts);
210210
cpu_relax();
211211
}
@@ -292,7 +292,7 @@ __cvdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
292292

293293
if (unlikely(tz != NULL)) {
294294
if (IS_ENABLED(CONFIG_TIME_NS) &&
295-
vd->clock_mode == VCLOCK_TIMENS)
295+
vd->clock_mode == VDSO_CLOCKMODE_TIMENS)
296296
vd = __arch_get_timens_vdso_data();
297297

298298
tz->tz_minuteswest = vd[CS_HRES_COARSE].tz_minuteswest;
@@ -308,7 +308,8 @@ static __maybe_unused __kernel_old_time_t __cvdso_time(__kernel_old_time_t *time
308308
const struct vdso_data *vd = __arch_get_vdso_data();
309309
__kernel_old_time_t t;
310310

311-
if (IS_ENABLED(CONFIG_TIME_NS) && vd->clock_mode == VCLOCK_TIMENS)
311+
if (IS_ENABLED(CONFIG_TIME_NS) &&
312+
vd->clock_mode == VDSO_CLOCKMODE_TIMENS)
312313
vd = __arch_get_timens_vdso_data();
313314

314315
t = READ_ONCE(vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec);
@@ -332,7 +333,8 @@ int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)
332333
if (unlikely((u32) clock >= MAX_CLOCKS))
333334
return -1;
334335

335-
if (IS_ENABLED(CONFIG_TIME_NS) && vd->clock_mode == VCLOCK_TIMENS)
336+
if (IS_ENABLED(CONFIG_TIME_NS) &&
337+
vd->clock_mode == VDSO_CLOCKMODE_TIMENS)
336338
vd = __arch_get_timens_vdso_data();
337339

338340
/*

0 commit comments

Comments
 (0)