This file is indexed.

/usr/share/systemtap/tapset/linux/ioscheduler.stp is in systemtap-common 2.6-0.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
// IO scheduler tapset
// Copyright (C) 2005, 2006 IBM Corp.
// Copyright (C) 2010 Red Hat Inc.
//
// This file is part of systemtap, and is free software.  You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.
// <tapsetdescription>
// This family of probe points is used to probe IO scheduler activities. 
// </tapsetdescription>
%{
#include <linux/blkdev.h>
#include <linux/elevator.h>
%}

/**
 * probe ioscheduler.elv_next_request - Fires when a request is retrieved from the request queue
 * @name: Name of the probe point
 * @elevator_name: The type of I/O elevator currently enabled
 */
probe ioscheduler.elv_next_request = kernel.function("blk_peek_request") !,
				     kernel.function("elv_next_request")
{
	name = "elv_next_request"
	elevator_name = kernel_string(
		@choose_defined($q->elevator->type->elevator_name,
			@choose_defined($q->elevator->elevator_type->elevator_name,
				$q->elevator->elevator_name)))
}

/**
 * probe ioscheduler.elv_next_request.return - Fires when a request retrieval issues a return signal
 * @name: Name of the probe point
 * @rq: Address of the request
 * @rq_flags: Request flags
 * @disk_major: Disk major number of the request
 * @disk_minor: Disk minor number of the request
 */
probe ioscheduler.elv_next_request.return =
		kernel.function("blk_peek_request").return !,
		kernel.function("elv_next_request").return
{
	name = "elv_next_request"
	if ($return == 0)  {
		rq = 0
		rq_flags = 0
		disk_major = -1
		disk_minor = -1
	} else {
		rq = $return
		rq_flags = @choose_defined($return->cmd_flags, $return->flags)
		if ($return->rq_disk == 0)  {
			disk_major = -1
			disk_minor = -1
		} else {
			disk_major = $return->rq_disk->major
			disk_minor = $return->rq_disk->first_minor
		}
	}
}

/**
 * probe ioscheduler.elv_completed_request - Fires when a request is completed
 * @name: Name of the probe point
 * @elevator_name: The type of I/O elevator currently enabled
 * @rq: Address of the request
 * @rq_flags: Request flags
 * @disk_major: Disk major number of the request
 * @disk_minor: Disk minor number of the request
 */
probe ioscheduler.elv_completed_request
	= kernel.function("elv_completed_request")
{
	name = "elv_completed_request"
	elevator_name = kernel_string(
		@choose_defined($q->elevator->type->elevator_name,
			@choose_defined($q->elevator->elevator_type->elevator_name,
				$q->elevator->elevator_name)))
	if($rq == 0)  {
		disk_major = -1
		disk_minor = -1
	} else {
		if($rq->rq_disk == 0)  {
			disk_major = -1
			disk_minor = -1
		} else {
			disk_major = $rq->rq_disk->major
			disk_minor = $rq->rq_disk->first_minor
		}
	}

	rq = $rq
	rq_flags = ($rq == 0) ? 0
		: @choose_defined($rq->cmd_flags, $rq->flags)
}

/**
 * probe ioscheduler.elv_add_request.kp - kprobe based probe to indicate that a request was added to the request queue
 * @name: Name of the probe point
 * @elevator_name: The type of I/O elevator currently enabled
 * @q: pointer to request queue
 * @rq: Address of the request
 * @rq_flags: Request flags
 * @disk_major: Disk major number of the request
 * @disk_minor: Disk minor number of the request
 */
// when a request is added to the request queue
probe ioscheduler.elv_add_request.kp =
		kernel.function("elv_insert") !,
		kernel.function("__elv_add_request")
{
	name = "elv_add_request"
	elevator_name = kernel_string(
		@choose_defined($q->elevator->type->elevator_name,
			@choose_defined($q->elevator->elevator_type->elevator_name,
				$q->elevator->elevator_name)))
	q = $q
	if($rq == 0)  {
		disk_major = -1
		disk_minor = -1
	} else {
		if($rq->rq_disk == 0)  {
			disk_major = -1
			disk_minor = -1
		} else {
			disk_major = $rq->rq_disk->major
			disk_minor = $rq->rq_disk->first_minor
		}
	}

	rq = $rq
	rq_flags = ($rq == 0) ? 0
		: @choose_defined($rq->cmd_flags, $rq->flags)
}

/**
 * probe ioscheduler.elv_add_request.tp - tracepoint based probe to indicate a request is added to the request queue.
 * @name		: Name of the probe point
 * @elevator_name	: The type of I/O elevator currently enabled.
 * @q			: Pointer to request queue.
 * @rq			: Address of request.
 * @rq_flags		: Request flags.
 * @disk_major		: Disk major no of request.
 * @disk_minor		: Disk minor number of request.
 *
 */
probe ioscheduler.elv_add_request.tp = kernel.trace("block_rq_insert") ?
{
	name = "elv_add_request"
	q =  $q
	elevator_name = kernel_string(
		@choose_defined($q->elevator->type->elevator_name,
			@choose_defined($q->elevator->elevator_type->elevator_name,
				$q->elevator->elevator_name)))
	rq = $rq

	if ($rq == 0 || $rq->rq_disk ==0) {
		disk_major = -1
		disk_minor = -1
	}
	else {
		disk_major = $rq->rq_disk->major
		disk_minor = $rq->rq_disk->first_minor
	}

	rq_flags = ($rq == 0) ? 0
		: @choose_defined($rq->cmd_flags, $rq->flags)
}

/**
 * probe ioscheduler.elv_add_request - probe to indicate request is added to the request queue.
 * @elevator_name	: The type of I/O elevator currently enabled.
 * @q			: Pointer to request queue.
 * @rq			: Address of request.
 * @rq_flags		: Request flags.
 * @disk_major		: Disk major no of request.
 * @disk_minor		: Disk minor number of request.
 *
 */
probe ioscheduler.elv_add_request =
	ioscheduler.elv_add_request.tp !, ioscheduler.elv_add_request.kp
{}

/**
 * probe ioscheduler_trace.elv_completed_request - Fires when a request is
 *							completed.
 * @name		: Name of the probe point
 * @elevator_name	: The type of I/O elevator currently enabled.
 * @rq			: Address of request.
 * @rq_flags		: Request flags.
 * @disk_major		: Disk major no of request.
 * @disk_minor		: Disk minor number of request.
 *
 */
probe ioscheduler_trace.elv_completed_request
			= kernel.trace("block_rq_complete") ?
{
	name = "elv_completed_request"
	elevator_name = kernel_string(
		@choose_defined($q->elevator->type->elevator_name,
			@choose_defined($q->elevator->elevator_type->elevator_name,
				$q->elevator->elevator_name)))
	rq = $rq

	if ($rq == 0 || $rq->rq_disk ==0) {
		disk_major = -1
		disk_minor = -1
	}
	else {
		disk_major = $rq->rq_disk->major
		disk_minor = $rq->rq_disk->first_minor
	}

	rq_flags = ($rq == 0) ? 0
		: @choose_defined($rq->cmd_flags, $rq->flags)
}

/**
 * probe ioscheduler_trace.elv_issue_request - Fires when a request is
 *							scheduled.
 * @name		: Name of the probe point
 * @elevator_name	: The type of I/O elevator currently enabled.
 * @rq			: Address of request.
 * @rq_flags		: Request flags.
 * @disk_major		: Disk major no of request.
 * @disk_minor		: Disk minor number of request.
 *
 */
probe ioscheduler_trace.elv_issue_request
			= kernel.trace("block_rq_issue") ?
{
	name = "elv_issue_request"
	elevator_name = kernel_string(
		@choose_defined($q->elevator->type->elevator_name,
			@choose_defined($q->elevator->elevator_type->elevator_name,
				$q->elevator->elevator_name)))
	rq = $rq

	if ($rq == 0 || $rq->rq_disk ==0) {
		disk_major = -1
		disk_minor = -1
	}
	else {
		disk_major = $rq->rq_disk->major
		disk_minor = $rq->rq_disk->first_minor
	}

	rq_flags = ($rq == 0) ? 0
		: @choose_defined($rq->cmd_flags, $rq->flags)
}

/**
 * probe ioscheduler_trace.elv_requeue_request - Fires when a request is
 *	put back on the queue, when the hadware cannot accept more requests.
 * @name		: Name of the probe point
 * @elevator_name	: The type of I/O elevator currently enabled.
 * @rq			: Address of request.
 * @rq_flags		: Request flags.
 * @disk_major		: Disk major no of request.
 * @disk_minor		: Disk minor number of request.
 *
 */
probe ioscheduler_trace.elv_requeue_request
			= kernel.trace("block_rq_requeue") ?
{
	name = "elv_requeue_request"
	elevator_name = kernel_string(
		@choose_defined($q->elevator->type->elevator_name,
			@choose_defined($q->elevator->elevator_type->elevator_name,
				$q->elevator->elevator_name)))
	rq = $rq

	if ($rq == 0 || $rq->rq_disk ==0) {
		disk_major = -1
		disk_minor = -1
	}
	else {
		disk_major = $rq->rq_disk->major
		disk_minor = $rq->rq_disk->first_minor
	}

	rq_flags = ($rq == 0) ? 0
		: @choose_defined($rq->cmd_flags, $rq->flags)
}

/**
 * probe ioscheduler_trace.elv_abort_request - Fires when a request is aborted.
 * @name		: Name of the probe point
 * @elevator_name	: The type of I/O elevator currently enabled.
 * @rq			: Address of request.
 * @rq_flags		: Request flags.
 * @disk_major		: Disk major no of request.
 * @disk_minor		: Disk minor number of request.
 *
 */
probe ioscheduler_trace.elv_abort_request
			= kernel.trace("block_rq_abort") ?
{
	name = "elv_abort_request"
	elevator_name = kernel_string(
		@choose_defined($q->elevator->type->elevator_name,
			@choose_defined($q->elevator->elevator_type->elevator_name,
				$q->elevator->elevator_name)))
	rq = $rq

	if ($rq == 0 || $rq->rq_disk ==0) {
		disk_major = -1
		disk_minor = -1
	}
	else {
		disk_major = $rq->rq_disk->major
		disk_minor = $rq->rq_disk->first_minor
	}

	rq_flags = ($rq == 0) ? 0
		: @choose_defined($rq->cmd_flags, $rq->flags)
}

/**
 * probe ioscheduler_trace.plug - Fires when a request queue is plugged;
 *		ie, requests in the queue cannot be serviced by block driver.
 * @name	: Name of the probe point
 * @rq_queue	: request queue
 *
 */
probe ioscheduler_trace.plug = kernel.trace("block_plug") ?
{
	name = "plug"
	rq_queue = $q
}

/**
 * probe ioscheduler_trace.unplug_io - Fires when a request queue is unplugged;
 *	Either, when number of pending requests in the queue exceeds threshold
 *	or, upon expiration of timer that was activated when queue was plugged.
 * @name	: Name of the probe point
 * @rq_queue	: request queue
 *
 */
probe ioscheduler_trace.unplug_io = kernel.trace("block_unplug_io") ?
{
	name = "unplug_io"
	rq_queue = $q
}

/**
 * probe ioscheduler_trace.unplug_timer - Fires when unplug timer associated
 *					with a request queue expires.
 * @name	: Name of the probe point
 * @rq_queue	: request queue
 *
 */
probe ioscheduler_trace.unplug_timer = kernel.trace("block_unplug_timer") ?
{
	name = "unplug_timer"
	rq_queue = $q
}

function disk_major_from_request:long(var_q:long)
%{ /* pure */
	struct request_queue *q = (struct request_queue *)((long)STAP_ARG_var_q);

	/* We need to make sure there isn't a deref hazard here when
	 * reading 'q->queue_head'.  However, kread() wants a pointer to
	 * a pointer, and we can't provide that for 'q->queue_head'
	 * since the list_head structure is directly embedded in the
	 * 'struct request_queue'.  So, we validate all the members of
	 * the list_head structure instead. */
	(void) kread(&(q->queue_head.next));
	(void) kread(&(q->queue_head.prev));
	if (list_empty(&(q->queue_head)))
		STAP_RETVALUE = -1;
	else  {
		struct request *rq = list_entry_rq(q->queue_head.next);
		struct gendisk *rq_disk = kread(&(rq->rq_disk));
		STAP_RETVALUE = kread(&(rq_disk->major));
	}
	CATCH_DEREF_FAULT();
%}

function disk_minor_from_request:long(var_q:long)
%{ /* pure */
	struct request_queue *q = (struct request_queue *)((long)STAP_ARG_var_q);

	/* We need to make sure there isn't a deref hazard here when
	 * reading 'q->queue_head'.  However, kread() wants a pointer to
	 * a pointer, and we can't provide that for 'q->queue_head'
	 * since the list_head structure is directly embedded in the
	 * 'struct request_queue'.  So, we validate all the members of
	 * the list_head structure instead. */
	(void) kread(&(q->queue_head.next));
	(void) kread(&(q->queue_head.prev));
	if (list_empty(&(q->queue_head)))
		STAP_RETVALUE = -1;
	else  {
		struct request *rq = list_entry_rq(q->queue_head.next);
		struct gendisk *rq_disk = kread(&(rq->rq_disk));
		STAP_RETVALUE = kread(&(rq_disk->first_minor));
	}
	CATCH_DEREF_FAULT();
%}