This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: kernel read fault when accessing context variables


I'm sorry that was a typo, npid is the name of the local variable I use in my
script. There is no local variable named npid in the scheduler. It should've
read npid = $next->tgid. As for the semantic errors, npid is not found
because as you pointed out it does not exist. And $prev isn't being found
because you probably aren't specifying a line number near enough to it. I
used 5364 or 5365 because that worked for my kernel version. You would need
to look at your sched.c file and find the correct line number, generally any
place where prev is used will work for me (making sure it's already been set
though). But, I also went line by line through the entire schedule function
and I would either get a semantic error (when it couldn't be found), or I
would get a kernel read fault (it's been found but there is some kind of
fault in reading it).

Could you tell me if it works for you if you look at a line in sched.c where
prev is set (or near it), and not just at the beginning of the function? In
the meantime I will try using a gcc version as suggested by Frank. As for my
compiler I used 4.4.1 which I guess is the latest version available through
apt-get on Ubuntu 9.10. I would like to know if anybody can get this working
on Ubuntu 9.10 so I can know their setup.


Mark Wielaard-4 wrote:
> 
> Hi Tony,
> 
> On Wed, 2010-07-07 at 11:41 -0700, tonyg362 wrote:
>> I'm trying to access the prev/next task structs within the scheduler e.g.
>> 
>> probe kernel.statement("schedule@kernel/sched.c:line#") {
>>     ppid = $prev->tgid
>>     npid = $npid->tgid
>> 
>>     printf("ppid:%d, npid:%d\n", ppid, npid)
>> }
>> 
>> I am able access $npid->tgid just fine and it prints the correct npid,
>> however whenever I try to access $prev->tgid the entire probe is skipped
>> and
>> I get a kernel read fault:
>> 
>> focused on module 'kernel'
>> selected source file '/build/buildd/linux-2.6.31/kernel/sched.c'
>> selected function schedule
>> probe schedule@/build/buildd/linux-2.6.31/kernel/sched.c:5365 kernel
>> reloc=.dynamic section=.text pc=0xffffffff8152bc4e
>> finding location for local 'prev' near address 0xffffffff8152bc4e, module
>> bias 0x0
>> [...]
>> ERROR: kernel read fault at 0x000000000000029d (addr) near identifier
>> '$prev' at test.stp:2:9
>>
>> I've tried building my own kernel, I've tried version 2.6.28, this error
>> seems to persist no matter what I try. I've even tried systemtap 1.2 same
>> problem.
> 
> I am not seeing the same thing as you, but I do also have trouble trying
> to grab $prev and $npid from schedule().
> 
> semantic error: not accessible at this address (0xffffffff814d7b30):
> identifier '$prev' at <input>:2:12
>         source:     ppid = $prev->tgid
>                            ^
> semantic error: unable to find local 'npid' near pc 0xffffffff814d7b30
> in schedule(kernel/sched.c) (alternatives: $prev $next $switch_count $rq
> $cpu): identifier '$npid' at :3:12
>         source:     npid = $npid->tgid
>                            ^
> 
> It is correct about $npid, there is no argument or local variable with
> that name in my kernel/sched.c(schedule) function. It might be correct
> about $prev, it might not yet be available at the start of the function.
> 
> I haven't inspected the dwarf output yet, but I assume gcc got somewhat
> confused here. I do notice schedule is marked with asmlinkage
> http://kernelnewbies.org/FAQ/asmlinkage maybe that gets gcc confused?
> 
> What compiler did you use to build your kernel?
> 
> Thanks,
> 
> Mark
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/kernel-read-fault-when-accessing-context-variables-tp29099754p29108946.html
Sent from the Sourceware - systemtap mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]