summaryrefslogtreecommitdiffstats
path: root/samples/bpf/map_perf_test_kern.c
diff options
context:
space:
mode:
authorTony Lindgren2017-03-06 17:37:53 +0100
committerTony Lindgren2017-03-06 17:37:53 +0100
commite24bce8fb4c26bd0d8eca74cbbee1ad049246be3 (patch)
treec219c2ec183633aa15841fca5b055a09d2d0b980 /samples/bpf/map_perf_test_kern.c
parentARM: OMAP2+: Release device node after it is no longer needed. (diff)
parentLinux 4.11-rc1 (diff)
downloadkernel-qcow2-linux-e24bce8fb4c26bd0d8eca74cbbee1ad049246be3.tar.gz
kernel-qcow2-linux-e24bce8fb4c26bd0d8eca74cbbee1ad049246be3.tar.xz
kernel-qcow2-linux-e24bce8fb4c26bd0d8eca74cbbee1ad049246be3.zip
Merge tag 'v4.11-rc1' into omap-for-v4.11/fixes
Linux 4.11-rc1
Diffstat (limited to 'samples/bpf/map_perf_test_kern.c')
-rw-r--r--samples/bpf/map_perf_test_kern.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/samples/bpf/map_perf_test_kern.c b/samples/bpf/map_perf_test_kern.c
index 7ee1574c8ccf..a91872a97742 100644
--- a/samples/bpf/map_perf_test_kern.c
+++ b/samples/bpf/map_perf_test_kern.c
@@ -57,6 +57,14 @@ struct bpf_map_def SEC("maps") percpu_hash_map_alloc = {
.map_flags = BPF_F_NO_PREALLOC,
};
+struct bpf_map_def SEC("maps") lpm_trie_map_alloc = {
+ .type = BPF_MAP_TYPE_LPM_TRIE,
+ .key_size = 8,
+ .value_size = sizeof(long),
+ .max_entries = 10000,
+ .map_flags = BPF_F_NO_PREALLOC,
+};
+
SEC("kprobe/sys_getuid")
int stress_hmap(struct pt_regs *ctx)
{
@@ -135,5 +143,27 @@ int stress_percpu_lru_hmap_alloc(struct pt_regs *ctx)
return 0;
}
+SEC("kprobe/sys_gettid")
+int stress_lpm_trie_map_alloc(struct pt_regs *ctx)
+{
+ union {
+ u32 b32[2];
+ u8 b8[8];
+ } key;
+ unsigned int i;
+
+ key.b32[0] = 32;
+ key.b8[4] = 192;
+ key.b8[5] = 168;
+ key.b8[6] = 0;
+ key.b8[7] = 1;
+
+#pragma clang loop unroll(full)
+ for (i = 0; i < 32; ++i)
+ bpf_map_lookup_elem(&lpm_trie_map_alloc, &key);
+
+ return 0;
+}
+
char _license[] SEC("license") = "GPL";
u32 _version SEC("version") = LINUX_VERSION_CODE;