Re: [PATCH v7] perf: __kmod_path__parse: deal with kernel module names in '[]' correctly

From: Jiri Olsa
Date: Wed Jun 03 2015 - 04:47:40 EST


On Wed, Jun 03, 2015 at 07:49:23AM +0000, Wang Nan wrote:

SNIP

> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index b335db3..87f5796 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
> @@ -166,12 +166,28 @@ bool is_supported_compression(const char *ext)
> return false;
> }
>
> -bool is_kernel_module(const char *pathname)
> +bool is_kernel_module(const char *pathname, int cpumode)
> {
> struct kmod_path m;
> -
> - if (kmod_path__parse(&m, pathname))
> - return NULL;
> + int mode = cpumode & PERF_RECORD_MISC_CPUMODE_MASK;
> +
> + WARN_ONCE(mode != cpumode,
> + "Internal error: passing unmasked cpumode (%x) to is_kernel_module",
> + cpumode);
> + /* caller should pass a masked cpumode. Mask again for safety. */

no need for this comment then ^^^

jirka

> + switch (mode) {
> + case PERF_RECORD_MISC_USER:
> + case PERF_RECORD_MISC_HYPERVISOR:
> + case PERF_RECORD_MISC_GUEST_USER:
> + return false;
> + /* Treat PERF_RECORD_MISC_CPUMODE_UNKNOWN as kernel */
> + default:
> + if (kmod_path__parse(&m, pathname)) {
> + pr_err("Failed to check whether %s is a kernel module or not. Assume it is.",
> + pathname);
> + return true;
> + }
> + }

SNIP

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/