linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/6] arm64: add the time namespace support
@ 2020-04-16  5:26 Andrei Vagin
  2020-04-16  5:26 ` [PATCH 1/6] arm64/vdso: use the fault callback to map vvar pages Andrei Vagin
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Andrei Vagin @ 2020-04-16  5:26 UTC (permalink / raw)
  To: Vincenzo Frascino, Catalin Marinas, Will Deacon
  Cc: linux-arm-kernel, linux-kernel, Mark Rutland, Thomas Gleixner,
	Andrei Vagin, Dmitry Safonov

Allocate the time namespace page among VVAR pages and add the logic
to handle faults on VVAR properly.

If a task belongs to a time namespace then the VVAR page which contains
the system wide VDSO data is replaced with a namespace specific page
which has the same layout as the VVAR page. That page has vdso_data->seq
set to 1 to enforce the slow path and vdso_data->clock_mode set to
VCLOCK_TIMENS to enforce the time namespace handling path.

The extra check in the case that vdso_data->seq is odd, e.g. a concurrent
update of the VDSO data is in progress, is not really affecting regular
tasks which are not part of a time namespace as the task is spin waiting
for the update to finish and vdso_data->seq to become even again.

If a time namespace task hits that code path, it invokes the corresponding
time getter function which retrieves the real VVAR page, reads host time
and then adds the offset for the requested clock which is stored in the
special VVAR page.

v2: Code cleanups suggested by Vincenzo.
v3: use OPTIMIZER_HIDE_VAR() instead of inline assembly in
    __arch_get_timens_vdso_data.

Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Dmitry Safonov <dima@arista.com>

v3 on github (if someone prefers `git pull` to `git am`):
https://github.com/avagin/linux-task-diag/tree/arm64/timens-v3

Andrei Vagin (6):
  arm64/vdso: use the fault callback to map vvar pages
  arm64/vdso: Zap vvar pages when switching to a time namespace
  arm64/vdso: Add time napespace page
  arm64/vdso: Handle faults on timens page
  arm64/vdso: Restrict splitting VVAR VMA
  arm64: enable time namespace support

 arch/arm64/Kconfig                            |   1 +
 .../include/asm/vdso/compat_gettimeofday.h    |  11 ++
 arch/arm64/include/asm/vdso/gettimeofday.h    |   8 ++
 arch/arm64/kernel/vdso.c                      | 134 ++++++++++++++++--
 arch/arm64/kernel/vdso/vdso.lds.S             |   3 +-
 arch/arm64/kernel/vdso32/vdso.lds.S           |   3 +-
 include/vdso/datapage.h                       |   1 +
 7 files changed, 147 insertions(+), 14 deletions(-)

-- 
2.24.1


^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH RESEND v3 0/6] arm64: add the time namespace support
@ 2020-06-02 18:02 Andrei Vagin
  2020-06-02 18:02 ` [PATCH 5/6] arm64/vdso: Restrict splitting VVAR VMA Andrei Vagin
  0 siblings, 1 reply; 14+ messages in thread
From: Andrei Vagin @ 2020-06-02 18:02 UTC (permalink / raw)
  To: linux-arm-kernel, Catalin Marinas, Will Deacon
  Cc: linux-kernel, Vincenzo Frascino, Mark Rutland, Thomas Gleixner,
	Dmitry Safonov, Andrei Vagin

Allocate the time namespace page among VVAR pages and add the logic
to handle faults on VVAR properly.

If a task belongs to a time namespace then the VVAR page which contains
the system wide VDSO data is replaced with a namespace specific page
which has the same layout as the VVAR page. That page has vdso_data->seq
set to 1 to enforce the slow path and vdso_data->clock_mode set to
VCLOCK_TIMENS to enforce the time namespace handling path.

The extra check in the case that vdso_data->seq is odd, e.g. a concurrent
update of the VDSO data is in progress, is not really affecting regular
tasks which are not part of a time namespace as the task is spin waiting
for the update to finish and vdso_data->seq to become even again.

If a time namespace task hits that code path, it invokes the corresponding
time getter function which retrieves the real VVAR page, reads host time
and then adds the offset for the requested clock which is stored in the
special VVAR page.

v2: Code cleanups suggested by Vincenzo.
v3: add a comment in __arch_get_timens_vdso_data.

Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Dmitry Safonov <dima@arista.com>

v3 on github (if someone prefers `git pull` to `git am`):
https://github.com/avagin/linux-task-diag/tree/arm64/timens-v3

Andrei Vagin (6):
  arm64/vdso: use the fault callback to map vvar pages
  arm64/vdso: Zap vvar pages when switching to a time namespace
  arm64/vdso: Add time napespace page
  arm64/vdso: Handle faults on timens page
  arm64/vdso: Restrict splitting VVAR VMA
  arm64: enable time namespace support

 arch/arm64/Kconfig                            |   1 +
 .../include/asm/vdso/compat_gettimeofday.h    |  11 ++
 arch/arm64/include/asm/vdso/gettimeofday.h    |   8 ++
 arch/arm64/kernel/vdso.c                      | 134 ++++++++++++++++--
 arch/arm64/kernel/vdso/vdso.lds.S             |   3 +-
 arch/arm64/kernel/vdso32/vdso.lds.S           |   3 +-
 include/vdso/datapage.h                       |   1 +
 7 files changed, 147 insertions(+), 14 deletions(-)

-- 
2.24.1


^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH v4 0/6] arm64: add the time namespace support
@ 2020-06-16  7:55 Andrei Vagin
  2020-06-16  7:55 ` [PATCH 5/6] arm64/vdso: Restrict splitting VVAR VMA Andrei Vagin
  0 siblings, 1 reply; 14+ messages in thread
From: Andrei Vagin @ 2020-06-16  7:55 UTC (permalink / raw)
  To: linux-arm-kernel, Catalin Marinas, Will Deacon
  Cc: linux-kernel, Vincenzo Frascino, Mark Rutland, Thomas Gleixner,
	Dmitry Safonov, Andrei Vagin

Allocate the time namespace page among VVAR pages and add the logic
to handle faults on VVAR properly.

If a task belongs to a time namespace then the VVAR page which contains
the system wide VDSO data is replaced with a namespace specific page
which has the same layout as the VVAR page. That page has vdso_data->seq
set to 1 to enforce the slow path and vdso_data->clock_mode set to
VCLOCK_TIMENS to enforce the time namespace handling path.

The extra check in the case that vdso_data->seq is odd, e.g. a concurrent
update of the VDSO data is in progress, is not really affecting regular
tasks which are not part of a time namespace as the task is spin waiting
for the update to finish and vdso_data->seq to become even again.

If a time namespace task hits that code path, it invokes the corresponding
time getter function which retrieves the real VVAR page, reads host time
and then adds the offset for the requested clock which is stored in the
special VVAR page.

v2: Code cleanups suggested by Vincenzo.
v3: add a comment in __arch_get_timens_vdso_data.
v4: - fix an issue reported by the lkp robot.
    - vvar has the same size with/without CONFIG_TIME_NAMESPACE, but the
      timens page isn't allocated on !CONFIG_TIME_NAMESPACE. This
      simplifies criu/vdso migration between different kernel configs.


Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Reviewed-by: Dmitry Safonov <dima@arista.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Dmitry Safonov <dima@arista.com>

v4 on github (if someone prefers `git pull` to `git am`):
https://github.com/avagin/linux-task-diag/tree/arm64/timens-v4

Andrei Vagin (6):
  arm64/vdso: use the fault callback to map vvar pages
  arm64/vdso: Zap vvar pages when switching to a time namespace
  arm64/vdso: Add time namespace page
  arm64/vdso: Handle faults on timens page
  arm64/vdso: Restrict splitting VVAR VMA
  arm64: enable time namespace support

--
2.24.1


^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH v5 0/6] arm64: add the time namespace support
@ 2020-06-24  8:33 Andrei Vagin
  2020-06-24  8:33 ` [PATCH 5/6] arm64/vdso: Restrict splitting VVAR VMA Andrei Vagin
  0 siblings, 1 reply; 14+ messages in thread
From: Andrei Vagin @ 2020-06-24  8:33 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Mark Rutland
  Cc: linux-arm-kernel, linux-kernel, Vincenzo Frascino,
	Thomas Gleixner, Dmitry Safonov, Christian Brauner, Andrei Vagin

Allocate the time namespace page among VVAR pages and add the logic
to handle faults on VVAR properly.

If a task belongs to a time namespace then the VVAR page which contains
the system wide VDSO data is replaced with a namespace specific page
which has the same layout as the VVAR page. That page has vdso_data->seq
set to 1 to enforce the slow path and vdso_data->clock_mode set to
VCLOCK_TIMENS to enforce the time namespace handling path.

The extra check in the case that vdso_data->seq is odd, e.g. a concurrent
update of the VDSO data is in progress, is not really affecting regular
tasks which are not part of a time namespace as the task is spin waiting
for the update to finish and vdso_data->seq to become even again.

If a time namespace task hits that code path, it invokes the corresponding
time getter function which retrieves the real VVAR page, reads host time
and then adds the offset for the requested clock which is stored in the
special VVAR page.

v2: Code cleanups suggested by Vincenzo.
v3: add a comment in __arch_get_timens_vdso_data.
v4: - fix an issue reported by the lkp robot.
    - vvar has the same size with/without CONFIG_TIME_NAMESPACE, but the
      timens page isn't allocated on !CONFIG_TIME_NAMESPACE. This
      simplifies criu/vdso migration between different kernel configs.
v5: - Code cleanups suggested by Mark Rutland.
    - In vdso_join_timens, mmap_write_lock is downgraded to
      mmap_read_lock. The VMA list isn't changed there, zap_page_range
      doesn't require mmap_write_lock.

Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Reviewed-by: Dmitry Safonov <dima@arista.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Dmitry Safonov <dima@arista.com>

v5 on github (if someone prefers `git pull` to `git am`):
https://github.com/avagin/linux-task-diag/tree/arm64/timens-v5

Andrei Vagin (6):
  arm64/vdso: use the fault callback to map vvar pages
  arm64/vdso: Zap vvar pages when switching to a time namespace
  arm64/vdso: Add time namespace page
  arm64/vdso: Handle faults on timens page
  arm64/vdso: Restrict splitting VVAR VMA
  arm64: enable time namespace support

--
2.24.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-06-24  8:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-16  5:26 [PATCH v3 0/6] arm64: add the time namespace support Andrei Vagin
2020-04-16  5:26 ` [PATCH 1/6] arm64/vdso: use the fault callback to map vvar pages Andrei Vagin
2020-04-16  5:26 ` [PATCH 2/6] arm64/vdso: Zap vvar pages when switching to a time namespace Andrei Vagin
2020-04-16  5:26 ` [PATCH 3/6] arm64/vdso: Add time napespace page Andrei Vagin
2020-04-16 10:45   ` Mark Rutland
2020-04-23  5:23     ` Andrei Vagin
2020-04-17  4:11   ` [PATCH 3/6 v2] arm64/vdso: Add time namespace page Andrei Vagin
2020-04-16  5:26 ` [PATCH 4/6] arm64/vdso: Handle faults on timens page Andrei Vagin
2020-04-16  5:26 ` [PATCH 5/6] arm64/vdso: Restrict splitting VVAR VMA Andrei Vagin
2020-04-16  5:26 ` [PATCH 6/6] arm64: enable time namespace support Andrei Vagin
2020-05-20 12:02 ` [PATCH v3 0/6] arm64: add the " Vincenzo Frascino
2020-06-02 18:02 [PATCH RESEND " Andrei Vagin
2020-06-02 18:02 ` [PATCH 5/6] arm64/vdso: Restrict splitting VVAR VMA Andrei Vagin
2020-06-16  7:55 [PATCH v4 0/6] arm64: add the time namespace support Andrei Vagin
2020-06-16  7:55 ` [PATCH 5/6] arm64/vdso: Restrict splitting VVAR VMA Andrei Vagin
2020-06-24  8:33 [PATCH v5 0/6] arm64: add the time namespace support Andrei Vagin
2020-06-24  8:33 ` [PATCH 5/6] arm64/vdso: Restrict splitting VVAR VMA Andrei Vagin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).