Skip to content

Commit

Permalink
time/namespace: Prepare introduction of struct vdso_clock
Browse files Browse the repository at this point in the history
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 <anna-maria@linutronix.de>
Signed-off-by: Nam Cao <namcao@linutronix.de>
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250303-vdso-clock-v1-14-c1b5c69a166f@linutronix.de
  • Loading branch information
Anna-Maria Behnsen authored and Thomas Gleixner committed Mar 8, 2025
1 parent 0235220 commit 5911e16
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions kernel/time/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,26 +165,26 @@ static struct timens_offset offset_from_ts(struct timespec64 off)
* HVCLOCK
* VVAR
*
* The check for vdso_time_data->clock_mode is in the unlikely path of
* The check for vdso_clock->clock_mode is in the unlikely path of
* the seq begin magic. So for the non-timens case most of the time
* 'seq' is even, so the branch is not taken.
*
* If 'seq' is odd, i.e. a concurrent update is in progress, the extra check
* for vdso_time_data->clock_mode is a non-issue. The task is spin waiting for the
* for vdso_clock->clock_mode is a non-issue. The task is spin waiting for the
* update to finish and for 'seq' to become even anyway.
*
* Timens page has vdso_time_data->clock_mode set to VDSO_CLOCKMODE_TIMENS which
* Timens page has vdso_clock->clock_mode set to VDSO_CLOCKMODE_TIMENS which
* enforces the time namespace handling path.
*/
static void timens_setup_vdso_clock_data(struct vdso_time_data *vdata,
static void timens_setup_vdso_clock_data(struct vdso_clock *vc,
struct time_namespace *ns)
{
struct timens_offset *offset = vdata->offset;
struct timens_offset *offset = vc->offset;
struct timens_offset monotonic = offset_from_ts(ns->offsets.monotonic);
struct timens_offset boottime = offset_from_ts(ns->offsets.boottime);

vdata->seq = 1;
vdata->clock_mode = VDSO_CLOCKMODE_TIMENS;
vc->seq = 1;
vc->clock_mode = VDSO_CLOCKMODE_TIMENS;
offset[CLOCK_MONOTONIC] = monotonic;
offset[CLOCK_MONOTONIC_RAW] = monotonic;
offset[CLOCK_MONOTONIC_COARSE] = monotonic;
Expand Down Expand Up @@ -220,6 +220,7 @@ static void timens_set_vvar_page(struct task_struct *task,
struct time_namespace *ns)
{
struct vdso_time_data *vdata;
struct vdso_clock *vc;
unsigned int i;

if (ns == &init_time_ns)
Expand All @@ -236,9 +237,10 @@ static void timens_set_vvar_page(struct task_struct *task,

ns->frozen_offsets = true;
vdata = page_address(ns->vvar_page);
vc = vdata;

for (i = 0; i < CS_BASES; i++)
timens_setup_vdso_clock_data(&vdata[i], ns);
timens_setup_vdso_clock_data(&vc[i], ns);

out:
mutex_unlock(&offset_lock);
Expand Down

0 comments on commit 5911e16

Please sign in to comment.