From: Brendan Gregg Date: Wed, 24 Aug 2016 22:10:05 +0000 (-0700) Subject: fix biosnoop after kernel change X-Git-Tag: v0.2.0~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d4d0bff136387b73988f794a3558be34324aad3;p=platform%2Fupstream%2Fbcc.git fix biosnoop after kernel change --- diff --git a/tools/biosnoop.py b/tools/biosnoop.py index 4b8fa9f..bed6ded 100755 --- a/tools/biosnoop.py +++ b/tools/biosnoop.py @@ -98,11 +98,23 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req) req->rq_disk->disk_name); } - if (req->cmd_flags & REQ_WRITE) { +/* + * The following deals with a kernel version change (in mainline 4.7, although + * it may be backported to earlier kernels) with how block request write flags + * are tested. We handle both pre- and post-change versions here. Please avoid + * kernel version tests like this as much as possible: they inflate the code, + * test, and maintenance burden. + */ +#ifdef REQ_WRITE +if (req->cmd_flags & REQ_WRITE) { +#else +if ((req->cmd_flags >> REQ_OP_SHIFT) == REQ_OP_WRITE) { +#endif data.rwflag = 1; } else { data.rwflag = 0; } + events.perf_submit(ctx, &data, sizeof(data)); start.delete(&req); infobyreq.delete(&req);