public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: David Smith <dsmith@redhat.com>
To: Shiyao Ma <i@introo.me>
Cc: systemtap@sourceware.org
Subject: Re: Is it ok to insert a module multiple times with staprun?
Date: Fri, 31 Mar 2017 14:50:00 -0000	[thread overview]
Message-ID: <CAKFOr-a+j4an-YhDT4shSwjZnduPsi4fxyJCmX9rNVXBRjVwmg@mail.gmail.com> (raw)
In-Reply-To: <CAJQX3DyS2inKFwJPDpQc+d4PLj+zP5fFqZDcxARy--F-C+L4tw@mail.gmail.com>

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)

  parent reply	other threads:[~2017-03-31 14:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-30  4:41 Shiyao Ma
2017-03-30  5:40 ` Arkady
     [not found]   ` <e7f616ba-eb90-47ee-b784-ea02fdf519ff@Spark>
2017-03-30  8:22     ` Arkady
2017-03-30 14:53       ` David Smith
2017-03-31  3:51         ` Shiyao Ma
2017-03-31  4:08           ` Arkady
2017-03-31 14:50           ` David Smith [this message]
2017-03-31 15:40             ` David Smith
2017-03-31 15:46               ` Shiyao Ma
2017-04-01  6:15               ` Shiyao Ma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKFOr-a+j4an-YhDT4shSwjZnduPsi4fxyJCmX9rNVXBRjVwmg@mail.gmail.com \
    --to=dsmith@redhat.com \
    --cc=i@introo.me \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).