Re: [PATCH 3/3] Add marker_query service
Mathieu Desnoyers <[email protected]>
| Newsgroups | gmane.linux.kernel.tracing |
|---|---|
| Message-ID | <20070514201727.GC25984@Krystal> |
Will apply, but I wonder why we start "instance" at 1 instead of 0... ? * Jan Kiszka ([email protected]) wrote: > Introduce marker_query(name, instance) to obtain a reference to a > marker's __mark_marker_data structure. This information can be used to > search for markers of a specific name and check the returned format > string for consistency in more flexible ways or defer the check. So far > consistency checks are done via a full string match on marker_set_probe > invocation, now we can also apply checksum tests without having to know > the string in advance in the context of marker_set_probe. > > > Signed-off-by: Jan Kiszka <[email protected]> > > --- > include/linux/marker.h | 1 + > kernel/module.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 48 insertions(+) > > Index: linux-2.6.21.1/kernel/module.c > =================================================================== > --- linux-2.6.21.1.orig/kernel/module.c > +++ linux-2.6.21.1/kernel/module.c > @@ -448,6 +448,26 @@ static int marker_list_probe_range(marke > return found; > } > > +/* Looks up a marker by its name and instance number within the specificed > + * range and returns the associated data structure. */ > +const struct __mark_marker_data *marker_query_range(const char *name, > + int instance, > + const struct __mark_marker *begin, > + const struct __mark_marker *end) > +{ > + const struct __mark_marker *iter; > + int found = 0; > + > + for (iter = begin; iter < end; iter++) { > + if (strcmp(name, iter->mdata->name) != 0) > + continue; > + > + if (found++ == instance) > + return iter->mdata; > + } > + return NULL; > +} > + > /* Calls _marker_set_probe_range for the core markers and modules markers. > * Marker enabling/disabling use the modlist_lock to synchronise. */ > int _marker_set_probe(int flags, const char *name, const char *format, > @@ -522,6 +542,33 @@ int marker_list_probe(marker_probe_func > return found; > } > EXPORT_SYMBOL_GPL(marker_list_probe); > + > +/* Looks up a marker by its name and instance number and returns the > + * associated data structure. */ > +const struct __mark_marker_data *marker_query(const char *name, int instance) > +{ > + struct module *mod; > + const struct __mark_marker_data *mdata; > + > + mutex_lock(&module_mutex); > + /* Core kernel markers */ > + mdata = marker_query_range(name, instance, > + __start___markers, __stop___markers); > + if (!mdata) { > + /* Markers in modules. */ > + list_for_each_entry(mod, &modules, list) > + if (!mod->taints) { > + mdata = marker_query_range(name, instance, > + mod->markers, > + mod->markers+mod->num_markers); > + if (mdata) > + break; > + } > + } > + mutex_unlock(&module_mutex); > + return mdata; > +} > +EXPORT_SYMBOL_GPL(marker_query); > #endif > > #ifdef CONFIG_SMP > Index: linux-2.6.21.1/include/linux/marker.h > =================================================================== > --- linux-2.6.21.1.orig/include/linux/marker.h > +++ linux-2.6.21.1/include/linux/marker.h > @@ -116,6 +116,7 @@ extern int _marker_set_probe(int flags, > > extern int marker_remove_probe(const char *name); > extern int marker_list_probe(marker_probe_func *probe); > +const struct __mark_marker_data *marker_query(const char *name, int instance); > > #endif /* __KERNEL__ */ > #endif > > _______________________________________________ > Ltt-dev mailing list > [email protected] > http://listserv.shafik.org/mailman/listinfo/ltt-dev -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 _______________________________________________ Ltt-dev mailing list [email protected] http://listserv.shafik.org/mailman/listinfo/ltt-dev
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFGSMPXPyWo/juummgRAh68AJ4jTtQU1kJqCsT91mEQunXvND5A+ACeM/fe sNw2wgP4WQIBLKUwIYnvj5k= =bdLD -----END PGP SIGNATURE-----