Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
379d19e
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
accounting
arch
bootconfig
bpf
build
cgroup
counter
debugging
edid
firewire
firmware
gpio
hv
iio
include
io_uring
kvm/kvm_stat
laptop
leds
lib
memory-model
objtool
pci
pcmcia
perf
power
rcu
scripts
spi
testing
cxl
fault-injection
ktest
kunit
nvdimm
radix-tree
scatterlist
selftests
alsa
arm64
bpf
benchs
bpf_testmod
gnu
map_tests
prog_tests
.gitignore
align.c
atomic_bounds.c
atomics.c
attach_probe.c
autoload.c
bind_perm.c
bloom_filter_map.c
bpf_cookie.c
bpf_iter.c
bpf_iter_setsockopt.c
bpf_iter_setsockopt_unix.c
bpf_loop.c
bpf_mod_race.c
bpf_nf.c
bpf_obj_id.c
bpf_tcp_ca.c
bpf_verif_scale.c
btf.c
btf_dedup_split.c
btf_dump.c
btf_endian.c
btf_map_in_map.c
btf_module.c
btf_skc_cls_ingress.c
btf_split.c
btf_tag.c
btf_write.c
cg_storage_multi.c
cgroup_attach_autodetach.c
cgroup_attach_multi.c
cgroup_attach_override.c
cgroup_getset_retval.c
cgroup_link.c
cgroup_skb_sk_lookup.c
cgroup_v1v2.c
check_mtu.c
cls_redirect.c
connect_force_port.c
core_autosize.c
core_extern.c
core_kern.c
core_read_macros.c
core_reloc.c
core_retro.c
cpu_mask.c
d_path.c
dummy_st_ops.c
enable_stats.c
endian.c
exhandler.c
fentry_fexit.c
fentry_test.c
fexit_bpf2bpf.c
fexit_sleep.c
fexit_stress.c
fexit_test.c
find_vma.c
flow_dissector.c
flow_dissector_load_bytes.c
flow_dissector_reattach.c
for_each.c
get_branch_snapshot.c
get_func_args_test.c
get_func_ip_test.c
get_stack_raw_tp.c
get_stackid_cannot_attach.c
global_data.c
global_data_init.c
global_func_args.c
hash_large_key.c
hashmap.c
helper_restricted.c
kfree_skb.c
kfunc_call.c
ksyms.c
ksyms_btf.c
ksyms_module.c
l4lb_all.c
legacy_printk.c
libbpf_probes.c
link_pinning.c
linked_funcs.c
linked_maps.c
linked_vars.c
load_bytes_relative.c
log_buf.c
lookup_and_delete.c
map_init.c
map_lock.c
map_ptr.c
metadata.c
migrate_reuseport.c
mmap.c
modify_return.c
module_attach.c
netcnt.c
netns_cookie.c
ns_current_pid_tgid.c
obj_name.c
pe_preserve_elems.c
perf_branches.c
perf_buffer.c
perf_event_stackmap.c
perf_link.c
pinning.c
pkt_access.c
pkt_md_access.c
probe_read_user_str.c
probe_user.c
prog_array_init.c
prog_run_xattr.c
queue_stack_map.c
raw_tp_test_run.c
raw_tp_writable_reject_nbd_invalid.c
raw_tp_writable_test_run.c
rdonly_maps.c
recursion.c
reference_tracking.c
resolve_btfids.c
ringbuf.c
ringbuf_multi.c
section_names.c
select_reuseport.c
send_signal.c
send_signal_sched_switch.c
signal_pending.c
sk_assign.c
sk_lookup.c
sk_storage_tracing.c
skb_ctx.c
skb_helpers.c
skc_to_unix_sock.c
skeleton.c
snprintf.c
snprintf_btf.c
sock_fields.c
socket_cookie.c
sockmap_basic.c
sockmap_ktls.c
sockmap_listen.c
sockopt.c
sockopt_inherit.c
sockopt_multi.c
sockopt_qos_to_cc.c
sockopt_sk.c
spinlock.c
stack_var_off.c
stacktrace_build_id.c
stacktrace_build_id_nmi.c
stacktrace_map.c
stacktrace_map_raw_tp.c
static_linked.c
subprogs.c
syscall.c
tailcalls.c
task_fd_query_rawtp.c
task_fd_query_tp.c
task_local_storage.c
task_pt_regs.c
tc_bpf.c
tc_redirect.c
tcp_estats.c
tcp_hdr_options.c
tcp_rtt.c
tcpbpf_user.c
test_bpf_syscall_macro.c
test_bpffs.c
test_bprm_opts.c
test_global_funcs.c
test_ima.c
test_local_storage.c
test_lsm.c
test_overhead.c
test_profiler.c
test_skb_pkt_end.c
test_strncmp.c
timer.c
timer_mim.c
tp_attach_query.c
trace_ext.c
trace_printk.c
trace_vprintk.c
trampoline_count.c
udp_limit.c
varlen.c
verif_stats.c
vmlinux.c
xdp.c
xdp_adjust_frags.c
xdp_adjust_tail.c
xdp_attach.c
xdp_bonding.c
xdp_bpf2bpf.c
xdp_context_test_run.c
xdp_cpumap_attach.c
xdp_devmap_attach.c
xdp_info.c
xdp_link.c
xdp_noinline.c
xdp_perf.c
xdpwall.c
progs
verifier
.gitignore
Makefile
Makefile.docs
README.rst
bench.c
bench.h
bpf_legacy.h
bpf_rand.h
bpf_rlimit.h
bpf_sockopt_helpers.h
bpf_tcp_helpers.h
bpf_util.h
btf_helpers.c
btf_helpers.h
cgroup_helpers.c
cgroup_helpers.h
config
flow_dissector_load.c
flow_dissector_load.h
get_cgroup_id_user.c
ima_setup.sh
netcnt_common.h
network_helpers.c
network_helpers.h
settings
test_bpftool.py
test_bpftool.sh
test_bpftool_build.sh
test_bpftool_metadata.sh
test_bpftool_synctypes.py
test_btf.h
test_cgroup_storage.c
test_cpp.cpp
test_dev_cgroup.c
test_doc_build.sh
test_flow_dissector.c
test_flow_dissector.sh
test_ftrace.sh
test_iptunnel_common.h
test_kmod.sh
test_lirc_mode2.sh
test_lirc_mode2_user.c
test_lpm_map.c
test_lru_map.c
test_lwt_ip_encap.sh
test_lwt_seg6local.sh
test_maps.c
test_maps.h
test_offload.py
test_progs.c
test_progs.h
test_select_reuseport_common.h
test_skb_cgroup_id.sh
test_skb_cgroup_id_user.c
test_sock.c
test_sock_addr.c
test_sock_addr.sh
test_sockmap.c
test_sysctl.c
test_tag.c
test_tc_edt.sh
test_tc_tunnel.sh
test_tcp_check_syncookie.sh
test_tcp_check_syncookie_user.c
test_tcp_hdr_options.h
test_tcpbpf.h
test_tcpnotify.h
test_tcpnotify_user.c
test_tunnel.sh
test_verifier.c
test_verifier_log.c
test_xdp_meta.sh
test_xdp_redirect.sh
test_xdp_redirect_multi.sh
test_xdp_veth.sh
test_xdp_vlan.sh
test_xdp_vlan_mode_generic.sh
test_xdp_vlan_mode_native.sh
test_xdping.sh
test_xsk.sh
testing_helpers.c
testing_helpers.h
trace_helpers.c
trace_helpers.h
urandom_read.c
vmtest.sh
with_addr.sh
with_tunnels.sh
xdp_redirect_multi.c
xdping.c
xdping.h
xdpxceiver.c
xdpxceiver.h
xsk_prereqs.sh
breakpoints
capabilities
cgroup
clone3
core
cpu-hotplug
cpufreq
damon
dma
dmabuf-heaps
drivers
efivarfs
exec
filesystems
firmware
fpu
ftrace
futex
gpio
ia64
intel_pstate
ipc
ir
kcmp
kexec
kmod
kselftest
kvm
landlock
lib
livepatch
lkdtm
locking
media_tests
membarrier
memfd
memory-hotplug
mincore
mount
mount_setattr
move_mount_set_group
mqueue
nci
net
netfilter
nsfs
ntb
openat2
perf_events
pid_namespace
pidfd
powerpc
prctl
proc
pstore
ptp
ptrace
rcutorture
resctrl
rlimits
rseq
rtc
safesetid
sched
seccomp
sgx
sigaltstack
size
sparc64
splice
static_keys
sync
syscall_user_dispatch
sysctl
tc-testing
timens
timers
tmpfs
tpm2
uevent
user
vDSO
vm
watchdog
wireguard
x86
zram
.gitignore
Makefile
gen_kselftest_tar.sh
kselftest.h
kselftest_deps.sh
kselftest_harness.h
kselftest_install.sh
kselftest_module.h
lib.mk
run_kselftest.sh
vsock
thermal/tmon
time
tracing
usb
virtio
vm
wmi
Makefile
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
bpf
/
prog_tests
/
get_stackid_cannot_attach.c
Blame
Blame
Latest commit
History
History
88 lines (73 loc) · 2.61 KB
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
bpf
/
prog_tests
/
get_stackid_cannot_attach.c
Top
File metadata and controls
Code
Blame
88 lines (73 loc) · 2.61 KB
Raw
// SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2020 Facebook #include <test_progs.h> #include "test_stacktrace_build_id.skel.h" void test_get_stackid_cannot_attach(void) { struct perf_event_attr attr = { /* .type = PERF_TYPE_SOFTWARE, */ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CPU_CYCLES, .precise_ip = 1, .sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_BRANCH_STACK, .branch_sample_type = PERF_SAMPLE_BRANCH_USER | PERF_SAMPLE_BRANCH_NO_FLAGS | PERF_SAMPLE_BRANCH_NO_CYCLES | PERF_SAMPLE_BRANCH_CALL_STACK, .sample_period = 5000, .size = sizeof(struct perf_event_attr), }; struct test_stacktrace_build_id *skel; __u32 duration = 0; int pmu_fd, err; skel = test_stacktrace_build_id__open(); if (CHECK(!skel, "skel_open", "skeleton open failed\n")) return; /* override program type */ bpf_program__set_type(skel->progs.oncpu, BPF_PROG_TYPE_PERF_EVENT); err = test_stacktrace_build_id__load(skel); if (CHECK(err, "skel_load", "skeleton load failed: %d\n", err)) goto cleanup; pmu_fd = syscall(__NR_perf_event_open, &attr, -1 /* pid */, 0 /* cpu 0 */, -1 /* group id */, 0 /* flags */); if (pmu_fd < 0 && (errno == ENOENT || errno == EOPNOTSUPP)) { printf("%s:SKIP:cannot open PERF_COUNT_HW_CPU_CYCLES with precise_ip > 0\n", __func__); test__skip(); goto cleanup; } if (CHECK(pmu_fd < 0, "perf_event_open", "err %d errno %d\n", pmu_fd, errno)) goto cleanup; skel->links.oncpu = bpf_program__attach_perf_event(skel->progs.oncpu, pmu_fd); ASSERT_ERR_PTR(skel->links.oncpu, "attach_perf_event_no_callchain"); close(pmu_fd); /* add PERF_SAMPLE_CALLCHAIN, attach should succeed */ attr.sample_type |= PERF_SAMPLE_CALLCHAIN; pmu_fd = syscall(__NR_perf_event_open, &attr, -1 /* pid */, 0 /* cpu 0 */, -1 /* group id */, 0 /* flags */); if (CHECK(pmu_fd < 0, "perf_event_open", "err %d errno %d\n", pmu_fd, errno)) goto cleanup; skel->links.oncpu = bpf_program__attach_perf_event(skel->progs.oncpu, pmu_fd); ASSERT_OK_PTR(skel->links.oncpu, "attach_perf_event_callchain"); close(pmu_fd); /* add exclude_callchain_kernel, attach should fail */ attr.exclude_callchain_kernel = 1; pmu_fd = syscall(__NR_perf_event_open, &attr, -1 /* pid */, 0 /* cpu 0 */, -1 /* group id */, 0 /* flags */); if (CHECK(pmu_fd < 0, "perf_event_open", "err %d errno %d\n", pmu_fd, errno)) goto cleanup; skel->links.oncpu = bpf_program__attach_perf_event(skel->progs.oncpu, pmu_fd); ASSERT_ERR_PTR(skel->links.oncpu, "attach_perf_event_exclude_callchain_kernel"); close(pmu_fd); cleanup: test_stacktrace_build_id__destroy(skel); }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
You can’t perform that action at this time.