Subject: Re: [PATCH v4 1/1] rps: core implementation

From: Eric Dumazet <[email-masked]>
Date: Sat, 21 Nov 2009 10:31:31 +0100

>>        percpu_add(netdev_rx_stat.total, 1);
>>        spin_lock_irqsave(&queue->input_pkt_queue.lock, flags);
>>
> Would it make sense to percpu_add into dev.c just for this when other
> parts in dev.c would still use __get_cpu_var(stat)++?  Also, I think
> this results in more instructions...

Dont worry, this is out of RPS scope anyway, but percpu_add() is
better on x86 at least.

	__get_cpu_var(netdev_rx_stat).total++;
->
	mov    $0xc17aa6b8,%eax  // per_cpu__netdev_rx_stat
	mov    %fs:0xc17a77c0,%edx // per_cpu__this_cpu_off
	incl   (%edx,%eax,1)

While

	percpu_add(netdev_rx_stat.total, 1);
->
	addl   $0x1,%fs:0xc17aa6b8 // per_cpu__netdev_rx_stat

Later can be done in any context, and use no register, so :

1) we reduce window with disabled interrupts.
2) allow compiler to not scratch two registers.