11
11
#include <linux/kmemleak.h>
12
12
#include <uapi/linux/btf.h>
13
13
#include <linux/btf_ids.h>
14
+ #include <asm/rqspinlock.h>
14
15
15
16
#define RINGBUF_CREATE_FLAG_MASK (BPF_F_NUMA_NODE)
16
17
@@ -29,7 +30,7 @@ struct bpf_ringbuf {
29
30
u64 mask ;
30
31
struct page * * pages ;
31
32
int nr_pages ;
32
- raw_spinlock_t spinlock ____cacheline_aligned_in_smp ;
33
+ rqspinlock_t spinlock ____cacheline_aligned_in_smp ;
33
34
/* For user-space producer ring buffers, an atomic_t busy bit is used
34
35
* to synchronize access to the ring buffers in the kernel, rather than
35
36
* the spinlock that is used for kernel-producer ring buffers. This is
@@ -173,7 +174,7 @@ static struct bpf_ringbuf *bpf_ringbuf_alloc(size_t data_sz, int numa_node)
173
174
if (!rb )
174
175
return NULL ;
175
176
176
- raw_spin_lock_init (& rb -> spinlock );
177
+ raw_res_spin_lock_init (& rb -> spinlock );
177
178
atomic_set (& rb -> busy , 0 );
178
179
init_waitqueue_head (& rb -> waitq );
179
180
init_irq_work (& rb -> work , bpf_ringbuf_notify );
@@ -416,12 +417,8 @@ static void *__bpf_ringbuf_reserve(struct bpf_ringbuf *rb, u64 size)
416
417
417
418
cons_pos = smp_load_acquire (& rb -> consumer_pos );
418
419
419
- if (in_nmi ()) {
420
- if (!raw_spin_trylock_irqsave (& rb -> spinlock , flags ))
421
- return NULL ;
422
- } else {
423
- raw_spin_lock_irqsave (& rb -> spinlock , flags );
424
- }
420
+ if (raw_res_spin_lock_irqsave (& rb -> spinlock , flags ))
421
+ return NULL ;
425
422
426
423
pend_pos = rb -> pending_pos ;
427
424
prod_pos = rb -> producer_pos ;
@@ -446,7 +443,7 @@ static void *__bpf_ringbuf_reserve(struct bpf_ringbuf *rb, u64 size)
446
443
*/
447
444
if (new_prod_pos - cons_pos > rb -> mask ||
448
445
new_prod_pos - pend_pos > rb -> mask ) {
449
- raw_spin_unlock_irqrestore (& rb -> spinlock , flags );
446
+ raw_res_spin_unlock_irqrestore (& rb -> spinlock , flags );
450
447
return NULL ;
451
448
}
452
449
@@ -458,7 +455,7 @@ static void *__bpf_ringbuf_reserve(struct bpf_ringbuf *rb, u64 size)
458
455
/* pairs with consumer's smp_load_acquire() */
459
456
smp_store_release (& rb -> producer_pos , new_prod_pos );
460
457
461
- raw_spin_unlock_irqrestore (& rb -> spinlock , flags );
458
+ raw_res_spin_unlock_irqrestore (& rb -> spinlock , flags );
462
459
463
460
return (void * )hdr + BPF_RINGBUF_HDR_SZ ;
464
461
}
0 commit comments