Skip to content

Commit 933393f

Browse files
Christoph Lameterhtejun
authored andcommitted
percpu: Remove irqsafe_cpu_xxx variants
We simply say that regular this_cpu use must be safe regardless of preemption and interrupt state. That has no material change for x86 and s390 implementations of this_cpu operations. However, arches that do not provide their own implementation for this_cpu operations will now get code generated that disables interrupts instead of preemption. -tj: This is part of on-going percpu API cleanup. For detailed discussion of the subject, please refer to the following thread. http://thread.gmane.org/gmane.linux.kernel/1222078 Signed-off-by: Christoph Lameter <cl@linux.com> Signed-off-by: Tejun Heo <tj@kernel.org> LKML-Reference: <alpine.DEB.2.00.1112221154380.11787@router.home>
1 parent ecefc36 commit 933393f

9 files changed

Lines changed: 62 additions & 236 deletions

File tree

‎arch/s390/include/asm/percpu.h‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define ARCH_NEEDS_WEAK_PER_CPU
2020
#endif
2121

22-
#define arch_irqsafe_cpu_to_op(pcp, val, op) \
22+
#define arch_this_cpu_to_op(pcp, val, op) \
2323
do { \
2424
typedef typeof(pcp) pcp_op_T__; \
2525
pcp_op_T__ old__, new__, prev__; \
@@ -41,27 +41,27 @@ do { \
4141
preempt_enable(); \
4242
} while (0)
4343

44-
#define irqsafe_cpu_add_1(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, +)
45-
#define irqsafe_cpu_add_2(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, +)
46-
#define irqsafe_cpu_add_4(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, +)
47-
#define irqsafe_cpu_add_8(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, +)
44+
#define this_cpu_add_1(pcp, val) arch_this_cpu_to_op(pcp, val, +)
45+
#define this_cpu_add_2(pcp, val) arch_this_cpu_to_op(pcp, val, +)
46+
#define this_cpu_add_4(pcp, val) arch_this_cpu_to_op(pcp, val, +)
47+
#define this_cpu_add_8(pcp, val) arch_this_cpu_to_op(pcp, val, +)
4848

49-
#define irqsafe_cpu_and_1(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, &)
50-
#define irqsafe_cpu_and_2(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, &)
51-
#define irqsafe_cpu_and_4(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, &)
52-
#define irqsafe_cpu_and_8(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, &)
49+
#define this_cpu_and_1(pcp, val) arch_this_cpu_to_op(pcp, val, &)
50+
#define this_cpu_and_2(pcp, val) arch_this_cpu_to_op(pcp, val, &)
51+
#define this_cpu_and_4(pcp, val) arch_this_cpu_to_op(pcp, val, &)
52+
#define this_cpu_and_8(pcp, val) arch_this_cpu_to_op(pcp, val, &)
5353

54-
#define irqsafe_cpu_or_1(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, |)
55-
#define irqsafe_cpu_or_2(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, |)
56-
#define irqsafe_cpu_or_4(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, |)
57-
#define irqsafe_cpu_or_8(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, |)
54+
#define this_cpu_or_1(pcp, val) arch_this_cpu_to_op(pcp, val, |)
55+
#define this_cpu_or_2(pcp, val) arch_this_cpu_to_op(pcp, val, |)
56+
#define this_cpu_or_4(pcp, val) arch_this_cpu_to_op(pcp, val, |)
57+
#define this_cpu_or_8(pcp, val) arch_this_cpu_to_op(pcp, val, |)
5858

59-
#define irqsafe_cpu_xor_1(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, ^)
60-
#define irqsafe_cpu_xor_2(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, ^)
61-
#define irqsafe_cpu_xor_4(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, ^)
62-
#define irqsafe_cpu_xor_8(pcp, val) arch_irqsafe_cpu_to_op(pcp, val, ^)
59+
#define this_cpu_xor_1(pcp, val) arch_this_cpu_to_op(pcp, val, ^)
60+
#define this_cpu_xor_2(pcp, val) arch_this_cpu_to_op(pcp, val, ^)
61+
#define this_cpu_xor_4(pcp, val) arch_this_cpu_to_op(pcp, val, ^)
62+
#define this_cpu_xor_8(pcp, val) arch_this_cpu_to_op(pcp, val, ^)
6363

64-
#define arch_irqsafe_cpu_cmpxchg(pcp, oval, nval) \
64+
#define arch_this_cpu_cmpxchg(pcp, oval, nval) \
6565
({ \
6666
typedef typeof(pcp) pcp_op_T__; \
6767
pcp_op_T__ ret__; \
@@ -79,10 +79,10 @@ do { \
7979
ret__; \
8080
})
8181

82-
#define irqsafe_cpu_cmpxchg_1(pcp, oval, nval) arch_irqsafe_cpu_cmpxchg(pcp, oval, nval)
83-
#define irqsafe_cpu_cmpxchg_2(pcp, oval, nval) arch_irqsafe_cpu_cmpxchg(pcp, oval, nval)
84-
#define irqsafe_cpu_cmpxchg_4(pcp, oval, nval) arch_irqsafe_cpu_cmpxchg(pcp, oval, nval)
85-
#define irqsafe_cpu_cmpxchg_8(pcp, oval, nval) arch_irqsafe_cpu_cmpxchg(pcp, oval, nval)
82+
#define this_cpu_cmpxchg_1(pcp, oval, nval) arch_this_cpu_cmpxchg(pcp, oval, nval)
83+
#define this_cpu_cmpxchg_2(pcp, oval, nval) arch_this_cpu_cmpxchg(pcp, oval, nval)
84+
#define this_cpu_cmpxchg_4(pcp, oval, nval) arch_this_cpu_cmpxchg(pcp, oval, nval)
85+
#define this_cpu_cmpxchg_8(pcp, oval, nval) arch_this_cpu_cmpxchg(pcp, oval, nval)
8686

8787
#include <asm-generic/percpu.h>
8888

‎arch/x86/include/asm/percpu.h‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -414,22 +414,6 @@ do { \
414414
#define this_cpu_xchg_2(pcp, nval) percpu_xchg_op(pcp, nval)
415415
#define this_cpu_xchg_4(pcp, nval) percpu_xchg_op(pcp, nval)
416416

417-
#define irqsafe_cpu_add_1(pcp, val) percpu_add_op((pcp), val)
418-
#define irqsafe_cpu_add_2(pcp, val) percpu_add_op((pcp), val)
419-
#define irqsafe_cpu_add_4(pcp, val) percpu_add_op((pcp), val)
420-
#define irqsafe_cpu_and_1(pcp, val) percpu_to_op("and", (pcp), val)
421-
#define irqsafe_cpu_and_2(pcp, val) percpu_to_op("and", (pcp), val)
422-
#define irqsafe_cpu_and_4(pcp, val) percpu_to_op("and", (pcp), val)
423-
#define irqsafe_cpu_or_1(pcp, val) percpu_to_op("or", (pcp), val)
424-
#define irqsafe_cpu_or_2(pcp, val) percpu_to_op("or", (pcp), val)
425-
#define irqsafe_cpu_or_4(pcp, val) percpu_to_op("or", (pcp), val)
426-
#define irqsafe_cpu_xor_1(pcp, val) percpu_to_op("xor", (pcp), val)
427-
#define irqsafe_cpu_xor_2(pcp, val) percpu_to_op("xor", (pcp), val)
428-
#define irqsafe_cpu_xor_4(pcp, val) percpu_to_op("xor", (pcp), val)
429-
#define irqsafe_cpu_xchg_1(pcp, nval) percpu_xchg_op(pcp, nval)
430-
#define irqsafe_cpu_xchg_2(pcp, nval) percpu_xchg_op(pcp, nval)
431-
#define irqsafe_cpu_xchg_4(pcp, nval) percpu_xchg_op(pcp, nval)
432-
433417
#ifndef CONFIG_M386
434418
#define __this_cpu_add_return_1(pcp, val) percpu_add_return_op(pcp, val)
435419
#define __this_cpu_add_return_2(pcp, val) percpu_add_return_op(pcp, val)
@@ -445,9 +429,6 @@ do { \
445429
#define this_cpu_cmpxchg_2(pcp, oval, nval) percpu_cmpxchg_op(pcp, oval, nval)
446430
#define this_cpu_cmpxchg_4(pcp, oval, nval) percpu_cmpxchg_op(pcp, oval, nval)
447431

448-
#define irqsafe_cpu_cmpxchg_1(pcp, oval, nval) percpu_cmpxchg_op(pcp, oval, nval)
449-
#define irqsafe_cpu_cmpxchg_2(pcp, oval, nval) percpu_cmpxchg_op(pcp, oval, nval)
450-
#define irqsafe_cpu_cmpxchg_4(pcp, oval, nval) percpu_cmpxchg_op(pcp, oval, nval)
451432
#endif /* !CONFIG_M386 */
452433

453434
#ifdef CONFIG_X86_CMPXCHG64
@@ -467,7 +448,6 @@ do { \
467448

468449
#define __this_cpu_cmpxchg_double_4(pcp1, pcp2, o1, o2, n1, n2) percpu_cmpxchg8b_double(pcp1, o1, o2, n1, n2)
469450
#define this_cpu_cmpxchg_double_4(pcp1, pcp2, o1, o2, n1, n2) percpu_cmpxchg8b_double(pcp1, o1, o2, n1, n2)
470-
#define irqsafe_cpu_cmpxchg_double_4(pcp1, pcp2, o1, o2, n1, n2) percpu_cmpxchg8b_double(pcp1, o1, o2, n1, n2)
471451
#endif /* CONFIG_X86_CMPXCHG64 */
472452

473453
/*
@@ -495,13 +475,6 @@ do { \
495475
#define this_cpu_xchg_8(pcp, nval) percpu_xchg_op(pcp, nval)
496476
#define this_cpu_cmpxchg_8(pcp, oval, nval) percpu_cmpxchg_op(pcp, oval, nval)
497477

498-
#define irqsafe_cpu_add_8(pcp, val) percpu_add_op((pcp), val)
499-
#define irqsafe_cpu_and_8(pcp, val) percpu_to_op("and", (pcp), val)
500-
#define irqsafe_cpu_or_8(pcp, val) percpu_to_op("or", (pcp), val)
501-
#define irqsafe_cpu_xor_8(pcp, val) percpu_to_op("xor", (pcp), val)
502-
#define irqsafe_cpu_xchg_8(pcp, nval) percpu_xchg_op(pcp, nval)
503-
#define irqsafe_cpu_cmpxchg_8(pcp, oval, nval) percpu_cmpxchg_op(pcp, oval, nval)
504-
505478
/*
506479
* Pretty complex macro to generate cmpxchg16 instruction. The instruction
507480
* is not supported on early AMD64 processors so we must be able to emulate
@@ -532,7 +505,6 @@ do { \
532505

533506
#define __this_cpu_cmpxchg_double_8(pcp1, pcp2, o1, o2, n1, n2) percpu_cmpxchg16b_double(pcp1, o1, o2, n1, n2)
534507
#define this_cpu_cmpxchg_double_8(pcp1, pcp2, o1, o2, n1, n2) percpu_cmpxchg16b_double(pcp1, o1, o2, n1, n2)
535-
#define irqsafe_cpu_cmpxchg_double_8(pcp1, pcp2, o1, o2, n1, n2) percpu_cmpxchg16b_double(pcp1, o1, o2, n1, n2)
536508

537509
#endif
538510

‎include/linux/netdevice.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,7 +2115,7 @@ extern void netdev_run_todo(void);
21152115
*/
21162116
static inline void dev_put(struct net_device *dev)
21172117
{
2118-
irqsafe_cpu_dec(*dev->pcpu_refcnt);
2118+
this_cpu_dec(*dev->pcpu_refcnt);
21192119
}
21202120

21212121
/**
@@ -2126,7 +2126,7 @@ static inline void dev_put(struct net_device *dev)
21262126
*/
21272127
static inline void dev_hold(struct net_device *dev)
21282128
{
2129-
irqsafe_cpu_inc(*dev->pcpu_refcnt);
2129+
this_cpu_inc(*dev->pcpu_refcnt);
21302130
}
21312131

21322132
/* Carrier loss detection, dial on demand. The functions netif_carrier_on

‎include/linux/netfilter/x_tables.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ DECLARE_PER_CPU(seqcount_t, xt_recseq);
471471
*
472472
* Begin packet processing : all readers must wait the end
473473
* 1) Must be called with preemption disabled
474-
* 2) softirqs must be disabled too (or we should use irqsafe_cpu_add())
474+
* 2) softirqs must be disabled too (or we should use this_cpu_add())
475475
* Returns :
476476
* 1 if no recursion on this cpu
477477
* 0 if recursion detected
@@ -503,7 +503,7 @@ static inline unsigned int xt_write_recseq_begin(void)
503503
*
504504
* End packet processing : all readers can proceed
505505
* 1) Must be called with preemption disabled
506-
* 2) softirqs must be disabled too (or we should use irqsafe_cpu_add())
506+
* 2) softirqs must be disabled too (or we should use this_cpu_add())
507507
*/
508508
static inline void xt_write_recseq_end(unsigned int addend)
509509
{

0 commit comments

Comments
 (0)