Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uprobe-stress: add uprobe stress-testing tool #279

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/c/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
/lsm
/cmake-build-debug/
/cmake-build-release/
/uprobe-stress
.gdb_history

3 changes: 2 additions & 1 deletion examples/c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ INCLUDES := -I$(OUTPUT) -I../../libbpf/include/uapi -I$(dir $(VMLINUX)) -I$(LIBB
CFLAGS := -g -Wall
ALL_LDFLAGS := $(LDFLAGS) $(EXTRA_LDFLAGS)

APPS = minimal minimal_legacy bootstrap uprobe kprobe fentry usdt sockfilter tc ksyscall task_iter lsm
APPS = minimal minimal_legacy bootstrap uprobe kprobe fentry usdt sockfilter tc ksyscall task_iter lsm \
uprobe-stress

CARGO ?= $(shell which cargo)
ifeq ($(strip $(CARGO)),)
Expand Down
30 changes: 30 additions & 0 deletions examples/c/uprobe-stress.bpf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include "uprobe-stress.h"

char LICENSE[] SEC("license") = "Dual BSD/GPL";

struct counter enter_hits[MAX_CPUS];
struct counter exit_hits[MAX_CPUS];

SEC("uprobe.multi")
int uprobe(struct pt_regs *ctx)
{
int cpu = bpf_get_smp_processor_id();

__sync_add_and_fetch(&enter_hits[cpu & CPU_MASK].value, 1);

return 0;
}

SEC("uretprobe.multi")
int uretprobe(struct pt_regs *ctx)
{
int cpu = bpf_get_smp_processor_id();

__sync_add_and_fetch(&exit_hits[cpu & CPU_MASK].value, 1);

return 0;
}
Loading