This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Is it ok to insert a module multiple times with staprun?
On Thu, Mar 30, 2017 at 10:51 PM, Shiyao Ma <i@introo.me> wrote:
> Hi,
>
>> Really to help you further you are going to have to describe what you
>> are trying to do a bit further.
>
>
> My aim is to pass in some information (arguments) to the module at run
> time (so in pass-5 time, not pass-[1-4]).
> That rules out the first option. stap -e "foobar".
>\
> Also, using the command line of staprun does not work here, due to the
> length limitation on shell command line.
To be clear (and perhaps you understand this already), the following
*does* substitute "vfs_read" in at pass 5 time:
# stap -e 'probe kernel.function(@1) { printf("%s\n", ppfunc());
exit() }' vfs_read
> The second procfs option, on the other hand, sounds feasible.
> However, I have a minor concern here. I'd like the info passed to the
> module (via procfs) be read at the very beginning, *before any
> kernel.function" probe has been registered to the system.
> In other words, any kernel.function probe should only be activated
> after the procfs.read is done.
>
> The closest thing I can come up in my mind is to do something like:
> probe begin {
> read_the_procfs_file_and_wait()
> }
>
> That is, put the reading file stuff into the begin probe.
>
> Possible to achieve that?
As you have written above, no.
As Arkady said, you'd have a global variable that would be set after
the procfs information is set, something like the following:
====
global config_done
probe procfs.write("config")
{
# process $value here
config_done = 1
}
probe kernel.function("vfs_read")
{
if (!config_done) next
# real processing here...
}
====
You'd run it like the following:
# stap -m foo foo.stp &
# cat config > /proc/systemtap/foo/config
Actually, it is even easier if your kernel is > 2.6.30, you can use
on-the-fly probes. In this case, the kprobe is disabled until
config_done is set.
====
global config_done
probe procfs.write("config")
{
# process $value here
config_done = 1
}
probe kernel.function("vfs_read") if (config_done)
{
# real processing here...
}
====
--
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)