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: Is it ok to insert a module multiple times with staprun?


On Thu, Mar 30, 2017 at 3:22 AM, Arkady <arkady.miasnikov@gmail.com> wrote:
> You can try to use /proc support in the STAP - there is a "probe"
> which adds a file to the procfs
>
> For example, procfs("PATH").write { printf("User wrote: %s", $value) }

Procfs files can be used for several interesting situations. See the
json tapset for an example.

> Alternatively you can use debugfs like I do in
> https://github.com/larytet/YALAS/blob/master/src/driver/sysfs.c
>
> On Thu, Mar 30, 2017 at 11:11 AM, Shiyao Ma <i@introo.me> wrote:
>> Hi,
>>
>> Indeed I should insert the kernel module only once.  And do some
>> if-conditions based on the supplied parameters.
>>
>> The limitation on my side is, the params are rather long, exceeding the
>> shell limitation.
>>
>> I'd like the module to  read  a file (that contains the arguments).
>>
>> Does systemstap script has such a support?

Systemtap, when run in its default 'linux' mode which installs kernel
modules, cannot read files. There are lots of reasons for this, but in
general the kernel cannot open/read/write files for itself. (Obviously
user programs request the kernel to open/read/write files.)

You've got a couple of options off the top of my head to handle your parameters.

1) Command line arguments - i.e. module parameters. Systemtap modules
can take parameters that do several things, like:

- specify probe points:

# stap -e 'probe kernel.function(@1) { printf("%s\n", ppfunc());
exit() }' vfs_read
vfs_read

- specify values to test:

# stap -e 'probe begin { if ($1 == 1) { printf("1 processing here\n")
} else { printf("non-1 processing here\n") }; exit() }' 1
1 processing here

These are really module parameters - that value isn't compiled into
the module. The value gets assigned at module insertion time.

2) Procfs probes. procfs probes create /proc files. These files can be
used for data output or input. Akady showed example of data input
above. That '$value' variable contains whatever the user wrote into
the /proc file.

Really to help you further you are going to have to describe what you
are trying to do a bit further.

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)


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