/************************************************************************** * * * Copyright (c) International Business Machines Corp., 2005 * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * * Author: Guanglei Li (guanglei@cn.ibm.com) * **************************************************************************/ /************************************************************ * Probe the event when a request is retrieved from request * * queue(dispatched to corresponding device), the event when * * a request is added by block layer into the request queue, * * and the event is removed by from the request queue * ************************************************************/ probe addevent.ioscheduler = addevent.ioscheduler.elv_next_request, addevent.ioscheduler.elv_add_request, addevent.ioscheduler.elv_remove_request { } /* when a request is retrieved from request queue */ probe addevent.ioscheduler.elv_next_request = kernel.function("elv_next_request") { if(filter_by_pid() == 1 ) { log_tracedata_common(HOOKID_IOSCHED_NEXT_REQ) log_ioscheduler_tracedata_extra_elv_next($q) } } /* when a request is added to the request queue */ probe addevent.ioscheduler.elv_add_request = kernel.function("__elv_add_request") { if(filter_by_pid() == 1 ) { log_tracedata_common(HOOKID_IOSCHED_ADD_REQ) log_ioscheduler_tracedata_extra_others($q, $rq) } } /* when a request is removed from the request queue */ probe addevent.ioscheduler.elv_remove_request = kernel.function("elv_remove_request") { if(filter_by_pid() == 1 ) { log_tracedata_common(HOOKID_IOSCHED_REMOVE_REQ) log_ioscheduler_tracedata_extra_others($q, $rq) } } %{ #include #include %} /* log the data specific to __elv_add_request and elv_remove_request, for kernel == 2.6.9. Need to confirm the actual kernel version range i.e. kernel_v <= 2.6.x. */ %( kernel_v == "2.6.9" %? function log_ioscheduler_tracedata_extra_others(var_q:long, var_rq:long) %{ struct request *rq = (struct request *)((long)THIS->var_rq); struct request_queue *q = (struct request_queue *)((long)THIS->var_q); /* elevator name|major|minor| */ _stp_printf("%s|%ld|%ld|", q->elevator.elevator_name, rq->rq_disk->major, rq->rq_disk->first_minor); %} /* log the data specific to __elv_add_request and elv_remove_request, for kernel > 2.6.9. The exact version need to be determined. */ %: function log_ioscheduler_tracedata_extra_others(var_q:long, var_rq:long) %{ struct request *rq = (struct request *)((long)THIS->var_rq); struct request_queue *q = (struct request_queue *)((long)THIS->var_q); /* elevator name|major|minor| */ _stp_printf("%s|%ld|%ld|", q->elevator->elevator_type->elevator_name, rq->rq_disk->major, rq->rq_disk->first_minor); %} %) /* log the data specific to elv_next_request, for kernel == 2.6.9 */ %( kernel_v == "2.6.9" %? function log_ioscheduler_tracedata_extra_elv_next(var:long) %{ struct request_queue *q; struct request *rq; q = (struct request_queue *)((long)THIS->var); /* If there is a request in the request queue: elevator name|major|minor| if there is no request in the request queue: elevator name|empty| */ if(list_empty(&(q->queue_head))) { _stp_printf("%s|empty|", q->elevator.elevator_name); } else { rq = list_entry_rq(q->queue_head.next); _stp_printf("%s|%ld|%ld", q->elevator.elevator_name, rq->rq_disk->major, rq->rq_disk->first_minor); } %} %: /* log the data specific to elv_next_request , for kernel > 2.6.9*/ function log_ioscheduler_tracedata_extra_elv_next(var:long) %{ struct request_queue *q; struct request *rq; q = (struct request_queue *)((long)THIS->var); /* If there is a request in the request queue: elevator name|major|minor| if there is no request in the request queue: elevator name|empty| */ if(list_empty(&(q->queue_head))) { _stp_printf("%s|empty|", q->elevator->elevator_type->elevator_name); } else { rq = list_entry_rq(q->queue_head.next); _stp_printf("%s|%ld|%ld", q->elevator->elevator_type->elevator_name, rq->rq_disk->major, rq->rq_disk->first_minor); } %} %)