mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-12 12:46:43 +07:00
5c7fc2d27d
BPF C program attaches to blk_mq_start_request()/blk_update_request() kprobe events to calculate IO latency. For every completed block IO event it computes the time delta in nsec and records in a histogram map: map[log10(delta)*10]++ User space reads this histogram map every 2 seconds and prints it as a 'heatmap' using gray shades of text terminal. Black spaces have many events and white spaces have very few events. Left most space is the smallest latency, right most space is the largest latency in the range. Usage: $ sudo ./tracex3 and do 'sudo dd if=/dev/sda of=/dev/null' in other terminal. Observe IO latencies and how different activity (like 'make kernel') affects it. Similar experiments can be done for network transmit latencies, syscalls, etc. '-t' flag prints the heatmap using normal ascii characters: $ sudo ./tracex3 -t heatmap of IO latency # - many events with this latency - few events |1us |10us |100us |1ms |10ms |100ms |1s |10s *ooo. *O.#. # 221 . *# . # 125 .. .o#*.. # 55 . . . . .#O # 37 .# # 175 .#*. # 37 # # 199 . . *#*. # 55 *#..* # 42 # # 266 ...***Oo#*OO**o#* . # 629 # # 271 . .#o* o.*o* # 221 . . o* *#O.. # 50 Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Cc: Arnaldo Carvalho de Melo <acme@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: David S. Miller <davem@davemloft.net> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Link: http://lkml.kernel.org/r/1427312966-8434-9-git-send-email-ast@plumgrid.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
46 lines
1.4 KiB
Makefile
46 lines
1.4 KiB
Makefile
# kbuild trick to avoid linker error. Can be omitted if a module is built.
|
|
obj- := dummy.o
|
|
|
|
# List of programs to build
|
|
hostprogs-y := test_verifier test_maps
|
|
hostprogs-y += sock_example
|
|
hostprogs-y += sockex1
|
|
hostprogs-y += sockex2
|
|
hostprogs-y += tracex1
|
|
hostprogs-y += tracex2
|
|
hostprogs-y += tracex3
|
|
|
|
test_verifier-objs := test_verifier.o libbpf.o
|
|
test_maps-objs := test_maps.o libbpf.o
|
|
sock_example-objs := sock_example.o libbpf.o
|
|
sockex1-objs := bpf_load.o libbpf.o sockex1_user.o
|
|
sockex2-objs := bpf_load.o libbpf.o sockex2_user.o
|
|
tracex1-objs := bpf_load.o libbpf.o tracex1_user.o
|
|
tracex2-objs := bpf_load.o libbpf.o tracex2_user.o
|
|
tracex3-objs := bpf_load.o libbpf.o tracex3_user.o
|
|
|
|
# Tell kbuild to always build the programs
|
|
always := $(hostprogs-y)
|
|
always += sockex1_kern.o
|
|
always += sockex2_kern.o
|
|
always += tracex1_kern.o
|
|
always += tracex2_kern.o
|
|
always += tracex3_kern.o
|
|
|
|
HOSTCFLAGS += -I$(objtree)/usr/include
|
|
|
|
HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
|
|
HOSTLOADLIBES_sockex1 += -lelf
|
|
HOSTLOADLIBES_sockex2 += -lelf
|
|
HOSTLOADLIBES_tracex1 += -lelf
|
|
HOSTLOADLIBES_tracex2 += -lelf
|
|
HOSTLOADLIBES_tracex3 += -lelf
|
|
|
|
# point this to your LLVM backend with bpf support
|
|
LLC=$(srctree)/tools/bpf/llvm/bld/Debug+Asserts/bin/llc
|
|
|
|
%.o: %.c
|
|
clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
|
|
-D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \
|
|
-O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
|