1723977caSMing Lei/* 2723977caSMing Lei $1: dev_t 3723977caSMing Lei $2: RWBS 4723977caSMing Lei $3: strlen($2) 5723977caSMing Lei 6723977caSMing Lei Track request order between block_io_start and block_rq_complete. 7*1fd4b8d7SCaleb Sander Mateos Sequence starts at 1 so 0 means "never seen". On first valid 8723977caSMing Lei completion, sync complete_seq to handle probe attachment races. 9723977caSMing Lei block_rq_complete listed first to reduce missed completion window. 10723977caSMing Lei*/ 11723977caSMing Lei 12723977caSMing LeiBEGIN { 13723977caSMing Lei @start_seq = (uint64)1; 14723977caSMing Lei @complete_seq = (uint64)0; 15723977caSMing Lei @out_of_order = (uint64)0; 16723977caSMing Lei @start_order[0] = (uint64)0; 17723977caSMing Lei delete(@start_order[0]); 18723977caSMing Lei printf("BPFTRACE_READY\n"); 19723977caSMing Lei} 20723977caSMing Lei 21723977caSMing Leitracepoint:block:block_rq_complete 22723977caSMing Lei/(int64)args.dev == $1 && !strncmp(args.rwbs, str($2), $3)/ 23723977caSMing Lei{ 24723977caSMing Lei $expected = @start_order[args.sector]; 25 if ($expected > 0) { 26 if (@complete_seq == 0) { 27 @complete_seq = $expected; 28 } 29 if ($expected != @complete_seq) { 30 printf("out_of_order: sector %llu started at seq %llu but completed at seq %llu\n", 31 args.sector, $expected, @complete_seq); 32 @out_of_order = @out_of_order + 1; 33 } 34 delete(@start_order[args.sector]); 35 @complete_seq = @complete_seq + 1; 36 } 37} 38 39tracepoint:block:block_io_start 40/(int64)args.dev == $1 && !strncmp(args.rwbs, str($2), $3)/ 41{ 42 @start_order[args.sector] = @start_seq; 43 @start_seq = @start_seq + 1; 44} 45 46END { 47 printf("total_start: %llu total_complete: %llu out_of_order: %llu\n", 48 @start_seq - 1, @complete_seq, @out_of_order); 49 clear(@start_order); 50 clear(@start_seq); 51 clear(@complete_seq); 52 clear(@out_of_order); 53} 54