Skip to content

Commit

Permalink
tests: fix a few tests to use the right register on powerpc
Browse files Browse the repository at this point in the history
Signed-off-by: Naveen N. Rao <[email protected]>
  • Loading branch information
rnav committed May 2, 2016
1 parent 56f2f14 commit 0301dda
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/python/test_trace2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
BPF_TABLE("hash", struct Ptr, struct Counters, stats, 1024);
int count_sched(struct pt_regs *ctx) {
#if defined(__powerpc__)
struct Ptr key = {.ptr=ctx->gpr[3]};
#else
struct Ptr key = {.ptr=ctx->bx};
#endif
struct Counters zleaf = {0};
stats.lookup_or_init(&key, &zleaf)->stat1++;
return 0;
Expand Down
8 changes: 8 additions & 0 deletions tests/python/test_trace3.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@ static u32 log2l(u64 v) {
}

int probe_blk_start_request(struct pt_regs *ctx) {
#if defined(__powerpc__)
struct Request rq = {.rq = ctx->gpr[3]};
#else
struct Request rq = {.rq = ctx->di};
#endif
struct Time tm = {.start = bpf_ktime_get_ns()};
requests.update(&rq, &tm);
return 0;
}

int probe_blk_update_request(struct pt_regs *ctx) {
#if defined(__powerpc__)
struct Request rq = {.rq = ctx->gpr[3]};
#else
struct Request rq = {.rq = ctx->di};
#endif
struct Time *tm = requests.lookup(&rq);
if (!tm) return 0;
u64 delta = bpf_ktime_get_ns() - tm->start;
Expand Down

0 comments on commit 0301dda

Please sign in to comment.