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

net: rds: use this_cpu_* per-cpu helper

Signed-off-by: Shan Wei <davidshan@tencent.com>
Reviewed-by: Christoph Lameter <cl@linux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Shan Wei and committed by
David S. Miller
ae4b46e9 1f743b07

+14 -12
+1 -1
net/rds/ib.h
··· 50 50 }; 51 51 52 52 struct rds_ib_refill_cache { 53 - struct rds_ib_cache_head *percpu; 53 + struct rds_ib_cache_head __percpu *percpu; 54 54 struct list_head *xfer; 55 55 struct list_head *ready; 56 56 };
+13 -11
net/rds/ib_recv.c
··· 418 418 struct rds_ib_refill_cache *cache) 419 419 { 420 420 unsigned long flags; 421 - struct rds_ib_cache_head *chp; 422 421 struct list_head *old; 422 + struct list_head __percpu *chpfirst; 423 423 424 424 local_irq_save(flags); 425 425 426 - chp = per_cpu_ptr(cache->percpu, smp_processor_id()); 427 - if (!chp->first) 426 + chpfirst = __this_cpu_read(cache->percpu->first); 427 + if (!chpfirst) 428 428 INIT_LIST_HEAD(new_item); 429 429 else /* put on front */ 430 - list_add_tail(new_item, chp->first); 431 - chp->first = new_item; 432 - chp->count++; 430 + list_add_tail(new_item, chpfirst); 433 431 434 - if (chp->count < RDS_IB_RECYCLE_BATCH_COUNT) 432 + __this_cpu_write(chpfirst, new_item); 433 + __this_cpu_inc(cache->percpu->count); 434 + 435 + if (__this_cpu_read(cache->percpu->count) < RDS_IB_RECYCLE_BATCH_COUNT) 435 436 goto end; 436 437 437 438 /* ··· 444 443 do { 445 444 old = xchg(&cache->xfer, NULL); 446 445 if (old) 447 - list_splice_entire_tail(old, chp->first); 448 - old = cmpxchg(&cache->xfer, NULL, chp->first); 446 + list_splice_entire_tail(old, chpfirst); 447 + old = cmpxchg(&cache->xfer, NULL, chpfirst); 449 448 } while (old); 450 449 451 - chp->first = NULL; 452 - chp->count = 0; 450 + 451 + __this_cpu_write(chpfirst, NULL); 452 + __this_cpu_write(cache->percpu->count, 0); 453 453 end: 454 454 local_irq_restore(flags); 455 455 }