diff mbox series

[SRU,X,1/1] clocksource: Defer override invalidation unless clock is unstable

Message ID 20200907041528.12540-2-matthew.ruffell@canonical.com
State New
Headers show
Series clock: overriding the clocksource should select the requested clocksource | expand

Commit Message

Matthew Ruffell Sept. 7, 2020, 4:15 a.m. UTC
From: Kyle Walker <kwalker@redhat.com>

BugLink: https://bugs.launchpad.net/bugs/1894591

Clocksources don't get the VALID_FOR_HRES flag until they have been
checked by a watchdog. However, when using an override, the
clocksource_select logic will clear the override value if the
clocksource is not marked VALID_FOR_HRES during that inititial check.
When using the boot arguments clocksource=<foo>, this selection can
run before the watchdog, and can cause the override to be incorrectly
cleared.

To address this condition, the override_name is only invalidated for
unstable clocksources. Otherwise, the override is left intact until after
the watchdog has validated the clocksource as stable/unstable.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Kyle Walker <kwalker@redhat.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
(cherry picked from commit 36374583f9084cdab4b5dcf5521a3ce55bebb9fa)
Signed-off-by: Matthew Ruffell <matthew.ruffell@canonical.com>
---
 kernel/time/clocksource.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Kleber Sacilotto de Souza Sept. 15, 2020, 9:23 a.m. UTC | #1
On 07.09.20 06:15, Matthew Ruffell wrote:
> From: Kyle Walker <kwalker@redhat.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1894591
> 
> Clocksources don't get the VALID_FOR_HRES flag until they have been
> checked by a watchdog. However, when using an override, the
> clocksource_select logic will clear the override value if the
> clocksource is not marked VALID_FOR_HRES during that inititial check.
> When using the boot arguments clocksource=<foo>, this selection can
> run before the watchdog, and can cause the override to be incorrectly
> cleared.
> 
> To address this condition, the override_name is only invalidated for
> unstable clocksources. Otherwise, the override is left intact until after
> the watchdog has validated the clocksource as stable/unstable.
> 
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Richard Cochran <richardcochran@gmail.com>
> Cc: Prarit Bhargava <prarit@redhat.com>
> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Signed-off-by: Kyle Walker <kwalker@redhat.com>
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> (cherry picked from commit 36374583f9084cdab4b5dcf5521a3ce55bebb9fa)
> Signed-off-by: Matthew Ruffell <matthew.ruffell@canonical.com>

Clean cherry-pick and positive test result.

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>


Thanks.

> ---
>  kernel/time/clocksource.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
> index a20368e1a720..ac4c84361be0 100644
> --- a/kernel/time/clocksource.c
> +++ b/kernel/time/clocksource.c
> @@ -607,9 +607,18 @@ static void __clocksource_select(bool skipcur)
>  		 */
>  		if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && oneshot) {
>  			/* Override clocksource cannot be used. */
> -			pr_warn("Override clocksource %s is not HRT compatible - cannot switch while in HRT/NOHZ mode\n",
> -				cs->name);
> -			override_name[0] = 0;
> +			if (cs->flags & CLOCK_SOURCE_UNSTABLE) {
> +				pr_warn("Override clocksource %s is unstable and not HRT compatible - cannot switch while in HRT/NOHZ mode\n",
> +					cs->name);
> +				override_name[0] = 0;
> +			} else {
> +				/*
> +				 * The override cannot be currently verified.
> +				 * Deferring to let the watchdog check.
> +				 */
> +				pr_info("Override clocksource %s is not currently HRT compatible - deferring\n",
> +					cs->name);
> +			}
>  		} else
>  			/* Override clocksource can be used. */
>  			best = cs;
>
William Breathitt Gray Sept. 15, 2020, 1 p.m. UTC | #2
On Mon, Sep 07, 2020 at 04:15:28PM +1200, Matthew Ruffell wrote:
> From: Kyle Walker <kwalker@redhat.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1894591
> 
> Clocksources don't get the VALID_FOR_HRES flag until they have been
> checked by a watchdog. However, when using an override, the
> clocksource_select logic will clear the override value if the
> clocksource is not marked VALID_FOR_HRES during that inititial check.
> When using the boot arguments clocksource=<foo>, this selection can
> run before the watchdog, and can cause the override to be incorrectly
> cleared.
> 
> To address this condition, the override_name is only invalidated for
> unstable clocksources. Otherwise, the override is left intact until after
> the watchdog has validated the clocksource as stable/unstable.
> 
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Richard Cochran <richardcochran@gmail.com>
> Cc: Prarit Bhargava <prarit@redhat.com>
> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Signed-off-by: Kyle Walker <kwalker@redhat.com>
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> (cherry picked from commit 36374583f9084cdab4b5dcf5521a3ce55bebb9fa)
> Signed-off-by: Matthew Ruffell <matthew.ruffell@canonical.com>
> ---
>  kernel/time/clocksource.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
> index a20368e1a720..ac4c84361be0 100644
> --- a/kernel/time/clocksource.c
> +++ b/kernel/time/clocksource.c
> @@ -607,9 +607,18 @@ static void __clocksource_select(bool skipcur)
>  		 */
>  		if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && oneshot) {
>  			/* Override clocksource cannot be used. */
> -			pr_warn("Override clocksource %s is not HRT compatible - cannot switch while in HRT/NOHZ mode\n",
> -				cs->name);
> -			override_name[0] = 0;
> +			if (cs->flags & CLOCK_SOURCE_UNSTABLE) {
> +				pr_warn("Override clocksource %s is unstable and not HRT compatible - cannot switch while in HRT/NOHZ mode\n",
> +					cs->name);
> +				override_name[0] = 0;
> +			} else {
> +				/*
> +				 * The override cannot be currently verified.
> +				 * Deferring to let the watchdog check.
> +				 */
> +				pr_info("Override clocksource %s is not currently HRT compatible - deferring\n",
> +					cs->name);
> +			}
>  		} else
>  			/* Override clocksource can be used. */
>  			best = cs;
> -- 
> 2.25.1

Acked-by: William Breathitt Gray <william.gray@canonical.com>
diff mbox series

Patch

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index a20368e1a720..ac4c84361be0 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -607,9 +607,18 @@  static void __clocksource_select(bool skipcur)
 		 */
 		if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && oneshot) {
 			/* Override clocksource cannot be used. */
-			pr_warn("Override clocksource %s is not HRT compatible - cannot switch while in HRT/NOHZ mode\n",
-				cs->name);
-			override_name[0] = 0;
+			if (cs->flags & CLOCK_SOURCE_UNSTABLE) {
+				pr_warn("Override clocksource %s is unstable and not HRT compatible - cannot switch while in HRT/NOHZ mode\n",
+					cs->name);
+				override_name[0] = 0;
+			} else {
+				/*
+				 * The override cannot be currently verified.
+				 * Deferring to let the watchdog check.
+				 */
+				pr_info("Override clocksource %s is not currently HRT compatible - deferring\n",
+					cs->name);
+			}
 		} else
 			/* Override clocksource can be used. */
 			best = cs;