diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-09 16:08:28 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-09 16:08:28 -0500 |
| commit | 6b3da11b3c36fdafce3a72e0e90d6c4e99e9aad5 (patch) | |
| tree | 33e64fc453619978c3ecc86c7ec3649db3b4d8dc /include/linux | |
| parent | db0c2bf69aa095d4a6de7b1145f29fe9a7c0f6a3 (diff) | |
| parent | 933393f58fef9963eac61db8093689544e29a600 (diff) | |
Merge branch 'for-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu
* 'for-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu:
percpu: Remove irqsafe_cpu_xxx variants
Fix up conflict in arch/x86/include/asm/percpu.h due to clash with
cebef5beed3d ("x86: Fix and improve percpu_cmpxchg{8,16}b_double()")
which edited the (now removed) irqsafe_cpu_cmpxchg*_double code.
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/netdevice.h | 4 | ||||
| -rw-r--r-- | include/linux/netfilter/x_tables.h | 4 | ||||
| -rw-r--r-- | include/linux/percpu.h | 190 |
3 files changed, 26 insertions, 172 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a1d109590da4..4c06cc0f194b 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
| @@ -2155,7 +2155,7 @@ extern void netdev_run_todo(void); | |||
| 2155 | */ | 2155 | */ |
| 2156 | static inline void dev_put(struct net_device *dev) | 2156 | static inline void dev_put(struct net_device *dev) |
| 2157 | { | 2157 | { |
| 2158 | irqsafe_cpu_dec(*dev->pcpu_refcnt); | 2158 | this_cpu_dec(*dev->pcpu_refcnt); |
| 2159 | } | 2159 | } |
| 2160 | 2160 | ||
| 2161 | /** | 2161 | /** |
| @@ -2166,7 +2166,7 @@ static inline void dev_put(struct net_device *dev) | |||
| 2166 | */ | 2166 | */ |
| 2167 | static inline void dev_hold(struct net_device *dev) | 2167 | static inline void dev_hold(struct net_device *dev) |
| 2168 | { | 2168 | { |
| 2169 | irqsafe_cpu_inc(*dev->pcpu_refcnt); | 2169 | this_cpu_inc(*dev->pcpu_refcnt); |
| 2170 | } | 2170 | } |
| 2171 | 2171 | ||
| 2172 | /* Carrier loss detection, dial on demand. The functions netif_carrier_on | 2172 | /* Carrier loss detection, dial on demand. The functions netif_carrier_on |
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index 32cddf78b13e..8d674a786744 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h | |||
| @@ -471,7 +471,7 @@ DECLARE_PER_CPU(seqcount_t, xt_recseq); | |||
| 471 | * | 471 | * |
| 472 | * Begin packet processing : all readers must wait the end | 472 | * Begin packet processing : all readers must wait the end |
| 473 | * 1) Must be called with preemption disabled | 473 | * 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()) |
| 475 | * Returns : | 475 | * Returns : |
| 476 | * 1 if no recursion on this cpu | 476 | * 1 if no recursion on this cpu |
| 477 | * 0 if recursion detected | 477 | * 0 if recursion detected |
| @@ -503,7 +503,7 @@ static inline unsigned int xt_write_recseq_begin(void) | |||
| 503 | * | 503 | * |
| 504 | * End packet processing : all readers can proceed | 504 | * End packet processing : all readers can proceed |
| 505 | * 1) Must be called with preemption disabled | 505 | * 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()) |
| 507 | */ | 507 | */ |
| 508 | static inline void xt_write_recseq_end(unsigned int addend) | 508 | static inline void xt_write_recseq_end(unsigned int addend) |
| 509 | { | 509 | { |
diff --git a/include/linux/percpu.h b/include/linux/percpu.h index 9ca008f0c542..32cd1f67462e 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h | |||
| @@ -172,10 +172,10 @@ extern phys_addr_t per_cpu_ptr_to_phys(void *addr); | |||
| 172 | * equal char, int or long. percpu_read() evaluates to a lvalue and | 172 | * equal char, int or long. percpu_read() evaluates to a lvalue and |
| 173 | * all others to void. | 173 | * all others to void. |
| 174 | * | 174 | * |
| 175 | * These operations are guaranteed to be atomic w.r.t. preemption. | 175 | * These operations are guaranteed to be atomic. |
| 176 | * The generic versions use plain get/put_cpu_var(). Archs are | 176 | * The generic versions disable interrupts. Archs are |
| 177 | * encouraged to implement single-instruction alternatives which don't | 177 | * encouraged to implement single-instruction alternatives which don't |
| 178 | * require preemption protection. | 178 | * require protection. |
| 179 | */ | 179 | */ |
| 180 | #ifndef percpu_read | 180 | #ifndef percpu_read |
| 181 | # define percpu_read(var) \ | 181 | # define percpu_read(var) \ |
| @@ -347,9 +347,10 @@ do { \ | |||
| 347 | 347 | ||
| 348 | #define _this_cpu_generic_to_op(pcp, val, op) \ | 348 | #define _this_cpu_generic_to_op(pcp, val, op) \ |
| 349 | do { \ | 349 | do { \ |
| 350 | preempt_disable(); \ | 350 | unsigned long flags; \ |
| 351 | local_irq_save(flags); \ | ||
| 351 | *__this_cpu_ptr(&(pcp)) op val; \ | 352 | *__this_cpu_ptr(&(pcp)) op val; \ |
| 352 | preempt_enable(); \ | 353 | local_irq_restore(flags); \ |
| 353 | } while (0) | 354 | } while (0) |
| 354 | 355 | ||
| 355 | #ifndef this_cpu_write | 356 | #ifndef this_cpu_write |
| @@ -447,10 +448,11 @@ do { \ | |||
| 447 | #define _this_cpu_generic_add_return(pcp, val) \ | 448 | #define _this_cpu_generic_add_return(pcp, val) \ |
| 448 | ({ \ | 449 | ({ \ |
| 449 | typeof(pcp) ret__; \ | 450 | typeof(pcp) ret__; \ |
| 450 | preempt_disable(); \ | 451 | unsigned long flags; \ |
| 452 | local_irq_save(flags); \ | ||
| 451 | __this_cpu_add(pcp, val); \ | 453 | __this_cpu_add(pcp, val); \ |
| 452 | ret__ = __this_cpu_read(pcp); \ | 454 | ret__ = __this_cpu_read(pcp); \ |
| 453 | preempt_enable(); \ | 455 | local_irq_restore(flags); \ |
| 454 | ret__; \ | 456 | ret__; \ |
| 455 | }) | 457 | }) |
| 456 | 458 | ||
| @@ -476,10 +478,11 @@ do { \ | |||
| 476 | 478 | ||
| 477 | #define _this_cpu_generic_xchg(pcp, nval) \ | 479 | #define _this_cpu_generic_xchg(pcp, nval) \ |
| 478 | ({ typeof(pcp) ret__; \ | 480 | ({ typeof(pcp) ret__; \ |
| 479 | preempt_disable(); \ | 481 | unsigned long flags; \ |
| 482 | local_irq_save(flags); \ | ||
| 480 | ret__ = __this_cpu_read(pcp); \ | 483 | ret__ = __this_cpu_read(pcp); \ |
| 481 | __this_cpu_write(pcp, nval); \ | 484 | __this_cpu_write(pcp, nval); \ |
| 482 | preempt_enable(); \ | 485 | local_irq_restore(flags); \ |
| 483 | ret__; \ | 486 | ret__; \ |
| 484 | }) | 487 | }) |
| 485 | 488 | ||
| @@ -501,12 +504,14 @@ do { \ | |||
| 501 | #endif | 504 | #endif |
| 502 | 505 | ||
| 503 | #define _this_cpu_generic_cmpxchg(pcp, oval, nval) \ | 506 | #define _this_cpu_generic_cmpxchg(pcp, oval, nval) \ |
| 504 | ({ typeof(pcp) ret__; \ | 507 | ({ \ |
| 505 | preempt_disable(); \ | 508 | typeof(pcp) ret__; \ |
| 509 | unsigned long flags; \ | ||
| 510 | local_irq_save(flags); \ | ||
| 506 | ret__ = __this_cpu_read(pcp); \ | 511 | ret__ = __this_cpu_read(pcp); \ |
| 507 | if (ret__ == (oval)) \ | 512 | if (ret__ == (oval)) \ |
| 508 | __this_cpu_write(pcp, nval); \ | 513 | __this_cpu_write(pcp, nval); \ |
| 509 | preempt_enable(); \ | 514 | local_irq_restore(flags); \ |
| 510 | ret__; \ | 515 | ret__; \ |
| 511 | }) | 516 | }) |
| 512 | 517 | ||
| @@ -538,10 +543,11 @@ do { \ | |||
| 538 | #define _this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \ | 543 | #define _this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \ |
| 539 | ({ \ | 544 | ({ \ |
| 540 | int ret__; \ | 545 | int ret__; \ |
| 541 | preempt_disable(); \ | 546 | unsigned long flags; \ |
| 547 | local_irq_save(flags); \ | ||
| 542 | ret__ = __this_cpu_generic_cmpxchg_double(pcp1, pcp2, \ | 548 | ret__ = __this_cpu_generic_cmpxchg_double(pcp1, pcp2, \ |
| 543 | oval1, oval2, nval1, nval2); \ | 549 | oval1, oval2, nval1, nval2); \ |
| 544 | preempt_enable(); \ | 550 | local_irq_restore(flags); \ |
| 545 | ret__; \ | 551 | ret__; \ |
| 546 | }) | 552 | }) |
| 547 | 553 | ||
| @@ -567,9 +573,9 @@ do { \ | |||
| 567 | #endif | 573 | #endif |
| 568 | 574 | ||
| 569 | /* | 575 | /* |
| 570 | * Generic percpu operations that do not require preemption handling. | 576 | * Generic percpu operations for context that are safe from preemption/interrupts. |
| 571 | * Either we do not care about races or the caller has the | 577 | * Either we do not care about races or the caller has the |
| 572 | * responsibility of handling preemptions issues. Arch code can still | 578 | * responsibility of handling preemption/interrupt issues. Arch code can still |
| 573 | * override these instructions since the arch per cpu code may be more | 579 | * override these instructions since the arch per cpu code may be more |
| 574 | * efficient and may actually get race freeness for free (that is the | 580 | * efficient and may actually get race freeness for free (that is the |
| 575 | * case for x86 for example). | 581 | * case for x86 for example). |
| @@ -802,156 +808,4 @@ do { \ | |||
| 802 | __pcpu_double_call_return_bool(__this_cpu_cmpxchg_double_, (pcp1), (pcp2), (oval1), (oval2), (nval1), (nval2)) | 808 | __pcpu_double_call_return_bool(__this_cpu_cmpxchg_double_, (pcp1), (pcp2), (oval1), (oval2), (nval1), (nval2)) |
| 803 | #endif | 809 | #endif |
| 804 | 810 | ||
| 805 | /* | ||
| 806 | * IRQ safe versions of the per cpu RMW operations. Note that these operations | ||
| 807 | * are *not* safe against modification of the same variable from another | ||
| 808 | * processors (which one gets when using regular atomic operations) | ||
| 809 | * They are guaranteed to be atomic vs. local interrupts and | ||
| 810 | * preemption only. | ||
| 811 | */ | ||
| 812 | #define irqsafe_cpu_generic_to_op(pcp, val, op) \ | ||
| 813 | do { \ | ||
| 814 | unsigned long flags; \ | ||
| 815 | local_irq_save(flags); \ | ||
| 816 | *__this_cpu_ptr(&(pcp)) op val; \ | ||
| 817 | local_irq_restore(flags); \ | ||
| 818 | } while (0) | ||
