Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

random: Use this_cpu_inc_return

__this_cpu_inc can create a single instruction to do the same as
__get_cpu_var()++.

Cc: Richard Kennedy <richard@rsk.demon.co.uk>
Cc: Matt Mackall <mpm@selenic.com>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Christoph Lameter and committed by
Tejun Heo
b29c617a ee1be862

+1 -1
+1 -1
drivers/char/random.c
··· 626 626 preempt_disable(); 627 627 /* if over the trickle threshold, use only 1 in 4096 samples */ 628 628 if (input_pool.entropy_count > trickle_thresh && 629 - (__get_cpu_var(trickle_count)++ & 0xfff)) 629 + ((__this_cpu_inc_return(trickle_count) - 1) & 0xfff)) 630 630 goto out; 631 631 632 632 sample.jiffies = jiffies;