mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
sched/membarrier: Modernize membarrier_global_expedited with cleanup guards
Replace explicit lock/unlock and free calls with scoped guards and automatic cleanup constructs. Signed-off-by: Aniket Gattani <aniketgattani@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20260503212205.3714217-3-aniketgattani@google.com
This commit is contained in:
parent
89976cd737
commit
a595972854
|
|
@ -267,23 +267,19 @@ void membarrier_update_current_mm(struct mm_struct *next_mm)
|
|||
|
||||
static int membarrier_global_expedited(void)
|
||||
{
|
||||
cpumask_var_t __free(free_cpumask_var) tmpmask = CPUMASK_VAR_NULL;
|
||||
int cpu;
|
||||
cpumask_var_t tmpmask;
|
||||
|
||||
if (num_online_cpus() == 1)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Matches memory barriers after rq->curr modification in
|
||||
* scheduler.
|
||||
*/
|
||||
smp_mb(); /* system call entry is not a mb. */
|
||||
|
||||
if (!zalloc_cpumask_var(&tmpmask, GFP_KERNEL))
|
||||
return -ENOMEM;
|
||||
|
||||
guard(mb)();
|
||||
SERIALIZE_IPI();
|
||||
cpus_read_lock();
|
||||
guard(cpus_read_lock)();
|
||||
|
||||
rcu_read_lock();
|
||||
for_each_online_cpu(cpu) {
|
||||
struct task_struct *p;
|
||||
|
|
@ -319,15 +315,6 @@ static int membarrier_global_expedited(void)
|
|||
smp_call_function_many(tmpmask, ipi_mb, NULL, 1);
|
||||
preempt_enable();
|
||||
|
||||
free_cpumask_var(tmpmask);
|
||||
cpus_read_unlock();
|
||||
|
||||
/*
|
||||
* Memory barrier on the caller thread _after_ we finished
|
||||
* waiting for the last IPI. Matches memory barriers before
|
||||
* rq->curr modification in scheduler.
|
||||
*/
|
||||
smp_mb(); /* exit from system call is not a mb */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user