lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZliaSISeFxx_FQ6O@localhost.localdomain>
Date: Thu, 30 May 2024 17:24:56 +0200
From: Frederic Weisbecker <frederic@...nel.org>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
	Anna-Maria Behnsen <anna-maria@...utronix.de>,
	Ingo Molnar <mingo@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tick: shift tick_nohz_switch_to_nohz() from
 tick_check_oneshot_change() to hrtimer_run_queues()

Le Thu, May 30, 2024 at 02:42:03PM +0200, Oleg Nesterov a écrit :
> hrtimer_run_queues() calls tick_check_oneshot_change() to check if we
> can switch to highres or nohz mode, but the current code looks very
> confusing to me. In the highres=n or CONFIG_HIGH_RES_TIMERS=n cases
> tick_check_oneshot_change() itself calls tick_nohz_switch_to_nohz()
> and returns zero; that is why it needs the "allow_nohz" argument,
> which imo also adds confusion.
> 
> This patch turns tick_check_oneshot_change() into a "pure" function
> without arguments. hrtimer_run_queues() calls hrtimer_switch_to_hres()
> or tick_nohz_switch_to_nohz() depending on hrtimer_is_hres_enabled().
> 
> Signed-off-by: Oleg Nesterov <oleg@...hat.com>
> ---
>  kernel/time/hrtimer.c       |  7 +++++--
>  kernel/time/tick-internal.h |  6 ++++--
>  kernel/time/tick-sched.c    | 15 ++++-----------
>  3 files changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
> index 492c14aac642..806f352b095d 100644
> --- a/kernel/time/hrtimer.c
> +++ b/kernel/time/hrtimer.c
> @@ -1891,8 +1891,11 @@ void hrtimer_run_queues(void)
>  	 * there only sets the check bit in the tick_oneshot code,
>  	 * otherwise we might deadlock vs. xtime_lock.
>  	 */
> -	if (tick_check_oneshot_change(!hrtimer_is_hres_enabled())) {
> -		hrtimer_switch_to_hres();
> +	if (tick_check_oneshot_change()) {
> +		if (hrtimer_is_hres_enabled())
> +			hrtimer_switch_to_hres();
> +		else
> +			tick_nohz_switch_to_nohz();

Thanks a lot for clarifying this! I've always found that confusing
(and note how I never did anything about it!)

Just a detail below:

>  		return;
>  	}
>  
> diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h
> index 5f2105e637bd..6764fbd18afd 100644
> --- a/kernel/time/tick-internal.h
> +++ b/kernel/time/tick-internal.h
> @@ -111,7 +111,8 @@ extern void tick_resume_oneshot(void);
>  static inline bool tick_oneshot_possible(void) { return true; }
>  extern int tick_oneshot_mode_active(void);
>  extern void tick_clock_notify(void);
> -extern int tick_check_oneshot_change(int allow_nohz);
> +extern int tick_check_oneshot_change(void);
> +extern void tick_nohz_switch_to_nohz(void);

tick_nohz_switch_to_nohz() is only built with CONFIG_NO_HZ_COMMON

You will have a build issue with CONFIG_HIGH_RES_TIMER && !CONFIG_NO_HZ_COMMON

>  extern int tick_init_highres(void);
>  #else /* !CONFIG_TICK_ONESHOT: */
>  static inline
> @@ -124,7 +125,8 @@ static inline void tick_oneshot_notify(void) { }
>  static inline bool tick_oneshot_possible(void) { return false; }
>  static inline int tick_oneshot_mode_active(void) { return 0; }
>  static inline void tick_clock_notify(void) { }
> -static inline int tick_check_oneshot_change(int allow_nohz) { return 0; }
> +static inline int tick_check_oneshot_change(void) { return 0; }
> +static inline void tick_nohz_switch_to_nohz(void) { }
>  #endif /* !CONFIG_TICK_ONESHOT */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ