Skip to content

Commit 2a916f2

Browse files
davem330Alexei Starovoitov
authored andcommitted
bpf: Use migrate_disable/enable in array macros and cgroup/lirc code.
Replace the preemption disable/enable with migrate_disable/enable() to reflect the actual requirement and to allow PREEMPT_RT to substitute it with an actual migration disable mechanism which does not disable preemption. Including the code paths that go via __bpf_prog_run_save_cb(). Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20200224145643.998293311@linutronix.de
1 parent 02ad059 commit 2a916f2

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

include/linux/bpf.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ int bpf_prog_array_copy(struct bpf_prog_array *old_array,
885885
struct bpf_prog *_prog; \
886886
struct bpf_prog_array *_array; \
887887
u32 _ret = 1; \
888-
preempt_disable(); \
888+
migrate_disable(); \
889889
rcu_read_lock(); \
890890
_array = rcu_dereference(array); \
891891
if (unlikely(check_non_null && !_array))\
@@ -898,7 +898,7 @@ int bpf_prog_array_copy(struct bpf_prog_array *old_array,
898898
} \
899899
_out: \
900900
rcu_read_unlock(); \
901-
preempt_enable(); \
901+
migrate_enable(); \
902902
_ret; \
903903
})
904904

@@ -932,7 +932,7 @@ _out: \
932932
u32 ret; \
933933
u32 _ret = 1; \
934934
u32 _cn = 0; \
935-
preempt_disable(); \
935+
migrate_disable(); \
936936
rcu_read_lock(); \
937937
_array = rcu_dereference(array); \
938938
_item = &_array->items[0]; \
@@ -944,7 +944,7 @@ _out: \
944944
_item++; \
945945
} \
946946
rcu_read_unlock(); \
947-
preempt_enable(); \
947+
migrate_enable(); \
948948
if (_ret) \
949949
_ret = (_cn ? NET_XMIT_CN : NET_XMIT_SUCCESS); \
950950
else \

include/linux/filter.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ static inline u8 *bpf_skb_cb(struct sk_buff *skb)
677677
return qdisc_skb_cb(skb)->data;
678678
}
679679

680+
/* Must be invoked with migration disabled */
680681
static inline u32 __bpf_prog_run_save_cb(const struct bpf_prog *prog,
681682
struct sk_buff *skb)
682683
{
@@ -702,9 +703,9 @@ static inline u32 bpf_prog_run_save_cb(const struct bpf_prog *prog,
702703
{
703704
u32 res;
704705

705-
preempt_disable();
706+
migrate_disable();
706707
res = __bpf_prog_run_save_cb(prog, skb);
707-
preempt_enable();
708+
migrate_enable();
708709
return res;
709710
}
710711

0 commit comments

Comments
 (0)