public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] vdso (generic and x86): Misc minor cleanups
@ 2024-07-01 14:47 Anna-Maria Behnsen
  2024-07-01 14:47 ` [PATCH 1/5] vdso/gettimeofday: Clarify comment about open coded function Anna-Maria Behnsen
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Anna-Maria Behnsen @ 2024-07-01 14:47 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino
  Cc: linux-kernel, Anna-Maria Behnsen, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H. Peter Anvin, x86

The queue contains minor vdso related cleanups such as fixing/adding
comments and removing unused stuff. First two patches are related to the
generic vdso part. Last three patches are x86 specific.

The queue is available here:

https://git.kernel.org/pub/scm/linux/kernel/git/anna-maria/linux-devel.git vdso/cleanup

To: Andy Lutomirski <luto@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
To: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: linux-kernel@vger.kernel.org

Thanks,

Anna-Maria

---
Anna-Maria Behnsen (5):
      vdso/gettimeofday: Clarify comment about open coded function
      vdso: Add comment about reason for vdso struct ordering
      x86/vdso: Fix function reference in comment
      x86/vgtod: Remove unused typedef gtod_long_t
      x86/vdso: Remove unused include

 arch/x86/include/asm/vdso/gettimeofday.h |  5 ++---
 arch/x86/include/asm/vdso/vsyscall.h     |  1 -
 arch/x86/include/asm/vgtod.h             |  5 -----
 include/vdso/datapage.h                  |  4 ++++
 lib/vdso/gettimeofday.c                  | 20 ++++++++++----------
 5 files changed, 16 insertions(+), 19 deletions(-)


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

* [PATCH 1/5] vdso/gettimeofday: Clarify comment about open coded function
  2024-07-01 14:47 [PATCH 0/5] vdso (generic and x86): Misc minor cleanups Anna-Maria Behnsen
@ 2024-07-01 14:47 ` Anna-Maria Behnsen
  2024-07-01 14:58   ` Vincenzo Frascino
  2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
  2024-07-01 14:47 ` [PATCH 2/5] vdso: Add comment about reason for vdso struct ordering Anna-Maria Behnsen
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 18+ messages in thread
From: Anna-Maria Behnsen @ 2024-07-01 14:47 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino
  Cc: linux-kernel, Anna-Maria Behnsen

The two comments state, that the following code open codes something but
they lack to specify what exactly is open coded.

Expand comments by mentioning the reference to the open coded function.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
 lib/vdso/gettimeofday.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
index 899850bd6f0b..c01eaafd8041 100644
--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -140,14 +140,14 @@ static __always_inline int do_hres(const struct vdso_data *vd, clockid_t clk,
 
 	do {
 		/*
-		 * Open coded to handle VDSO_CLOCKMODE_TIMENS. Time namespace
-		 * enabled tasks have a special VVAR page installed which
-		 * has vd->seq set to 1 and vd->clock_mode set to
-		 * VDSO_CLOCKMODE_TIMENS. For non time namespace affected tasks
-		 * this does not affect performance because if vd->seq is
-		 * odd, i.e. a concurrent update is in progress the extra
-		 * check for vd->clock_mode is just a few extra
-		 * instructions while spin waiting for vd->seq to become
+		 * Open coded function vdso_read_begin() to handle
+		 * VDSO_CLOCKMODE_TIMENS. Time namespace enabled tasks have a
+		 * special VVAR page installed which has vd->seq set to 1 and
+		 * vd->clock_mode set to VDSO_CLOCKMODE_TIMENS. For non time
+		 * namespace affected tasks this does not affect performance
+		 * because if vd->seq is odd, i.e. a concurrent update is in
+		 * progress the extra check for vd->clock_mode is just a few
+		 * extra instructions while spin waiting for vd->seq to become
 		 * even again.
 		 */
 		while (unlikely((seq = READ_ONCE(vd->seq)) & 1)) {
@@ -223,8 +223,8 @@ static __always_inline int do_coarse(const struct vdso_data *vd, clockid_t clk,
 
 	do {
 		/*
-		 * Open coded to handle VDSO_CLOCK_TIMENS. See comment in
-		 * do_hres().
+		 * Open coded function vdso_read_begin() to handle
+		 * VDSO_CLOCK_TIMENS. See comment in do_hres().
 		 */
 		while ((seq = READ_ONCE(vd->seq)) & 1) {
 			if (IS_ENABLED(CONFIG_TIME_NS) &&

-- 
2.39.2


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

* [PATCH 2/5] vdso: Add comment about reason for vdso struct ordering
  2024-07-01 14:47 [PATCH 0/5] vdso (generic and x86): Misc minor cleanups Anna-Maria Behnsen
  2024-07-01 14:47 ` [PATCH 1/5] vdso/gettimeofday: Clarify comment about open coded function Anna-Maria Behnsen
@ 2024-07-01 14:47 ` Anna-Maria Behnsen
  2024-07-01 15:10   ` Vincenzo Frascino
  2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
  2024-07-01 14:47 ` [PATCH 3/5] x86/vdso: Fix function reference in comment Anna-Maria Behnsen
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 18+ messages in thread
From: Anna-Maria Behnsen @ 2024-07-01 14:47 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino
  Cc: linux-kernel, Anna-Maria Behnsen

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
 include/vdso/datapage.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
index d04d394db064..7647e0946f50 100644
--- a/include/vdso/datapage.h
+++ b/include/vdso/datapage.h
@@ -77,6 +77,10 @@ struct vdso_timestamp {
  * vdso_data will be accessed by 64 bit and compat code at the same time
  * so we should be careful before modifying this structure.
  *
+ * The ordering of the struct members is optimized to have fast access to the
+ * often required struct members which are related to CLOCK_REALTIME and
+ * CLOCK_MONOTONIC. This information is stored in the first cache lines.
+ *
  * @basetime is used to store the base time for the system wide time getter
  * VVAR page.
  *

-- 
2.39.2


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

* [PATCH 3/5] x86/vdso: Fix function reference in comment
  2024-07-01 14:47 [PATCH 0/5] vdso (generic and x86): Misc minor cleanups Anna-Maria Behnsen
  2024-07-01 14:47 ` [PATCH 1/5] vdso/gettimeofday: Clarify comment about open coded function Anna-Maria Behnsen
  2024-07-01 14:47 ` [PATCH 2/5] vdso: Add comment about reason for vdso struct ordering Anna-Maria Behnsen
@ 2024-07-01 14:47 ` Anna-Maria Behnsen
  2024-07-01 15:11   ` Vincenzo Frascino
  2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
  2024-07-01 14:47 ` [PATCH 4/5] x86/vgtod: Remove unused typedef gtod_long_t Anna-Maria Behnsen
  2024-07-01 14:47 ` [PATCH 5/5] x86/vdso: Remove unused include Anna-Maria Behnsen
  4 siblings, 2 replies; 18+ messages in thread
From: Anna-Maria Behnsen @ 2024-07-01 14:47 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino
  Cc: linux-kernel, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin, x86, Anna-Maria Behnsen

Replace the reference to the non-existent function arch_vdso_cycles_valid()
by the proper function arch_vdso_cycles_ok().

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
 arch/x86/include/asm/vdso/gettimeofday.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/vdso/gettimeofday.h b/arch/x86/include/asm/vdso/gettimeofday.h
index 0ef36190abe6..b2d2df026f6e 100644
--- a/arch/x86/include/asm/vdso/gettimeofday.h
+++ b/arch/x86/include/asm/vdso/gettimeofday.h
@@ -328,9 +328,8 @@ static __always_inline u64 vdso_calc_ns(const struct vdso_data *vd, u64 cycles,
 	 * due to unsigned comparison.
 	 *
 	 * Due to the MSB/Sign-bit being used as invalid marker (see
-	 * arch_vdso_cycles_valid() above), the effective mask is S64_MAX,
-	 * but that case is also unlikely and will also take the unlikely path
-	 * here.
+	 * arch_vdso_cycles_ok() above), the effective mask is S64_MAX, but that
+	 * case is also unlikely and will also take the unlikely path here.
 	 */
 	if (unlikely(delta > vd->max_cycles)) {
 		/*

-- 
2.39.2


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

* [PATCH 4/5] x86/vgtod: Remove unused typedef gtod_long_t
  2024-07-01 14:47 [PATCH 0/5] vdso (generic and x86): Misc minor cleanups Anna-Maria Behnsen
                   ` (2 preceding siblings ...)
  2024-07-01 14:47 ` [PATCH 3/5] x86/vdso: Fix function reference in comment Anna-Maria Behnsen
@ 2024-07-01 14:47 ` Anna-Maria Behnsen
  2024-07-01 15:19   ` Vincenzo Frascino
  2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
  2024-07-01 14:47 ` [PATCH 5/5] x86/vdso: Remove unused include Anna-Maria Behnsen
  4 siblings, 2 replies; 18+ messages in thread
From: Anna-Maria Behnsen @ 2024-07-01 14:47 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino
  Cc: linux-kernel, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin, x86, Anna-Maria Behnsen

The typedef gtod_long_t is not used anymore so remove it.

The header file contains then only includes dependent on
CONFIG_GENERIC_GETTIMEOFDAY to not break ARCH=um. Nevertheless, keep the
header file only with those includes to prevent spreading ifdeffery all
over the place.

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
 arch/x86/include/asm/vgtod.h | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/x86/include/asm/vgtod.h b/arch/x86/include/asm/vgtod.h
index 7aa38b2ad8a9..a0ce291abcae 100644
--- a/arch/x86/include/asm/vgtod.h
+++ b/arch/x86/include/asm/vgtod.h
@@ -14,11 +14,6 @@
 
 #include <uapi/linux/time.h>
 
-#ifdef BUILD_VDSO32_64
-typedef u64 gtod_long_t;
-#else
-typedef unsigned long gtod_long_t;
-#endif
 #endif /* CONFIG_GENERIC_GETTIMEOFDAY */
 
 #endif /* _ASM_X86_VGTOD_H */

-- 
2.39.2


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

* [PATCH 5/5] x86/vdso: Remove unused include
  2024-07-01 14:47 [PATCH 0/5] vdso (generic and x86): Misc minor cleanups Anna-Maria Behnsen
                   ` (3 preceding siblings ...)
  2024-07-01 14:47 ` [PATCH 4/5] x86/vgtod: Remove unused typedef gtod_long_t Anna-Maria Behnsen
@ 2024-07-01 14:47 ` Anna-Maria Behnsen
  2024-07-01 16:19   ` Vincenzo Frascino
  2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
  4 siblings, 2 replies; 18+ messages in thread
From: Anna-Maria Behnsen @ 2024-07-01 14:47 UTC (permalink / raw)
  To: Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino
  Cc: linux-kernel, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin, x86, Anna-Maria Behnsen

Including hrtimer.h is not required and is probably a historical
leftover. Remove it.

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
 arch/x86/include/asm/vdso/vsyscall.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/x86/include/asm/vdso/vsyscall.h b/arch/x86/include/asm/vdso/vsyscall.h
index be199a9b2676..93226281b450 100644
--- a/arch/x86/include/asm/vdso/vsyscall.h
+++ b/arch/x86/include/asm/vdso/vsyscall.h
@@ -4,7 +4,6 @@
 
 #ifndef __ASSEMBLY__
 
-#include <linux/hrtimer.h>
 #include <linux/timekeeper_internal.h>
 #include <vdso/datapage.h>
 #include <asm/vgtod.h>

-- 
2.39.2


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

* Re: [PATCH 1/5] vdso/gettimeofday: Clarify comment about open coded function
  2024-07-01 14:47 ` [PATCH 1/5] vdso/gettimeofday: Clarify comment about open coded function Anna-Maria Behnsen
@ 2024-07-01 14:58   ` Vincenzo Frascino
  2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
  1 sibling, 0 replies; 18+ messages in thread
From: Vincenzo Frascino @ 2024-07-01 14:58 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Andy Lutomirski, Thomas Gleixner; +Cc: linux-kernel



On 01/07/2024 15:47, Anna-Maria Behnsen wrote:
> The two comments state, that the following code open codes something but
> they lack to specify what exactly is open coded.
> 
> Expand comments by mentioning the reference to the open coded function.
> 
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>

Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

> ---
>  lib/vdso/gettimeofday.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
> index 899850bd6f0b..c01eaafd8041 100644
> --- a/lib/vdso/gettimeofday.c
> +++ b/lib/vdso/gettimeofday.c
> @@ -140,14 +140,14 @@ static __always_inline int do_hres(const struct vdso_data *vd, clockid_t clk,
>  
>  	do {
>  		/*
> -		 * Open coded to handle VDSO_CLOCKMODE_TIMENS. Time namespace
> -		 * enabled tasks have a special VVAR page installed which
> -		 * has vd->seq set to 1 and vd->clock_mode set to
> -		 * VDSO_CLOCKMODE_TIMENS. For non time namespace affected tasks
> -		 * this does not affect performance because if vd->seq is
> -		 * odd, i.e. a concurrent update is in progress the extra
> -		 * check for vd->clock_mode is just a few extra
> -		 * instructions while spin waiting for vd->seq to become
> +		 * Open coded function vdso_read_begin() to handle
> +		 * VDSO_CLOCKMODE_TIMENS. Time namespace enabled tasks have a
> +		 * special VVAR page installed which has vd->seq set to 1 and
> +		 * vd->clock_mode set to VDSO_CLOCKMODE_TIMENS. For non time
> +		 * namespace affected tasks this does not affect performance
> +		 * because if vd->seq is odd, i.e. a concurrent update is in
> +		 * progress the extra check for vd->clock_mode is just a few
> +		 * extra instructions while spin waiting for vd->seq to become
>  		 * even again.
>  		 */
>  		while (unlikely((seq = READ_ONCE(vd->seq)) & 1)) {
> @@ -223,8 +223,8 @@ static __always_inline int do_coarse(const struct vdso_data *vd, clockid_t clk,
>  
>  	do {
>  		/*
> -		 * Open coded to handle VDSO_CLOCK_TIMENS. See comment in
> -		 * do_hres().
> +		 * Open coded function vdso_read_begin() to handle
> +		 * VDSO_CLOCK_TIMENS. See comment in do_hres().
>  		 */
>  		while ((seq = READ_ONCE(vd->seq)) & 1) {
>  			if (IS_ENABLED(CONFIG_TIME_NS) &&
> 

-- 
Regards,
Vincenzo

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

* Re: [PATCH 2/5] vdso: Add comment about reason for vdso struct ordering
  2024-07-01 14:47 ` [PATCH 2/5] vdso: Add comment about reason for vdso struct ordering Anna-Maria Behnsen
@ 2024-07-01 15:10   ` Vincenzo Frascino
  2024-07-01 15:31     ` Anna-Maria Behnsen
  2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
  1 sibling, 1 reply; 18+ messages in thread
From: Vincenzo Frascino @ 2024-07-01 15:10 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Andy Lutomirski, Thomas Gleixner; +Cc: linux-kernel



On 01/07/2024 15:47, Anna-Maria Behnsen wrote:
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>

nit: Can you please add something in the commit message?

Otherwise:

Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

> ---
>  include/vdso/datapage.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
> index d04d394db064..7647e0946f50 100644
> --- a/include/vdso/datapage.h
> +++ b/include/vdso/datapage.h
> @@ -77,6 +77,10 @@ struct vdso_timestamp {
>   * vdso_data will be accessed by 64 bit and compat code at the same time
>   * so we should be careful before modifying this structure.
>   *
> + * The ordering of the struct members is optimized to have fast access to the
> + * often required struct members which are related to CLOCK_REALTIME and
> + * CLOCK_MONOTONIC. This information is stored in the first cache lines.
> + *
>   * @basetime is used to store the base time for the system wide time getter
>   * VVAR page.
>   *
> 

-- 
Regards,
Vincenzo

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

* Re: [PATCH 3/5] x86/vdso: Fix function reference in comment
  2024-07-01 14:47 ` [PATCH 3/5] x86/vdso: Fix function reference in comment Anna-Maria Behnsen
@ 2024-07-01 15:11   ` Vincenzo Frascino
  2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
  1 sibling, 0 replies; 18+ messages in thread
From: Vincenzo Frascino @ 2024-07-01 15:11 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Andy Lutomirski, Thomas Gleixner
  Cc: linux-kernel, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin, x86



On 01/07/2024 15:47, Anna-Maria Behnsen wrote:
> Replace the reference to the non-existent function arch_vdso_cycles_valid()
> by the proper function arch_vdso_cycles_ok().
> 
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: x86@kernel.org
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>

Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

> ---
>  arch/x86/include/asm/vdso/gettimeofday.h | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/include/asm/vdso/gettimeofday.h b/arch/x86/include/asm/vdso/gettimeofday.h
> index 0ef36190abe6..b2d2df026f6e 100644
> --- a/arch/x86/include/asm/vdso/gettimeofday.h
> +++ b/arch/x86/include/asm/vdso/gettimeofday.h
> @@ -328,9 +328,8 @@ static __always_inline u64 vdso_calc_ns(const struct vdso_data *vd, u64 cycles,
>  	 * due to unsigned comparison.
>  	 *
>  	 * Due to the MSB/Sign-bit being used as invalid marker (see
> -	 * arch_vdso_cycles_valid() above), the effective mask is S64_MAX,
> -	 * but that case is also unlikely and will also take the unlikely path
> -	 * here.
> +	 * arch_vdso_cycles_ok() above), the effective mask is S64_MAX, but that
> +	 * case is also unlikely and will also take the unlikely path here.
>  	 */
>  	if (unlikely(delta > vd->max_cycles)) {
>  		/*
> 

-- 
Regards,
Vincenzo

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

* Re: [PATCH 4/5] x86/vgtod: Remove unused typedef gtod_long_t
  2024-07-01 14:47 ` [PATCH 4/5] x86/vgtod: Remove unused typedef gtod_long_t Anna-Maria Behnsen
@ 2024-07-01 15:19   ` Vincenzo Frascino
  2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
  1 sibling, 0 replies; 18+ messages in thread
From: Vincenzo Frascino @ 2024-07-01 15:19 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Andy Lutomirski, Thomas Gleixner
  Cc: linux-kernel, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin, x86



On 01/07/2024 15:47, Anna-Maria Behnsen wrote:
> The typedef gtod_long_t is not used anymore so remove it.
> 
> The header file contains then only includes dependent on
> CONFIG_GENERIC_GETTIMEOFDAY to not break ARCH=um. Nevertheless, keep the
> header file only with those includes to prevent spreading ifdeffery all
> over the place.
> 
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: x86@kernel.org
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>

Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

> ---
>  arch/x86/include/asm/vgtod.h | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/arch/x86/include/asm/vgtod.h b/arch/x86/include/asm/vgtod.h
> index 7aa38b2ad8a9..a0ce291abcae 100644
> --- a/arch/x86/include/asm/vgtod.h
> +++ b/arch/x86/include/asm/vgtod.h
> @@ -14,11 +14,6 @@
>  
>  #include <uapi/linux/time.h>
>  
> -#ifdef BUILD_VDSO32_64
> -typedef u64 gtod_long_t;
> -#else
> -typedef unsigned long gtod_long_t;
> -#endif
>  #endif /* CONFIG_GENERIC_GETTIMEOFDAY */
>  
>  #endif /* _ASM_X86_VGTOD_H */
> 

-- 
Regards,
Vincenzo

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

* Re: [PATCH 2/5] vdso: Add comment about reason for vdso struct ordering
  2024-07-01 15:10   ` Vincenzo Frascino
@ 2024-07-01 15:31     ` Anna-Maria Behnsen
  2024-07-01 16:17       ` Vincenzo Frascino
  0 siblings, 1 reply; 18+ messages in thread
From: Anna-Maria Behnsen @ 2024-07-01 15:31 UTC (permalink / raw)
  To: Vincenzo Frascino, Andy Lutomirski, Thomas Gleixner; +Cc: linux-kernel

Vincenzo Frascino <vincenzo.frascino@arm.com> writes:

> On 01/07/2024 15:47, Anna-Maria Behnsen wrote:
>> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
>
> nit: Can you please add something in the commit message?

Sure, I would propose the following:

The struct vdso_data is optimized for fast access to the often required
struct members. The optimization is not documented in the struct
description but it should be kept in mind, when working with the
vdso_data struct.

Add a comment to the struct description.

>
> Otherwise:
>
> Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

Thanks!

>> ---
>>  include/vdso/datapage.h | 4 ++++
>>  1 file changed, 4 insertions(+)
>> 
>> diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
>> index d04d394db064..7647e0946f50 100644
>> --- a/include/vdso/datapage.h
>> +++ b/include/vdso/datapage.h
>> @@ -77,6 +77,10 @@ struct vdso_timestamp {
>>   * vdso_data will be accessed by 64 bit and compat code at the same time
>>   * so we should be careful before modifying this structure.
>>   *
>> + * The ordering of the struct members is optimized to have fast access to the
>> + * often required struct members which are related to CLOCK_REALTIME and
>> + * CLOCK_MONOTONIC. This information is stored in the first cache lines.
>> + *
>>   * @basetime is used to store the base time for the system wide time getter
>>   * VVAR page.
>>   *
>> 

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

* Re: [PATCH 2/5] vdso: Add comment about reason for vdso struct ordering
  2024-07-01 15:31     ` Anna-Maria Behnsen
@ 2024-07-01 16:17       ` Vincenzo Frascino
  0 siblings, 0 replies; 18+ messages in thread
From: Vincenzo Frascino @ 2024-07-01 16:17 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Andy Lutomirski, Thomas Gleixner; +Cc: linux-kernel



On 01/07/2024 16:31, Anna-Maria Behnsen wrote:
> Vincenzo Frascino <vincenzo.frascino@arm.com> writes:
> 
>> On 01/07/2024 15:47, Anna-Maria Behnsen wrote:
>>> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
>>
>> nit: Can you please add something in the commit message?
> 
> Sure, I would propose the following:
> 
> The struct vdso_data is optimized for fast access to the often required
> struct members. The optimization is not documented in the struct
> description but it should be kept in mind, when working with the
> vdso_data struct.
> 
> Add a comment to the struct description.
> 
>>
>> Otherwise:
>>
>> Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> 
> Thanks!
>

Works for me. Thanks!

>>> ---
>>>  include/vdso/datapage.h | 4 ++++
>>>  1 file changed, 4 insertions(+)
>>>
>>> diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
>>> index d04d394db064..7647e0946f50 100644
>>> --- a/include/vdso/datapage.h
>>> +++ b/include/vdso/datapage.h
>>> @@ -77,6 +77,10 @@ struct vdso_timestamp {
>>>   * vdso_data will be accessed by 64 bit and compat code at the same time
>>>   * so we should be careful before modifying this structure.
>>>   *
>>> + * The ordering of the struct members is optimized to have fast access to the
>>> + * often required struct members which are related to CLOCK_REALTIME and
>>> + * CLOCK_MONOTONIC. This information is stored in the first cache lines.
>>> + *
>>>   * @basetime is used to store the base time for the system wide time getter
>>>   * VVAR page.
>>>   *
>>>

-- 
Regards,
Vincenzo

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

* Re: [PATCH 5/5] x86/vdso: Remove unused include
  2024-07-01 14:47 ` [PATCH 5/5] x86/vdso: Remove unused include Anna-Maria Behnsen
@ 2024-07-01 16:19   ` Vincenzo Frascino
  2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
  1 sibling, 0 replies; 18+ messages in thread
From: Vincenzo Frascino @ 2024-07-01 16:19 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Andy Lutomirski, Thomas Gleixner
  Cc: linux-kernel, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin, x86



On 01/07/2024 15:47, Anna-Maria Behnsen wrote:
> Including hrtimer.h is not required and is probably a historical
> leftover. Remove it.
> 
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: x86@kernel.org
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>

Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

> ---
>  arch/x86/include/asm/vdso/vsyscall.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/arch/x86/include/asm/vdso/vsyscall.h b/arch/x86/include/asm/vdso/vsyscall.h
> index be199a9b2676..93226281b450 100644
> --- a/arch/x86/include/asm/vdso/vsyscall.h
> +++ b/arch/x86/include/asm/vdso/vsyscall.h
> @@ -4,7 +4,6 @@
>  
>  #ifndef __ASSEMBLY__
>  
> -#include <linux/hrtimer.h>
>  #include <linux/timekeeper_internal.h>
>  #include <vdso/datapage.h>
>  #include <asm/vgtod.h>
> 

-- 
Regards,
Vincenzo

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

* [tip: timers/core] x86/vdso: Remove unused include
  2024-07-01 14:47 ` [PATCH 5/5] x86/vdso: Remove unused include Anna-Maria Behnsen
  2024-07-01 16:19   ` Vincenzo Frascino
@ 2024-07-03 19:36   ` tip-bot2 for Anna-Maria Behnsen
  1 sibling, 0 replies; 18+ messages in thread
From: tip-bot2 for Anna-Maria Behnsen @ 2024-07-03 19:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Anna-Maria Behnsen, Thomas Gleixner, Vincenzo Frascino, x86,
	linux-kernel

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     2b83be20ae60308f5da31c696137a9561c44c24c
Gitweb:        https://git.kernel.org/tip/2b83be20ae60308f5da31c696137a9561c44c24c
Author:        Anna-Maria Behnsen <anna-maria@linutronix.de>
AuthorDate:    Mon, 01 Jul 2024 16:47:58 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 03 Jul 2024 21:27:04 +02:00

x86/vdso: Remove unused include

Including hrtimer.h is not required and is probably a historical
leftover. Remove it.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20240701-vdso-cleanup-v1-5-36eb64e7ece2@linutronix.de

---
 arch/x86/include/asm/vdso/vsyscall.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/x86/include/asm/vdso/vsyscall.h b/arch/x86/include/asm/vdso/vsyscall.h
index be199a9..9322628 100644
--- a/arch/x86/include/asm/vdso/vsyscall.h
+++ b/arch/x86/include/asm/vdso/vsyscall.h
@@ -4,7 +4,6 @@
 
 #ifndef __ASSEMBLY__
 
-#include <linux/hrtimer.h>
 #include <linux/timekeeper_internal.h>
 #include <vdso/datapage.h>
 #include <asm/vgtod.h>

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

* [tip: timers/core] x86/vgtod: Remove unused typedef gtod_long_t
  2024-07-01 14:47 ` [PATCH 4/5] x86/vgtod: Remove unused typedef gtod_long_t Anna-Maria Behnsen
  2024-07-01 15:19   ` Vincenzo Frascino
@ 2024-07-03 19:36   ` tip-bot2 for Anna-Maria Behnsen
  1 sibling, 0 replies; 18+ messages in thread
From: tip-bot2 for Anna-Maria Behnsen @ 2024-07-03 19:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Anna-Maria Behnsen, Thomas Gleixner, Vincenzo Frascino, x86,
	linux-kernel

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     ee6664d7326bb42c86692b3fdac4edcfb2beab2f
Gitweb:        https://git.kernel.org/tip/ee6664d7326bb42c86692b3fdac4edcfb2beab2f
Author:        Anna-Maria Behnsen <anna-maria@linutronix.de>
AuthorDate:    Mon, 01 Jul 2024 16:47:57 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 03 Jul 2024 21:27:04 +02:00

x86/vgtod: Remove unused typedef gtod_long_t

The typedef gtod_long_t is not used anymore so remove it.

The header file contains then only includes dependent on
CONFIG_GENERIC_GETTIMEOFDAY to not break ARCH=um. Nevertheless, keep the
header file only with those includes to prevent spreading ifdeffery all
over the place.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20240701-vdso-cleanup-v1-4-36eb64e7ece2@linutronix.de

---
 arch/x86/include/asm/vgtod.h | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/x86/include/asm/vgtod.h b/arch/x86/include/asm/vgtod.h
index 7aa38b2..a0ce291 100644
--- a/arch/x86/include/asm/vgtod.h
+++ b/arch/x86/include/asm/vgtod.h
@@ -14,11 +14,6 @@
 
 #include <uapi/linux/time.h>
 
-#ifdef BUILD_VDSO32_64
-typedef u64 gtod_long_t;
-#else
-typedef unsigned long gtod_long_t;
-#endif
 #endif /* CONFIG_GENERIC_GETTIMEOFDAY */
 
 #endif /* _ASM_X86_VGTOD_H */

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

* [tip: timers/core] x86/vdso: Fix function reference in comment
  2024-07-01 14:47 ` [PATCH 3/5] x86/vdso: Fix function reference in comment Anna-Maria Behnsen
  2024-07-01 15:11   ` Vincenzo Frascino
@ 2024-07-03 19:36   ` tip-bot2 for Anna-Maria Behnsen
  1 sibling, 0 replies; 18+ messages in thread
From: tip-bot2 for Anna-Maria Behnsen @ 2024-07-03 19:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Anna-Maria Behnsen, Thomas Gleixner, Vincenzo Frascino, x86,
	linux-kernel

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     7239ae7f8349fba53c74b559b2059b1c20e8966d
Gitweb:        https://git.kernel.org/tip/7239ae7f8349fba53c74b559b2059b1c20e8966d
Author:        Anna-Maria Behnsen <anna-maria@linutronix.de>
AuthorDate:    Mon, 01 Jul 2024 16:47:56 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 03 Jul 2024 21:27:04 +02:00

x86/vdso: Fix function reference in comment

Replace the reference to the non-existent function arch_vdso_cycles_valid()
by the proper function arch_vdso_cycles_ok().

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20240701-vdso-cleanup-v1-3-36eb64e7ece2@linutronix.de

---
 arch/x86/include/asm/vdso/gettimeofday.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/vdso/gettimeofday.h b/arch/x86/include/asm/vdso/gettimeofday.h
index 0ef3619..b2d2df0 100644
--- a/arch/x86/include/asm/vdso/gettimeofday.h
+++ b/arch/x86/include/asm/vdso/gettimeofday.h
@@ -328,9 +328,8 @@ static __always_inline u64 vdso_calc_ns(const struct vdso_data *vd, u64 cycles, 
 	 * due to unsigned comparison.
 	 *
 	 * Due to the MSB/Sign-bit being used as invalid marker (see
-	 * arch_vdso_cycles_valid() above), the effective mask is S64_MAX,
-	 * but that case is also unlikely and will also take the unlikely path
-	 * here.
+	 * arch_vdso_cycles_ok() above), the effective mask is S64_MAX, but that
+	 * case is also unlikely and will also take the unlikely path here.
 	 */
 	if (unlikely(delta > vd->max_cycles)) {
 		/*

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

* [tip: timers/core] vdso: Add comment about reason for vdso struct ordering
  2024-07-01 14:47 ` [PATCH 2/5] vdso: Add comment about reason for vdso struct ordering Anna-Maria Behnsen
  2024-07-01 15:10   ` Vincenzo Frascino
@ 2024-07-03 19:36   ` tip-bot2 for Anna-Maria Behnsen
  1 sibling, 0 replies; 18+ messages in thread
From: tip-bot2 for Anna-Maria Behnsen @ 2024-07-03 19:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Anna-Maria Behnsen, Thomas Gleixner, Vincenzo Frascino, x86,
	linux-kernel

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     d00106bbdfa82732c23cba44491c38f8c410d865
Gitweb:        https://git.kernel.org/tip/d00106bbdfa82732c23cba44491c38f8c410d865
Author:        Anna-Maria Behnsen <anna-maria@linutronix.de>
AuthorDate:    Mon, 01 Jul 2024 16:47:55 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 03 Jul 2024 21:27:03 +02:00

vdso: Add comment about reason for vdso struct ordering

struct vdso_data is optimized for fast access to the often required struct
members. The optimization is not documented in the struct description but
it should be kept in mind, when working with the vdso_data struct.
                                                                                                                                                                                                                                             
Add a comment to the struct description.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20240701-vdso-cleanup-v1-2-36eb64e7ece2@linutronix.de

---
 include/vdso/datapage.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
index d04d394..7647e09 100644
--- a/include/vdso/datapage.h
+++ b/include/vdso/datapage.h
@@ -77,6 +77,10 @@ struct vdso_timestamp {
  * vdso_data will be accessed by 64 bit and compat code at the same time
  * so we should be careful before modifying this structure.
  *
+ * The ordering of the struct members is optimized to have fast access to the
+ * often required struct members which are related to CLOCK_REALTIME and
+ * CLOCK_MONOTONIC. This information is stored in the first cache lines.
+ *
  * @basetime is used to store the base time for the system wide time getter
  * VVAR page.
  *

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

* [tip: timers/core] vdso/gettimeofday: Clarify comment about open coded function
  2024-07-01 14:47 ` [PATCH 1/5] vdso/gettimeofday: Clarify comment about open coded function Anna-Maria Behnsen
  2024-07-01 14:58   ` Vincenzo Frascino
@ 2024-07-03 19:36   ` tip-bot2 for Anna-Maria Behnsen
  1 sibling, 0 replies; 18+ messages in thread
From: tip-bot2 for Anna-Maria Behnsen @ 2024-07-03 19:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Anna-Maria Behnsen, Thomas Gleixner, Vincenzo Frascino, x86,
	linux-kernel

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     f48955e038eaf43812c3701079c7371abe0315a4
Gitweb:        https://git.kernel.org/tip/f48955e038eaf43812c3701079c7371abe0315a4
Author:        Anna-Maria Behnsen <anna-maria@linutronix.de>
AuthorDate:    Mon, 01 Jul 2024 16:47:54 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 03 Jul 2024 21:27:03 +02:00

vdso/gettimeofday: Clarify comment about open coded function

The two comments state, that the following code open codes something but
they lack to specify what exactly is open coded.

Expand comments by mentioning the reference to the open coded function.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20240701-vdso-cleanup-v1-1-36eb64e7ece2@linutronix.de

---
 lib/vdso/gettimeofday.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
index 899850b..c01eaaf 100644
--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -140,14 +140,14 @@ static __always_inline int do_hres(const struct vdso_data *vd, clockid_t clk,
 
 	do {
 		/*
-		 * Open coded to handle VDSO_CLOCKMODE_TIMENS. Time namespace
-		 * enabled tasks have a special VVAR page installed which
-		 * has vd->seq set to 1 and vd->clock_mode set to
-		 * VDSO_CLOCKMODE_TIMENS. For non time namespace affected tasks
-		 * this does not affect performance because if vd->seq is
-		 * odd, i.e. a concurrent update is in progress the extra
-		 * check for vd->clock_mode is just a few extra
-		 * instructions while spin waiting for vd->seq to become
+		 * Open coded function vdso_read_begin() to handle
+		 * VDSO_CLOCKMODE_TIMENS. Time namespace enabled tasks have a
+		 * special VVAR page installed which has vd->seq set to 1 and
+		 * vd->clock_mode set to VDSO_CLOCKMODE_TIMENS. For non time
+		 * namespace affected tasks this does not affect performance
+		 * because if vd->seq is odd, i.e. a concurrent update is in
+		 * progress the extra check for vd->clock_mode is just a few
+		 * extra instructions while spin waiting for vd->seq to become
 		 * even again.
 		 */
 		while (unlikely((seq = READ_ONCE(vd->seq)) & 1)) {
@@ -223,8 +223,8 @@ static __always_inline int do_coarse(const struct vdso_data *vd, clockid_t clk,
 
 	do {
 		/*
-		 * Open coded to handle VDSO_CLOCK_TIMENS. See comment in
-		 * do_hres().
+		 * Open coded function vdso_read_begin() to handle
+		 * VDSO_CLOCK_TIMENS. See comment in do_hres().
 		 */
 		while ((seq = READ_ONCE(vd->seq)) & 1) {
 			if (IS_ENABLED(CONFIG_TIME_NS) &&

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

end of thread, other threads:[~2024-07-03 19:36 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-01 14:47 [PATCH 0/5] vdso (generic and x86): Misc minor cleanups Anna-Maria Behnsen
2024-07-01 14:47 ` [PATCH 1/5] vdso/gettimeofday: Clarify comment about open coded function Anna-Maria Behnsen
2024-07-01 14:58   ` Vincenzo Frascino
2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
2024-07-01 14:47 ` [PATCH 2/5] vdso: Add comment about reason for vdso struct ordering Anna-Maria Behnsen
2024-07-01 15:10   ` Vincenzo Frascino
2024-07-01 15:31     ` Anna-Maria Behnsen
2024-07-01 16:17       ` Vincenzo Frascino
2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
2024-07-01 14:47 ` [PATCH 3/5] x86/vdso: Fix function reference in comment Anna-Maria Behnsen
2024-07-01 15:11   ` Vincenzo Frascino
2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
2024-07-01 14:47 ` [PATCH 4/5] x86/vgtod: Remove unused typedef gtod_long_t Anna-Maria Behnsen
2024-07-01 15:19   ` Vincenzo Frascino
2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
2024-07-01 14:47 ` [PATCH 5/5] x86/vdso: Remove unused include Anna-Maria Behnsen
2024-07-01 16:19   ` Vincenzo Frascino
2024-07-03 19:36   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox