1 /* $NetBSD: rf_acctrace.c,v 1.22 2006/10/12 01:31:50 christos Exp $ */
3 * Copyright (c) 1995 Carnegie-Mellon University.
8 * Permission to use, copy, modify and distribute this software and
9 * its documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
16 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 * Carnegie Mellon requests users of this software to return to
20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
29 /*****************************************************************************
31 * acctrace.c -- code to support collecting information about each access
33 *****************************************************************************/
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: rf_acctrace.c,v 1.22 2006/10/12 01:31:50 christos Exp $");
40 #include <sys/types.h>
41 #include <dev/raidframe/raidframevar.h>
43 #include "rf_threadstuff.h"
44 #include "rf_debugMem.h"
45 #include "rf_acctrace.h"
46 #include "rf_general.h"
48 #include "rf_etimer.h"
50 #include "rf_shutdown.h"
53 static long numTracesSoFar
;
55 RF_DECLARE_MUTEX(rf_tracing_mutex
)
58 rf_ConfigureAccessTrace(RF_ShutdownList_t
**listp
)
61 rf_mutex_init(&rf_tracing_mutex
);
65 /* install a trace record. cause a flush to disk or to the trace
66 * collector daemon if the trace buffer is at least 1/2 full.
69 rf_LogTraceRec(RF_Raid_t
*raid
, RF_AccTraceEntry_t
*rec
)
71 RF_AccTotals_t
*acc
= &raid
->acc_totals
;
73 if (((rf_maxNumTraces
>= 0) && (numTracesSoFar
>= rf_maxNumTraces
)))
76 /* update AccTotals for this device */
77 if (!raid
->keep_acc_totals
)
81 acc
->recon_start_to_fetch_us
+= rec
->specific
.recon
.recon_start_to_fetch_us
;
82 acc
->recon_fetch_to_return_us
+= rec
->specific
.recon
.recon_fetch_to_return_us
;
83 acc
->recon_return_to_submit_us
+= rec
->specific
.recon
.recon_return_to_submit_us
;
84 acc
->recon_num_phys_ios
+= rec
->num_phys_ios
;
85 acc
->recon_phys_io_us
+= rec
->phys_io_us
;
86 acc
->recon_diskwait_us
+= rec
->diskwait_us
;
87 acc
->recon_reccount
++;
89 RF_HIST_ADD(acc
->tot_hist
, rec
->total_us
);
90 RF_HIST_ADD(acc
->dw_hist
, rec
->diskwait_us
);
91 /* count of physical ios which are too big. often due to
92 * thermal recalibration */
93 /* if bigvals > 0, you should probably ignore this data set */
94 if (rec
->diskwait_us
> 100000)
96 acc
->total_us
+= rec
->total_us
;
97 acc
->suspend_ovhd_us
+= rec
->specific
.user
.suspend_ovhd_us
;
98 acc
->map_us
+= rec
->specific
.user
.map_us
;
99 acc
->lock_us
+= rec
->specific
.user
.lock_us
;
100 acc
->dag_create_us
+= rec
->specific
.user
.dag_create_us
;
101 acc
->dag_retry_us
+= rec
->specific
.user
.dag_retry_us
;
102 acc
->exec_us
+= rec
->specific
.user
.exec_us
;
103 acc
->cleanup_us
+= rec
->specific
.user
.cleanup_us
;
104 acc
->exec_engine_us
+= rec
->specific
.user
.exec_engine_us
;
105 acc
->xor_us
+= rec
->xor_us
;
106 acc
->q_us
+= rec
->q_us
;
107 acc
->plog_us
+= rec
->plog_us
;
108 acc
->diskqueue_us
+= rec
->diskqueue_us
;
109 acc
->diskwait_us
+= rec
->diskwait_us
;
110 acc
->num_phys_ios
+= rec
->num_phys_ios
;
111 acc
->phys_io_us
= rec
->phys_io_us
;
112 acc
->user_reccount
++;
115 #endif /* RF_ACC_TRACE > 0 */