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: <87h60xtw0p.fsf@DESKTOP-5N7EMDA>
Date: Tue, 03 Jun 2025 10:10:46 +0800
From: "Huang, Ying" <ying.huang@...ux.alibaba.com>
To: Joshua Hahn <joshua.hahnjy@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,  Gregory Price
 <gourry@...rry.net>,  David Hildenbrand <david@...hat.com>,  Zi Yan
 <ziy@...dia.com>,  Matthew Brost <matthew.brost@...el.com>,  Rakie Kim
 <rakie.kim@...com>,  Byungchul Park <byungchul@...com>,  Alistair Popple
 <apopple@...dia.com>,  linux-mm@...ck.org,  linux-kernel@...r.kernel.org,
  kernel-team@...a.com
Subject: Re: [PATCH 2/2] mm/mempolicy: Skip unnecessary synchronize_rcu()

Joshua Hahn <joshua.hahnjy@...il.com> writes:

> By unconditionally setting wi_state to NULL and conditionally calling
> synchronize_rcu(), we can save an unncessary call when there is no
> old_wi_state.

Per my understanding, in the original code, if !old_wi_state, we will
return immediately instead of calling synchronize_rcu() too.  Or I miss
something?

The patch itself is a nice cleanup with reduced line number.  Feel free
to add my

Reviewed-by: Huang Ying <ying.huang@...ux.alibaba.com>

in the future version.

> Suggested-by: David Hildenbrand <david@...hat.com>
> Signed-off-by: Joshua Hahn <joshua.hahnjy@...il.com>
> ---
>  mm/mempolicy.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 3b1dfd08338b..b0619d0020c9 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -3703,18 +3703,15 @@ static void wi_state_free(void)
>  	struct weighted_interleave_state *old_wi_state;
>  
>  	mutex_lock(&wi_state_lock);
> -
>  	old_wi_state = rcu_dereference_protected(wi_state,
>  			lockdep_is_held(&wi_state_lock));
> -	if (!old_wi_state) {
> -		mutex_unlock(&wi_state_lock);
> -		return;
> -	}
> -
>  	rcu_assign_pointer(wi_state, NULL);
>  	mutex_unlock(&wi_state_lock);
> -	synchronize_rcu();
> -	kfree(old_wi_state);
> +
> +	if (old_wi_state) {
> +		synchronize_rcu();
> +		kfree(old_wi_state);
> +	}
>  }
>  
>  static struct kobj_attribute wi_auto_attr =

---
Best Regards,
Huang, Ying

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ