Skip to content

Commit 6eac779

Browse files
davem330Alexei Starovoitov
authored andcommitted
bpf/tests: Use migrate disable instead of preempt disable
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. [ tglx: Switched it over to migrate disable ] 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.785306549@linutronix.de
1 parent 3d9f773 commit 6eac779

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/test_bpf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6660,14 +6660,14 @@ static int __run_one(const struct bpf_prog *fp, const void *data,
66606660
u64 start, finish;
66616661
int ret = 0, i;
66626662

6663-
preempt_disable();
6663+
migrate_disable();
66646664
start = ktime_get_ns();
66656665

66666666
for (i = 0; i < runs; i++)
66676667
ret = BPF_PROG_RUN(fp, data);
66686668

66696669
finish = ktime_get_ns();
6670-
preempt_enable();
6670+
migrate_enable();
66716671

66726672
*duration = finish - start;
66736673
do_div(*duration, runs);

net/bpf/test_run.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static int bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat,
3737
repeat = 1;
3838

3939
rcu_read_lock();
40-
preempt_disable();
40+
migrate_disable();
4141
time_start = ktime_get_ns();
4242
for (i = 0; i < repeat; i++) {
4343
bpf_cgroup_storage_set(storage);
@@ -54,18 +54,18 @@ static int bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat,
5454

5555
if (need_resched()) {
5656
time_spent += ktime_get_ns() - time_start;
57-
preempt_enable();
57+
migrate_enable();
5858
rcu_read_unlock();
5959

6060
cond_resched();
6161

6262
rcu_read_lock();
63-
preempt_disable();
63+
migrate_disable();
6464
time_start = ktime_get_ns();
6565
}
6666
}
6767
time_spent += ktime_get_ns() - time_start;
68-
preempt_enable();
68+
migrate_enable();
6969
rcu_read_unlock();
7070

7171
do_div(time_spent, repeat);

0 commit comments

Comments
 (0)