From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20844 invoked by alias); 9 Dec 2005 02:17:17 -0000 Received: (qmail 20835 invoked by uid 22791); 9 Dec 2005 02:17:16 -0000 X-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: sourceware.org Received: from ausmtp04.au.ibm.com (HELO ausmtp04.au.ibm.com) (202.81.18.152) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 09 Dec 2005 02:17:14 +0000 Received: from sd0112e0.au.ibm.com (d23rh903.au.ibm.com [202.81.18.201]) by ausmtp04.au.ibm.com (8.12.10/8.12.10) with ESMTP id jB92KW2N064816 for ; Fri, 9 Dec 2005 13:20:32 +1100 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.250.244]) by sd0112e0.au.ibm.com (8.12.10/NCO/VERS6.8) with ESMTP id jB92K4Fk185876 for ; Fri, 9 Dec 2005 13:20:07 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.12.11/8.13.3) with ESMTP id jB92GB1p001729 for ; Fri, 9 Dec 2005 13:16:12 +1100 Received: from IBM946B3A4365F ([9.181.131.76]) by d23av03.au.ibm.com (8.12.11/8.12.11) with SMTP id jB92G5NY001502; Fri, 9 Dec 2005 13:16:09 +1100 Message-ID: <000a01c5fc66$7c8a9d90$4c83b509@IBM946B3A4365F> From: "Guanglei Li" To: "Frank Ch. Eigler" Cc: References: <002701c5fbcd$17d8aa70$4c83b509@IBM946B3A4365F> <001a01c5fc08$46f90530$5452b509@siemensswallow> <20051208152937.GM9617@redhat.com> Subject: Re: request to add additional runtime path Date: Fri, 09 Dec 2005 02:17:00 -0000 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2670 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2005-q4/txt/msg00384.txt.bz2 > Not that this directly relates to your issue, but why would you use > embedded-C for something like this? Could you post a fuller > example? > In fact, I am working on a kernel event trace tool using systemTap which targets for performance analysis. This tool will look at some interesting places inside the kernel and get the relative data for post analysis. The places it looks at are those such as scsi layers, io schedulers, syscalls etc. So I need some embedded c functions which will get the information by access kernel function parameters or directly calling some kernel functions or some other ways. Here's one of them, and I will send out the entire codes of this trace tool onto mailinglist some time later: /* 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(5) log_ioscheduler_tracedata_extra_elv_next($q) } } %( 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); } %} %: ... /* to deal with some other kernel versions, omitted ... */ %) /* data tracing filter by pid return: 1 - if continue to log the raw data 0 - return without logging the raw data */ function filter_by_pid:long() %{ struct task_struct *cur = current; if(cur->tgid != _stp_pid) /* skip stapd itself */ { /* to trace a specific process if we explicitly specify which process we want to trace by: 1. stap -c "process_to_trace" ... 2. stap -x pid_to_trace ... else we will trace all the processes */ if( _stp_target != 0 && cur->tgid != _stp_target) { THIS->__retvalue = 0; return; } THIS->__retvalue = 1; } else /*skip the events generated by stap itself*/ THIS->__retvalue = 0; return; %} /* Log the data common to all events */ function log_tracedata_common(hookID:long) %{ struct timeval tv; struct task_struct *cur = current; /* second|usec|pid|ppid|tid|cpuid|hoodID */ do_gettimeofday (&tv); _stp_printf("\n%ld|%ld|%ld|%ld|%ld|%u|%ld|", tv.tv_sec, tv.tv_usec, cur->tgid, \ cur->parent->pid, cur->pid, cur->thread_info->cpu,THIS->hookID); %} Here you can see log_tracedata_common(5), 5 is the hookID. I think it's better to use IOSCHED_NEXT_REQ_HOOKID instead of 5. So that it's easier for maintenance. > It is undesirable for embedded C code to make direct calls to the > runtime. Among other reasons, this is since that API exists for the > convenience of the translator, and thus may change frequently > Currently I have no need to put .c files into runtime dir. > >> [...] such macros appear almost in every stp files, so it's better >> to include a .h file in each stp file [...] > > Assuming this were a good idea, it could be supported by adding the > tapset source directories to the C compiler's include path. > Yes, in fact at present what I want is to add -I includepath when making the module. > > - FChE > >