public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Re: systemtap question..
       [not found] <48ACFC02.3080002@gmail.com>
@ 2008-08-23  4:28 ` Peter Teoh
  2008-08-23 12:51   ` Mark Wielaard
  2008-08-23 14:09   ` Frank Ch. Eigler
  0 siblings, 2 replies; 5+ messages in thread
From: Peter Teoh @ 2008-08-23  4:28 UTC (permalink / raw)
  To: systemtap; +Cc: Om Narasimhan

as discovered by narasimhan, the following script will lead to kernel
freezing and hanged for me:

I execute via "stap -kvvv script.stp" command.

Question is:  why does he get a compilation error when using the -u
option?  (same for me as well, which goes away when removed?)

On Thu, Aug 21, 2008 at 1:24 PM, Om Narasimhan <om.turyx@gmail.com> wrote:
> --script begin--
> [om@testserv ~]$ cat /space/stap/inode-watch.stp
> # Usage:
> # taps the vfs_write and vfs_read
> #
>
> probe kernel.function ("vfs_read"), kernel.function("vfs_write")
> {
>       inode = $file->f_dentry->d_inode->i_ino
>       dev_nr = $file->f_dentry->d_inode->i_sb->s_dev
>
> }
> -- script end--
> --errors begin--
> [om@testserv ~]$ stap -vv -u /space/stap/inode-watch.stp
> SystemTap translator/driver (version 0.6.2/0.127 built 2008-03-27)
> Copyright (C) 2005-2008 Red Hat, Inc. and others
> This is free software; see the source for copying conditions.
> Created temporary directory "/tmp/stap6uzgp4"
> Searched '/usr/share/systemtap/tapset/x86_64/*.stp', found 1
> Searched '/usr/share/systemtap/tapset/*.stp', found 37
> Pass 1: parsed user script and 38 library script(s) in 130usr/0sys/134real
> ms.
> probe vfs_read@fs/read_write.c:257 kernel section=.text
> pc=0xffffffff81098064
> probe vfs_write@fs/read_write.c:315 kernel section=.text
> pc=0xffffffff81097eed
> semantic error: field 'f_dentry' not found (alternatives: f_u f_path f_op
> f_count f_flags f_mode f_pos f_owner f_uid f_gid f_ra f_version f_security
> private_data f_ep_links f_ep_lock f_mapping): identifier '$file' at
> /space/stap/inode-watch.stp:7:10
> semantic error: field 'f_dentry' not found (alternatives: f_u f_path f_op
> f_count f_flags f_mode f_pos f_owner f_uid f_gid f_ra f_version f_security
> private_data f_ep_links f_ep_lock f_mapping): identifier '$file' at
> /space/stap/inode-watch.stp:8:11
> semantic error: probe_1063 with unresolved type: identifier 'inode' at
> /space/stap/inode-watch.stp:7:2
> semantic error: probe_1063 with unresolved type: identifier 'dev_nr' at
> /space/stap/inode-watch.stp:8:2
> semantic error: probe_1064 with unresolved type: identifier 'inode' at
> /space/stap/inode-watch.stp:7:2
> semantic error: probe_1064 with unresolved type: identifier 'dev_nr' at
> /space/stap/inode-watch.stp:8:2
> Pass 2: analyzed script: 2 probe(s), 0 function(s), 0 embed(s), 0 global(s)
> in 230usr/70sys/306real ms.
> Pass 2: analysis failed.  Try again with more '-v' (verbose) options.
> Running rm -rf /tmp/stap6uzgp4
> --errors end--
>
> I know why the error occur.
> From include/linux/fs.h,
> #define f_dentry    f_path.dentry
>
> Apparently f_dentry cannot be used from systemtap.
> If I replace f_dentry with fpath.dentry, systemtap complains about string
> operations because `.` is string concatenation operator.
>
> Any idea? Any pointers?
>
> Thanks,
> Om.


-- 
Regards,
Peter Teoh

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: systemtap question..
  2008-08-23  4:28 ` systemtap question Peter Teoh
@ 2008-08-23 12:51   ` Mark Wielaard
  2008-08-23 14:09   ` Frank Ch. Eigler
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Wielaard @ 2008-08-23 12:51 UTC (permalink / raw)
  To: Peter Teoh; +Cc: systemtap, Om Narasimhan

Hi Peter,

On Sat, 2008-08-23 at 12:27 +0800, Peter Teoh wrote:
> as discovered by narasimhan, the following script will lead to kernel
> freezing and hanged for me:
> 
> I execute via "stap -kvvv script.stp" command.

The kernel freezing is worrying. That should not happen. And it doesn't
for me. Do you have some more information? Kernel version, any
backtraces on the console when this happens, etc.

> Question is:  why does he get a compilation error when using the -u
> option?  (same for me as well, which goes away when removed?)

When you use -u stap doesn't remove unused parts of the script.
Without -u stap is "smart" and sees that you never actually use any of
the variables in your script:

WARNING: eliding unused variable identifier 'inode' at script.stp:3:7
WARNING: eliding unused variable identifier 'dev_nr' at script.stp:4:7
WARNING: eliding unused variable identifier 'inode' at script.stp:3:7
WARNING: eliding unused variable identifier 'dev_nr' at script.stp:4:7

If you add something like the following to your probe it will actually
use these variables and give an error about the code that assigns values
to them:

  printf("%s inode: %d, dev_nr: %d\n", probefunc(), inode, dev_nr);

semantic error: field 'f_dentry' not found (alternatives: f_u f_path
f_op f_count f_flags f_mode f_pos f_owner f_uid f_gid f_ra f_version
f_security private_data f_ep_links f_ep_lock f_mapping): identifier
'$file' at script.stp:3:15

And indeed you need to replace f_dentry with f_path->dentry for newer
kernels.

Cheers,

Mark

This is the full version of the script that works for me against
2.6.25.14:

probe kernel.function ("vfs_read"), kernel.function("vfs_write")
{
      inode = $file->f_path->dentry->d_inode->i_ino
      dev_nr = $file->f_path->dentry->d_inode->i_sb->s_dev
      printf("%s inode: %d, dev_nr: %d\n", probefunc(), inode, dev_nr);
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: systemtap question..
  2008-08-23  4:28 ` systemtap question Peter Teoh
  2008-08-23 12:51   ` Mark Wielaard
@ 2008-08-23 14:09   ` Frank Ch. Eigler
  1 sibling, 0 replies; 5+ messages in thread
From: Frank Ch. Eigler @ 2008-08-23 14:09 UTC (permalink / raw)
  To: Peter Teoh; +Cc: systemtap, Om Narasimhan

"Peter Teoh" <htmldeveloper@gmail.com> writes:

> as discovered by narasimhan, the following script will lead to kernel
> freezing and hanged for me:
> I execute via "stap -kvvv script.stp" command.

Please see the "HowToReportBugs" systemtap wiki page.


> Question is:  why does he get a compilation error when using the -u
> option?  (same for me as well, which goes away when removed?)

>> probe kernel.function ("vfs_read"), kernel.function("vfs_write")
>> {
>>       inode = $file->f_dentry->d_inode->i_ino
>>       dev_nr = $file->f_dentry->d_inode->i_sb->s_dev
>>
>> }

The reason is that this probe does nothing.  The "inode" and "dev_nr"
variables being fetched are not printed, so systemtap figures they
were not needed in the first place, and elides the $-expressions.  The
"-u" (unoptimized) flag preserves such code.

- FChE

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: systemtap question
@ 2006-09-06 18:41 Stone, Joshua I
  0 siblings, 0 replies; 5+ messages in thread
From: Stone, Joshua I @ 2006-09-06 18:41 UTC (permalink / raw)
  To: Frank Ch. Eigler, Anthony Green; +Cc: systemtap

On Wednesday, September 06, 2006 6:36 AM, Frank Ch. Eigler wrote:
> Hi -
> 
> green@redhat.com wrote:
> 
>> I have a customer who wants certain system files to have
>> non-standard file permissions, but some cron job keeps changing them
>> back every night.  He'd like to figure out who is doing this.
> 
> OK.
> 
>> Is this the kind of thing systemtap could help with?  Do you have
>> any examples that are similar to this?

Here's a tiny script that probes the chmod syscall, and prints the
calling process and walks the process "stack".  You might also have to
probe fchmod, but it's more difficult to account that since you only get
the file descriptor.

Josh


probe syscall.chmod {
  printf("%5d %-16s %s -> %#o\n", tid(), execname(), path, mode)
  printf(" ^\n")
  for (t = task_parent(task_current()); task_tid(t) != 0; t =
task_parent(t)) {
    printf(" | %5d %s\n", task_tid(t), task_execname(t))
  }
  printf(" ------------------------\n")
}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: systemtap question
       [not found] <1157546598.2847.28.camel@localhost.localdomain>
@ 2006-09-06 13:36 ` Frank Ch. Eigler
  0 siblings, 0 replies; 5+ messages in thread
From: Frank Ch. Eigler @ 2006-09-06 13:36 UTC (permalink / raw)
  To: Anthony Green; +Cc: systemtap

Hi -

green@redhat.com wrote:

> I have a customer who wants certain system files to have
> non-standard file permissions, but some cron job keeps changing them
> back every night.  He'd like to figure out who is doing this.

OK.

> Is this the kind of thing systemtap could help with?  Do you have
> any examples that are similar to this?

The closest one would be one of the demos from the tutorial, which I'm
plopping onto the wiki as we speak.
http://sourceware.org/systemtap/wiki/WSFileMonitor

- FChE

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-08-23 14:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <48ACFC02.3080002@gmail.com>
2008-08-23  4:28 ` systemtap question Peter Teoh
2008-08-23 12:51   ` Mark Wielaard
2008-08-23 14:09   ` Frank Ch. Eigler
2006-09-06 18:41 Stone, Joshua I
     [not found] <1157546598.2847.28.camel@localhost.localdomain>
2006-09-06 13:36 ` Frank Ch. Eigler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).