xref: /aosp_15_r20/external/blktrace/btt/trace_plug.c (revision 1a3d31e37cc95e9919fd86900a2b6a555f55952c)
1*1a3d31e3SAndroid Build Coastguard Worker /*
2*1a3d31e3SAndroid Build Coastguard Worker  * blktrace output analysis: generate a timeline & gather statistics
3*1a3d31e3SAndroid Build Coastguard Worker  *
4*1a3d31e3SAndroid Build Coastguard Worker  * Copyright (C) 2007 Alan D. Brunelle <[email protected]>
5*1a3d31e3SAndroid Build Coastguard Worker  *
6*1a3d31e3SAndroid Build Coastguard Worker  *  This program is free software; you can redistribute it and/or modify
7*1a3d31e3SAndroid Build Coastguard Worker  *  it under the terms of the GNU General Public License as published by
8*1a3d31e3SAndroid Build Coastguard Worker  *  the Free Software Foundation; either version 2 of the License, or
9*1a3d31e3SAndroid Build Coastguard Worker  *  (at your option) any later version.
10*1a3d31e3SAndroid Build Coastguard Worker  *
11*1a3d31e3SAndroid Build Coastguard Worker  *  This program is distributed in the hope that it will be useful,
12*1a3d31e3SAndroid Build Coastguard Worker  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13*1a3d31e3SAndroid Build Coastguard Worker  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*1a3d31e3SAndroid Build Coastguard Worker  *  GNU General Public License for more details.
15*1a3d31e3SAndroid Build Coastguard Worker  *
16*1a3d31e3SAndroid Build Coastguard Worker  *  You should have received a copy of the GNU General Public License
17*1a3d31e3SAndroid Build Coastguard Worker  *  along with this program; if not, write to the Free Software
18*1a3d31e3SAndroid Build Coastguard Worker  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19*1a3d31e3SAndroid Build Coastguard Worker  *
20*1a3d31e3SAndroid Build Coastguard Worker  */
21*1a3d31e3SAndroid Build Coastguard Worker #include "globals.h"
22*1a3d31e3SAndroid Build Coastguard Worker 
get_nio_up(struct io * u_iop)23*1a3d31e3SAndroid Build Coastguard Worker static __u64 get_nio_up(struct io *u_iop)
24*1a3d31e3SAndroid Build Coastguard Worker {
25*1a3d31e3SAndroid Build Coastguard Worker 	__u64 *val = u_iop->pdu;
26*1a3d31e3SAndroid Build Coastguard Worker 	return be64_to_cpu(*val);
27*1a3d31e3SAndroid Build Coastguard Worker }
28*1a3d31e3SAndroid Build Coastguard Worker 
trace_unplug_io(struct io * u_iop)29*1a3d31e3SAndroid Build Coastguard Worker void trace_unplug_io(struct io *u_iop)
30*1a3d31e3SAndroid Build Coastguard Worker {
31*1a3d31e3SAndroid Build Coastguard Worker 	unplug_hist_add(u_iop);
32*1a3d31e3SAndroid Build Coastguard Worker 	dip_unplug(u_iop->t.device, BIT_TIME(u_iop->t.time), get_nio_up(u_iop));
33*1a3d31e3SAndroid Build Coastguard Worker 	io_release(u_iop);
34*1a3d31e3SAndroid Build Coastguard Worker }
35*1a3d31e3SAndroid Build Coastguard Worker 
trace_unplug_timer(struct io * ut_iop)36*1a3d31e3SAndroid Build Coastguard Worker void trace_unplug_timer(struct io *ut_iop)
37*1a3d31e3SAndroid Build Coastguard Worker {
38*1a3d31e3SAndroid Build Coastguard Worker 	dip_unplug_tm(ut_iop->t.device, BIT_TIME(ut_iop->t.time),
39*1a3d31e3SAndroid Build Coastguard Worker 			get_nio_up(ut_iop));
40*1a3d31e3SAndroid Build Coastguard Worker 	io_release(ut_iop);
41*1a3d31e3SAndroid Build Coastguard Worker }
42*1a3d31e3SAndroid Build Coastguard Worker 
trace_plug(struct io * p_iop)43*1a3d31e3SAndroid Build Coastguard Worker void trace_plug(struct io *p_iop)
44*1a3d31e3SAndroid Build Coastguard Worker {
45*1a3d31e3SAndroid Build Coastguard Worker 	dip_plug(p_iop->t.device, BIT_TIME(p_iop->t.time));
46*1a3d31e3SAndroid Build Coastguard Worker 	io_release(p_iop);
47*1a3d31e3SAndroid Build Coastguard Worker }
48