Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/mempolicy: skip unnecessary synchronize_rcu()

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.

Link: https://lkml.kernel.org/r/20250602162345.2595696-2-joshua.hahnjy@gmail.com
Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com>
Suggested-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Huang Ying <ying.huang@linux.alibaba.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Gregory Price <gourry@gourry.net>
Cc: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: kernel test robot <lkp@intel.com>
Cc: Mathew Brost <matthew.brost@intel.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Joshua Hahn and committed by
Andrew Morton
1ec8a6e3 1e6b17b4

+5 -8
+5 -8
mm/mempolicy.c
··· 3703 3703 struct weighted_interleave_state *old_wi_state; 3704 3704 3705 3705 mutex_lock(&wi_state_lock); 3706 - 3707 3706 old_wi_state = rcu_dereference_protected(wi_state, 3708 3707 lockdep_is_held(&wi_state_lock)); 3709 - if (!old_wi_state) { 3710 - mutex_unlock(&wi_state_lock); 3711 - return; 3712 - } 3713 - 3714 3708 rcu_assign_pointer(wi_state, NULL); 3715 3709 mutex_unlock(&wi_state_lock); 3716 - synchronize_rcu(); 3717 - kfree(old_wi_state); 3710 + 3711 + if (old_wi_state) { 3712 + synchronize_rcu(); 3713 + kfree(old_wi_state); 3714 + } 3718 3715 } 3719 3716 3720 3717 static struct kobj_attribute wi_auto_attr =