mbox series

[0/5] arm64: add the time namespace support

Message ID 20200204175913.74901-1-avagin@gmail.com (mailing list archive)
Headers show
Series arm64: add the time namespace support | expand

Message

Andrei Vagin Feb. 4, 2020, 5:59 p.m. UTC
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.

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

Andrei Vagin (5):
  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

 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(-)

Comments

Andrei Vagin Feb. 17, 2020, 3:34 p.m. UTC | #1
Vincenzo, could you take a look this patchset?

On Tue, Feb 04, 2020 at 09:59:08AM -0800, Andrei Vagin wrote:
> 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.
> 
> Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Dmitry Safonov <dima@arista.com>
> 
> Andrei Vagin (5):
>   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
> 
>  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
>
Vincenzo Frascino Feb. 17, 2020, 6:25 p.m. UTC | #2
Hi Andrei,

On 17/02/2020 15:34, Andrei Vagin wrote:
> Vincenzo, could you take a look this patchset?
> 

Apologize for not getting to this yet. I will have a look at your patches during
this week.

> On Tue, Feb 04, 2020 at 09:59:08AM -0800, Andrei Vagin wrote:
>> 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.
>>
>> Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Dmitry Safonov <dima@arista.com>
>>
>> Andrei Vagin (5):
>>   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
>>
>>  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
>>
Vincenzo Frascino Feb. 20, 2020, 12:40 p.m. UTC | #3
Hi Andrei,

On 04/02/2020 17:59, Andrei Vagin wrote:
> 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.
> 

Thank you for adding the arm64 support of time namespaces. Overall it looks fine
to me even if I have few comments. I will test it in the coming days just to
make sure I did not miss something major. I will keep you updated on the results.

> Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Dmitry Safonov <dima@arista.com>
> 
> Andrei Vagin (5):
>   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
> 
>  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(-)
>
Andrei Vagin Feb. 23, 2020, 8:08 a.m. UTC | #4
On Thu, Feb 20, 2020 at 12:40:47PM +0000, Vincenzo Frascino wrote:
> Hi Andrei,
> 
> On 04/02/2020 17:59, Andrei Vagin wrote:
> > 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.
> > 
> 
> Thank you for adding the arm64 support of time namespaces. Overall it looks fine
> to me even if I have few comments. I will test it in the coming days just to
> make sure I did not miss something major. I will keep you updated on the results.

Thank you for the review. All comments look reasonable and I will
address them and post a second version.

Thanks,
Andrei