aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-02-02 23:46:28 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-02-02 23:46:28 +0000
commita34e99603d5bee16790ce6ee20826de2166b78e1 (patch)
tree3235ba11c547e08e3dcf6d9d40df278c59e086a6
parent84ab342b4f76375a64b0ed824cb2f62846297164 (diff)
parent3f91c6568189b02ba03e5b9aa75d613be2dd2a5b (diff)
downloadbcc-simpleperf-release.tar.gz
Snap for 11400057 from 3f91c6568189b02ba03e5b9aa75d613be2dd2a5b to simpleperf-releasesimpleperf-release
Change-Id: I1701ad25d13298ad75a9d050400d1cb319e77461
-rw-r--r--libbpf-tools/Android.bp4
-rw-r--r--libbpf-tools/biolatency.bpf.c9
-rw-r--r--libbpf-tools/biostacks.bpf.c8
-rw-r--r--libbpf-tools/fsdist.bpf.c8
-rw-r--r--libbpf-tools/offcputime.bpf.c8
-rw-r--r--libbpf-tools/runqlat.bpf.c8
6 files changed, 29 insertions, 16 deletions
diff --git a/libbpf-tools/Android.bp b/libbpf-tools/Android.bp
index 8bf6064d..e24b2c0f 100644
--- a/libbpf-tools/Android.bp
+++ b/libbpf-tools/Android.bp
@@ -28,7 +28,6 @@ cc_defaults {
name: "bcc_bpf_defaults",
compile_multilib: "first",
cflags: [
- "--target=bpf",
"-fno-data-sections",
"-fno-function-sections",
"-fno-stack-protector",
@@ -37,6 +36,8 @@ cc_defaults {
"-Wno-pointer-arith",
"-Wno-unused-command-line-argument",
"-Wno-unused-parameter",
+ "-mllvm -bpf-stack-size=1024",
+ "-g",
],
header_libs: [
"bpf_prog_headers",
@@ -68,6 +69,7 @@ cc_defaults {
],
},
},
+ bpf_target: true,
visibility: ["//visibility:private"],
}
diff --git a/libbpf-tools/biolatency.bpf.c b/libbpf-tools/biolatency.bpf.c
index 429412db..d0409fd0 100644
--- a/libbpf-tools/biolatency.bpf.c
+++ b/libbpf-tools/biolatency.bpf.c
@@ -101,6 +101,7 @@ static int handle_block_rq_complete(struct request *rq, int error, unsigned int
struct hist_key hkey = {};
struct hist *histp;
s64 delta;
+ u64 udelta;
if (filter_cg && !bpf_current_task_under_cgroup(&cgroup_map, 0))
return 0;
@@ -113,6 +114,8 @@ static int handle_block_rq_complete(struct request *rq, int error, unsigned int
if (delta < 0)
goto cleanup;
+ udelta = (u64)delta;
+
if (targ_per_disk) {
struct gendisk *disk = get_disk(rq);
@@ -131,10 +134,10 @@ static int handle_block_rq_complete(struct request *rq, int error, unsigned int
}
if (targ_ms)
- delta /= 1000000U;
+ udelta /= 1000000U;
else
- delta /= 1000U;
- slot = log2l(delta);
+ udelta /= 1000U;
+ slot = log2l(udelta);
if (slot >= MAX_SLOTS)
slot = MAX_SLOTS - 1;
__sync_fetch_and_add(&histp->slots[slot], 1);
diff --git a/libbpf-tools/biostacks.bpf.c b/libbpf-tools/biostacks.bpf.c
index 0ca69880..c1dce671 100644
--- a/libbpf-tools/biostacks.bpf.c
+++ b/libbpf-tools/biostacks.bpf.c
@@ -74,6 +74,7 @@ int trace_done(void *ctx, struct request *rq)
struct internal_rqinfo *i_rqinfop;
struct hist *histp;
s64 delta;
+ u64 udelta;
i_rqinfop = bpf_map_lookup_elem(&rqinfos, &rq);
if (!i_rqinfop)
@@ -81,14 +82,15 @@ int trace_done(void *ctx, struct request *rq)
delta = (s64)(ts - i_rqinfop->start_ts);
if (delta < 0)
goto cleanup;
+ udelta = (u64)delta;
histp = bpf_map_lookup_or_try_init(&hists, &i_rqinfop->rqinfo, &zero);
if (!histp)
goto cleanup;
if (targ_ms)
- delta /= 1000000U;
+ udelta /= 1000000U;
else
- delta /= 1000U;
- slot = log2l(delta);
+ udelta /= 1000U;
+ slot = log2l(udelta);
if (slot >= MAX_SLOTS)
slot = MAX_SLOTS - 1;
__sync_fetch_and_add(&histp->slots[slot], 1);
diff --git a/libbpf-tools/fsdist.bpf.c b/libbpf-tools/fsdist.bpf.c
index 1bf98e91..19bc51a3 100644
--- a/libbpf-tools/fsdist.bpf.c
+++ b/libbpf-tools/fsdist.bpf.c
@@ -41,6 +41,7 @@ static int probe_return(enum fs_file_op op)
__u64 ts = bpf_ktime_get_ns();
__u64 *tsp, slot;
__s64 delta;
+ __u64 udelta;
tsp = bpf_map_lookup_elem(&starts, &tid);
if (!tsp)
@@ -53,12 +54,13 @@ static int probe_return(enum fs_file_op op)
if (delta < 0)
goto cleanup;
+ udelta = (__u64)delta;
if (in_ms)
- delta /= 1000000;
+ udelta /= 1000000;
else
- delta /= 1000;
+ udelta /= 1000;
- slot = log2l(delta);
+ slot = log2l(udelta);
if (slot >= MAX_SLOTS)
slot = MAX_SLOTS - 1;
__sync_fetch_and_add(&hists[op].slots[slot], 1);
diff --git a/libbpf-tools/offcputime.bpf.c b/libbpf-tools/offcputime.bpf.c
index cb20d501..3a36fa32 100644
--- a/libbpf-tools/offcputime.bpf.c
+++ b/libbpf-tools/offcputime.bpf.c
@@ -63,6 +63,7 @@ int BPF_PROG(sched_switch, bool preempt, struct task_struct *prev, struct task_s
struct internal_key *i_keyp, i_key;
struct val_t *valp, val;
s64 delta;
+ u64 udelta;
u32 pid;
if (allow_record(prev)) {
@@ -94,13 +95,14 @@ int BPF_PROG(sched_switch, bool preempt, struct task_struct *prev, struct task_s
delta = (s64)(bpf_ktime_get_ns() - i_keyp->start_ts);
if (delta < 0)
goto cleanup;
- delta /= 1000U;
- if (delta < min_block_ns || delta > max_block_ns)
+ udelta = (u64)delta;
+ udelta /= 1000U;
+ if (udelta < min_block_ns || udelta > max_block_ns)
goto cleanup;
valp = bpf_map_lookup_elem(&info, &i_keyp->key);
if (!valp)
goto cleanup;
- __sync_fetch_and_add(&valp->delta, delta);
+ __sync_fetch_and_add(&valp->delta, udelta);
cleanup:
bpf_map_delete_elem(&start, &pid);
diff --git a/libbpf-tools/runqlat.bpf.c b/libbpf-tools/runqlat.bpf.c
index 76e0553e..1ddf976e 100644
--- a/libbpf-tools/runqlat.bpf.c
+++ b/libbpf-tools/runqlat.bpf.c
@@ -80,6 +80,7 @@ static int handle_switch(bool preempt, struct task_struct *prev, struct task_str
u64 *tsp, slot;
u32 pid, hkey;
s64 delta;
+ u64 udelta;
if (filter_cg && !bpf_current_task_under_cgroup(&cgroup_map, 0))
return 0;
@@ -95,6 +96,7 @@ static int handle_switch(bool preempt, struct task_struct *prev, struct task_str
delta = bpf_ktime_get_ns() - *tsp;
if (delta < 0)
goto cleanup;
+ udelta = (u64)delta;
if (targ_per_process)
hkey = BPF_CORE_READ(next, tgid);
@@ -111,10 +113,10 @@ static int handle_switch(bool preempt, struct task_struct *prev, struct task_str
bpf_probe_read_kernel_str(&histp->comm, sizeof(histp->comm),
next->comm);
if (targ_ms)
- delta /= 1000000U;
+ udelta /= 1000000U;
else
- delta /= 1000U;
- slot = log2l(delta);
+ udelta /= 1000U;
+ slot = log2l(udelta);
if (slot >= MAX_SLOTS)
slot = MAX_SLOTS - 1;
__sync_fetch_and_add(&histp->slots[slot], 1);