Re: Linux kernel marker questions

Mathieu Desnoyers <[email protected]>
Newsgroups gmane.linux.systemtap,gmane.linux.kernel.tracing
Message-ID <20070528182305.GD7882@Krystal>
* David Smith ([email protected]) wrote:
> Mathieu,
> 
> I've just finished checking in initial support for your new kernel 
> markers into systemtap.  I've got some rough edges to work on, but in 
> general it works.
> 
> As I implemented the marker support, I come up with several questions 
> I'd like some help/clarification with.
> 
> 1)  According to Documentation/marker.txt, the marker name 
> (subsystem_event) is "is an identifier unique to your event".
> 
> Am I correct that unique marker names are not strictly enforced but 
> "uniqueness" is more of a convention?
> 

Yes. A marker can be declared more than once, but bears the same
semantics and should have the same parameter types.

> _marker_set_probe() seems to support the view that marker names aren't 
> unique since it doesn't stop looking for more marker matches once it 
> finds a match.
> 

See answer below. Also, if a marker is defined in an inline function or
an unrolled loop (this last optimization is disabled in the kernel build
though), it will result in multiple occurences of the marker.

> One problem this creates for systemtap is that systemtap's probe syntax 
> looks like 'kernel.mark("marker_name")' and 
> 'module("module_name").mark('marker_name').  I believe with the current 
> code if a marker exists with the same name, format string, and flags in 
> the kernel and a loadable module there isn't any way to only enable the 
> marker in one place or the other - you can only enable both markers 
> (assuming the module is loaded).  Am I correct?
> 

Correct. It could be fixed by adapting _marker_set_probe, making it take
an optinional struct module* argument. It will have more effects on the
forthcoming markers version though, since I keep a data structure of the
active markers throrough the kernel, so that if a marker is set before a
module is loaded, the marker will be activated at module load time.

> 2) _marker_set_probe() expects the marker name, format string, and flags 
> that were specified when the marker was inserted.  If marker names were 
> truly unique, I would really only need the marker name to enable a marker.
> 

format string and flags are only there to make sure nobody writes
foolishly a "bad" probe without considering the reentrancy impact and
by expecting the wrong arguments. Note that passing a NULL format string
is valid and means that the probe will parse the string dynamicall,
therefore getting around the verification.

> Since systemtap can compile modules for a kernel that isn't running, I 
> can't really use marker_list_probe() for getting a list of markers 
> present (even if the output of marker_list_probe() was more than just 
> printks).  So, currently to get a list of markers for a particular 
> kernel, the code reads and parses the kernel/module '__markers_strings' 
> elf section, which gets systemtap the marker names and format strings. 
> (Getting the marker flags out of a kernel/module elf file is possible, 
> but won't be easy.)
> 
> Currently systemtap can only enable markers that used the MF_DEFAULT set 
> of flags.
> 
> Have you got any ideas on how systemtap (or any other program) can get a 
> list of all the data _marker_set_probe needs?
> 

Hrm.. well, isn't this information is a __markers section, which points
to a __markers data section ? It seems to me that it could be extracted
from the binary too, just like the __markers_strings. Please keep in
mind that these sections and data structures will change in the
forthcoming markers version.


> 3) From systemtap's point of view, _marker_set_probe() doesn't return 
> enough error information.  Currently it just returns the number of 
> probes enabled.  If _marker_set_probe returns a 0 (meaning no markers 
> were enabled), I don't know which of the following that means:
> 
> - the marker name wasn't found
> - the marker name was found, but format string didn't match the compiled 
> format string
> - the marker name was found and the format strings matched, but the 
> marker flags didn't match the compiled marker flags
> - the marker is already enabled (since markers can only have one 
> function attached to them at a time)
> 
> Would there be any way of getting more detailed error information?
> 

It will change in the new version. I guess we should rediscuss it once I
submit the new patches.

> Thanks for the help.
> 

Thanks for your collaboration, I hope I answered to your questions
appropriately.

Mathieu

> -- 
> David Smith
> [email protected]
> Red Hat
> http://www.redhat.com
> 256.217.0141 (direct)
> 256.837.0057 (fax)

-- 
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.