Re: [RFC PATCH] introduce sys_membarrier(): process-wide memorybarrier (v5)
From: Peter Zijlstra
Date: Wed Jan 13 2010 - 11:40:17 EST
On Tue, 2010-01-12 at 20:37 -0500, Mathieu Desnoyers wrote:
> + for_each_cpu(cpu, tmpmask) {
> + spin_lock_irq(&cpu_rq(cpu)->lock);
> + mm = cpu_curr(cpu)->mm;
> + spin_unlock_irq(&cpu_rq(cpu)->lock);
> + if (current->mm != mm)
> + cpumask_clear_cpu(cpu, tmpmask);
> + }
Why not:
rcu_read_lock();
if (current->mm != cpu_curr(cpu)->mm)
cpumask_clear_cpu(cpu, tmpmask);
rcu_read_unlock();
the RCU read lock ensures the task_struct obtained remains valid, and it
avoids taking the rq->lock.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/