[PATCH 3/3] Add marker_query service
Jan Kiszka <[email protected]>
| Newsgroups | gmane.linux.kernel.tracing |
|---|---|
| Message-ID | <[email protected]> |
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
signature.asc
(application/pgp-signature, 249 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iD8DBQFGRO8YniDOoMHTA+kRAtE6AJ9P24xv2AZqogXGBf3549iLIgkGAgCeImGh vK9Q/VvVa4YGw2c2yJRCOXw= =0jtT -----END PGP SIGNATURE-----