mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 08:33:17 +02:00
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>
This commit is contained in:
parent
1e6b17b423
commit
1ec8a6e30e
|
|
@ -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 =
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user