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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3a275469-63aa-4929-acbc-28b7ea4b7bc9@paulmck-laptop>
Date:   Fri, 21 Jul 2023 15:45:43 -0700
From:   "Paul E. McKenney" <paulmck@...nel.org>
To:     thunder.leizhen@...weicloud.com
Cc:     Frederic Weisbecker <frederic@...nel.org>,
        Neeraj Upadhyay <quic_neeraju@...cinc.com>,
        Joel Fernandes <joel@...lfernandes.org>,
        Josh Triplett <josh@...htriplett.org>,
        Boqun Feng <boqun.feng@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        Lai Jiangshan <jiangshanlai@...il.com>,
        Zqiang <qiang.zhang1211@...il.com>, rcu@...r.kernel.org,
        linux-kernel@...r.kernel.org, Zhen Lei <thunder.leizhen@...wei.com>
Subject: Re: [PATCH 2/2] rcu: Simplify check_cpu_stall()

On Fri, Jul 21, 2023 at 03:57:16PM +0800, thunder.leizhen@...weicloud.com wrote:
> From: Zhen Lei <thunder.leizhen@...wei.com>
> 
> The code and comments of self detected and other detected are the same
> except the output function. Combine the same parts to avoid duplication.
> 
> Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>

This looks like a nice simplification, thank you!

Please make this not depend on the earlier patch and resend.

							Thanx, Paul

> ---
>  kernel/rcu/tree_stall.h | 36 +++++++++++-------------------------
>  1 file changed, 11 insertions(+), 25 deletions(-)
> 
> diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
> index 371713f3f7d15d9..0ade7f9dcaa18da 100644
> --- a/kernel/rcu/tree_stall.h
> +++ b/kernel/rcu/tree_stall.h
> @@ -711,7 +711,7 @@ static void print_cpu_stall(unsigned long gps)
>  
>  static void check_cpu_stall(struct rcu_data *rdp)
>  {
> -	bool didstall = false;
> +	bool self_detected;
>  	unsigned long gs1;
>  	unsigned long gs2;
>  	unsigned long gps;
> @@ -758,10 +758,10 @@ static void check_cpu_stall(struct rcu_data *rdp)
>  		return; /* No stall or GP completed since entering function. */
>  	rnp = rdp->mynode;
>  	jn = jiffies + ULONG_MAX / 2;
> +	self_detected = READ_ONCE(rnp->qsmask) & rdp->grpmask;
>  	if (rcu_gp_in_progress() &&
> -	    (READ_ONCE(rnp->qsmask) & rdp->grpmask) &&
> +	    (self_detected || ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY)) &&
>  	    cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
> -
>  		/*
>  		 * If a virtual machine is stopped by the host it can look to
>  		 * the watchdog like an RCU stall. Check to see if the host
> @@ -770,31 +770,17 @@ static void check_cpu_stall(struct rcu_data *rdp)
>  		if (kvm_check_and_clear_guest_paused())
>  			return;
>  
> -		/* We haven't checked in, so go dump stack. */
> -		print_cpu_stall(gps);
> -		if (READ_ONCE(rcu_cpu_stall_ftrace_dump))
> -			rcu_ftrace_dump(DUMP_ALL);
> -		didstall = true;
> -
> -	} else if (rcu_gp_in_progress() &&
> -		   ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY) &&
> -		   cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
> -
> -		/*
> -		 * If a virtual machine is stopped by the host it can look to
> -		 * the watchdog like an RCU stall. Check to see if the host
> -		 * stopped the vm.
> -		 */
> -		if (kvm_check_and_clear_guest_paused())
> -			return;
> +		if (self_detected) {
> +			/* We haven't checked in, so go dump stack. */
> +			print_cpu_stall(gps);
> +		} else {
> +			/* They had a few time units to dump stack, so complain. */
> +			print_other_cpu_stall(gs2, gps);
> +		}
>  
> -		/* They had a few time units to dump stack, so complain. */
> -		print_other_cpu_stall(gs2, gps);
>  		if (READ_ONCE(rcu_cpu_stall_ftrace_dump))
>  			rcu_ftrace_dump(DUMP_ALL);
> -		didstall = true;
> -	}
> -	if (didstall) {
> +
>  		jn = jiffies + 3 * rcu_jiffies_till_stall_check() + 3;
>  		WRITE_ONCE(rcu_state.jiffies_stall, jn);
>  	}
> -- 
> 2.25.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ