Re: [Use cpuops V1 05/11] core: Replace __get_cpu_var with __this_cpu_readif not used for an address.

From: Tejun Heo
Date: Tue Dec 07 2010 - 09:31:15 EST


Hello,

On 12/06/2010 06:16 PM, Christoph Lameter wrote:
> __get_cpu_var() can be replaced with this_cpu_read and will then use a single
> read instruction with implied address calculation to access the correct per cpu
> instance.
>
> However, the address of a per cpu variable passed to __this_cpu_read() cannot be
> determed (since its an implied address conversion through segment prefixes).
> Therefore apply this only to uses of __get_cpu_var where the addres of the
> variable is not used.
>
> Cc: Pekka Enberg <penberg@xxxxxxxxxxxxxx>
> Cc: Hugh Dickins <hughd@xxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Signed-off-by: Christoph Lameter <cl@xxxxxxxxx>
...
> @@ -802,18 +802,18 @@ static void takeover_tasklets(unsigned i
>
> /* Find end, append list for that CPU. */
> if (&per_cpu(tasklet_vec, cpu).head != per_cpu(tasklet_vec, cpu).tail) {
> - *(__get_cpu_var(tasklet_vec).tail) = per_cpu(tasklet_vec, cpu).head;
> - __get_cpu_var(tasklet_vec).tail = per_cpu(tasklet_vec, cpu).tail;
> + *__this_cpu_read(tasklet_vec.tail) = per_cpu(tasklet_vec, cpu).head;
> + this_cpu_write(tasklet_vec.tail, per_cpu(tasklet_vec, cpu).tail);
> per_cpu(tasklet_vec, cpu).head = NULL;
> per_cpu(tasklet_vec, cpu).tail = &per_cpu(tasklet_vec, cpu).head;
> }
> raise_softirq_irqoff(TASKLET_SOFTIRQ);
>
> if (&per_cpu(tasklet_hi_vec, cpu).head != per_cpu(tasklet_hi_vec, cpu).tail) {
> - *__get_cpu_var(tasklet_hi_vec).tail = per_cpu(tasklet_hi_vec, cpu).head;
> - __get_cpu_var(tasklet_hi_vec).tail = per_cpu(tasklet_hi_vec, cpu).tail;
> + *__this_cpuo_read(tasklet_hi_vec.tail) = per_cpu(tasklet_hi_vec, cpu).head;
> + __this_cpu_write(tasklet_hi_vec.tail, per_cpu(tasklet_hi_vec, cpu).tail;

I don't think __this_cpuo_read() would build.

--
tejun
--
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/