.. | .. |
---|
3165 | 3165 | static __always_inline int |
---|
3166 | 3166 | trace_recursive_lock(struct ring_buffer_per_cpu *cpu_buffer) |
---|
3167 | 3167 | { |
---|
3168 | | - unsigned int val = cpu_buffer->current_context; |
---|
3169 | | - unsigned long pc = preempt_count(); |
---|
| 3168 | + unsigned int val; |
---|
| 3169 | + unsigned long pc = preempt_count(), flags; |
---|
3170 | 3170 | int bit; |
---|
3171 | 3171 | |
---|
3172 | 3172 | if (!(pc & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET))) |
---|
.. | .. |
---|
3175 | 3175 | bit = pc & NMI_MASK ? RB_CTX_NMI : |
---|
3176 | 3176 | pc & HARDIRQ_MASK ? RB_CTX_IRQ : RB_CTX_SOFTIRQ; |
---|
3177 | 3177 | |
---|
| 3178 | + flags = hard_cond_local_irq_save(); |
---|
| 3179 | + |
---|
| 3180 | + val = cpu_buffer->current_context; |
---|
| 3181 | + |
---|
3178 | 3182 | if (unlikely(val & (1 << (bit + cpu_buffer->nest)))) { |
---|
3179 | 3183 | /* |
---|
3180 | 3184 | * It is possible that this was called by transitioning |
---|
.. | .. |
---|
3182 | 3186 | * been updated yet. In this case, use the TRANSITION bit. |
---|
3183 | 3187 | */ |
---|
3184 | 3188 | bit = RB_CTX_TRANSITION; |
---|
3185 | | - if (val & (1 << (bit + cpu_buffer->nest))) |
---|
| 3189 | + if (val & (1 << (bit + cpu_buffer->nest))) { |
---|
| 3190 | + hard_cond_local_irq_restore(flags); |
---|
3186 | 3191 | return 1; |
---|
| 3192 | + } |
---|
3187 | 3193 | } |
---|
3188 | 3194 | |
---|
3189 | 3195 | val |= (1 << (bit + cpu_buffer->nest)); |
---|
3190 | 3196 | cpu_buffer->current_context = val; |
---|
| 3197 | + |
---|
| 3198 | + hard_cond_local_irq_restore(flags); |
---|
3191 | 3199 | |
---|
3192 | 3200 | return 0; |
---|
3193 | 3201 | } |
---|
.. | .. |
---|
3195 | 3203 | static __always_inline void |
---|
3196 | 3204 | trace_recursive_unlock(struct ring_buffer_per_cpu *cpu_buffer) |
---|
3197 | 3205 | { |
---|
| 3206 | + unsigned long flags; |
---|
| 3207 | + |
---|
| 3208 | + flags = hard_cond_local_irq_save(); |
---|
3198 | 3209 | cpu_buffer->current_context &= |
---|
3199 | 3210 | cpu_buffer->current_context - (1 << cpu_buffer->nest); |
---|
| 3211 | + hard_cond_local_irq_restore(flags); |
---|
3200 | 3212 | } |
---|
3201 | 3213 | |
---|
3202 | 3214 | /* The recursive locking above uses 5 bits */ |
---|