File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed
tools/testing/selftests/bpf Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -397,6 +397,28 @@ l_true: \
397397 , [as]"i"((dst_as << 16) | src_as));
398398#endif
399399
400+ void bpf_preempt_disable (void ) __weak __ksym ;
401+ void bpf_preempt_enable (void ) __weak __ksym ;
402+
403+ typedef struct {
404+ } __bpf_preempt_t ;
405+
406+ static inline __bpf_preempt_t __bpf_preempt_constructor (void )
407+ {
408+ __bpf_preempt_t ret = {};
409+
410+ bpf_preempt_disable ();
411+ return ret ;
412+ }
413+ static inline void __bpf_preempt_destructor (__bpf_preempt_t * t )
414+ {
415+ bpf_preempt_enable ();
416+ }
417+ #define bpf_guard_preempt () \
418+ __bpf_preempt_t ___bpf_apply(preempt, __COUNTER__) \
419+ __attribute__((__unused__, __cleanup__(__bpf_preempt_destructor))) = \
420+ __bpf_preempt_constructor()
421+
400422/* Description
401423 * Assert that a conditional expression is true.
402424 * Returns
Original file line number Diff line number Diff line change 33#include <bpf/bpf_helpers.h>
44#include <bpf/bpf_tracing.h>
55#include "bpf_misc.h"
6-
7- void bpf_preempt_disable (void ) __ksym ;
8- void bpf_preempt_enable (void ) __ksym ;
6+ #include "bpf_experimental.h"
97
108SEC ("?tc" )
119__failure __msg ("1 bpf_preempt_enable is missing" )
@@ -92,8 +90,7 @@ static __noinline void preempt_balance_subprog(void)
9290SEC ("?tc" )
9391__success int preempt_balance (struct __sk_buff * ctx )
9492{
95- bpf_preempt_disable ();
96- bpf_preempt_enable ();
93+ bpf_guard_preempt ();
9794 return 0 ;
9895}
9996
You can’t perform that action at this time.
0 commit comments