.. | .. |
---|
40 | 40 | |
---|
41 | 41 | #include <linux/percpu.h> |
---|
42 | 42 | #include <linux/preempt.h> |
---|
| 43 | +#include <linux/locallock.h> |
---|
43 | 44 | |
---|
44 | 45 | DECLARE_PER_CPU(struct aa_buffers, aa_buffers); |
---|
| 46 | +DECLARE_LOCAL_IRQ_LOCK(aa_buffers_lock); |
---|
45 | 47 | |
---|
46 | 48 | #define ASSIGN(FN, A, X, N) ((X) = FN(A, N)) |
---|
47 | 49 | #define EVAL1(FN, A, X) ASSIGN(FN, A, X, 0) /*X = FN(0)*/ |
---|
.. | .. |
---|
51 | 53 | |
---|
52 | 54 | #define for_each_cpu_buffer(I) for ((I) = 0; (I) < MAX_PATH_BUFFERS; (I)++) |
---|
53 | 55 | |
---|
54 | | -#ifdef CONFIG_DEBUG_PREEMPT |
---|
| 56 | +#ifdef CONFIG_PREEMPT_RT_BASE |
---|
| 57 | +static inline void AA_BUG_PREEMPT_ENABLED(const char *s) |
---|
| 58 | +{ |
---|
| 59 | + struct local_irq_lock *lv; |
---|
| 60 | + |
---|
| 61 | + lv = this_cpu_ptr(&aa_buffers_lock); |
---|
| 62 | + WARN_ONCE(lv->owner != current, |
---|
| 63 | + "__get_buffer without aa_buffers_lock\n"); |
---|
| 64 | +} |
---|
| 65 | + |
---|
| 66 | +#elif defined(CONFIG_DEBUG_PREEMPT) |
---|
55 | 67 | #define AA_BUG_PREEMPT_ENABLED(X) AA_BUG(preempt_count() <= 0, X) |
---|
56 | 68 | #else |
---|
57 | 69 | #define AA_BUG_PREEMPT_ENABLED(X) /* nop */ |
---|
.. | .. |
---|
67 | 79 | |
---|
68 | 80 | #define get_buffers(X...) \ |
---|
69 | 81 | do { \ |
---|
70 | | - struct aa_buffers *__cpu_var = get_cpu_ptr(&aa_buffers); \ |
---|
| 82 | + struct aa_buffers *__cpu_var; \ |
---|
| 83 | + __cpu_var = get_locked_ptr(aa_buffers_lock, &aa_buffers); \ |
---|
71 | 84 | __get_buffers(__cpu_var, X); \ |
---|
72 | 85 | } while (0) |
---|
73 | 86 | |
---|
74 | 87 | #define put_buffers(X, Y...) \ |
---|
75 | 88 | do { \ |
---|
76 | 89 | __put_buffers(X, Y); \ |
---|
77 | | - put_cpu_ptr(&aa_buffers); \ |
---|
| 90 | + put_locked_ptr(aa_buffers_lock, &aa_buffers); \ |
---|
78 | 91 | } while (0) |
---|
79 | 92 | |
---|
80 | 93 | #endif /* __AA_PATH_H */ |
---|