mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-10 15:54:39 +08:00
b061017f8b
Add a bunch of loop tests. Most of them are created by replacing '#pragma unroll' with '#pragma clang loop unroll(disable)' Several tests are artificially large: /* partial unroll. llvm will unroll loop ~150 times. * C loop count -> 600. * Asm loop count -> 4. * 16k insns in loop body. * Total of 5 such loops. Total program size ~82k insns. */ "./pyperf600.o", /* no unroll at all. * C loop count -> 600. * ASM loop count -> 600. * ~110 insns in loop body. * Total of 5 such loops. Total program size ~1500 insns. */ "./pyperf600_nounroll.o", /* partial unroll. 19k insn in a loop. * Total program size 20.8k insn. * ~350k processed_insns */ "./strobemeta.o", Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
29 lines
517 B
C
29 lines
517 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
// Copyright (c) 2019 Facebook
|
|
#include <linux/sched.h>
|
|
#include <linux/ptrace.h>
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <stdbool.h>
|
|
#include <linux/bpf.h>
|
|
#include "bpf_helpers.h"
|
|
|
|
char _license[] SEC("license") = "GPL";
|
|
|
|
SEC("raw_tracepoint/kfree_skb")
|
|
int nested_loops(volatile struct pt_regs* ctx)
|
|
{
|
|
int i, j, sum = 0, m;
|
|
|
|
for (j = 0; j < 300; j++)
|
|
for (i = 0; i < j; i++) {
|
|
if (j & 1)
|
|
m = ctx->rax;
|
|
else
|
|
m = j;
|
|
sum += i * m;
|
|
}
|
|
|
|
return sum;
|
|
}
|