lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150504161539.GG10475@kernel.org>
Date:	Mon, 4 May 2015 13:15:39 -0300
From:	Arnaldo Carvalho de Melo <acme@...nel.org>
To:	Namhyung Kim <namhyung@...nel.org>
Cc:	Ingo Molnar <mingo@...nel.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Jiri Olsa <jolsa@...hat.com>,
	LKML <linux-kernel@...r.kernel.org>,
	David Ahern <dsahern@...il.com>,
	Joonsoo Kim <js1304@...il.com>,
	Minchan Kim <minchan@...nel.org>,
	Pekka Enberg <penberg@...nel.org>, linux-mm@...ck.org
Subject: Re: [PATCH 6/6] perf kmem: Show warning when trying to run stat
 without record

Em Tue, Apr 21, 2015 at 01:55:07PM +0900, Namhyung Kim escreveu:
> Sometimes one can mistakenly run perf kmem stat without perf kmem
> record before or different configuration like recoding --slab and stat
> --page.  Show a warning message like below to inform user:
> 
>   # perf kmem stat --page --caller
>   Not found page events.  Have you run 'perf kmem record --page' before?
> 
> Acked-by: Pekka Enberg <penberg@...nel.org>
> Signed-off-by: Namhyung Kim <namhyung@...nel.org>
> ---
>  tools/perf/builtin-kmem.c | 31 ++++++++++++++++++++++++++++---
>  1 file changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
> index 828b7284e547..f29a766f18f8 100644
> --- a/tools/perf/builtin-kmem.c
> +++ b/tools/perf/builtin-kmem.c
> @@ -1882,6 +1882,7 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
>  	};
>  	struct perf_session *session;
>  	int ret = -1;
> +	const char errmsg[] = "Not found %s events.  Have you run 'perf kmem record --%s' before?\n";
>  
>  	perf_config(kmem_config, NULL);
>  	argc = parse_options_subcommand(argc, argv, kmem_options,
> @@ -1908,11 +1909,35 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
>  	if (session == NULL)
>  		return -1;
>  
> +	if (kmem_slab) {
> +		struct perf_evsel *evsel;
> +		bool found = false;
> +
> +		evlist__for_each(session->evlist, evsel) {
> +			if (!strcmp(perf_evsel__name(evsel), "kmem:kmalloc")) {
> +				found = true;
> +				break;
> +			}
> +		}

We have:

struct perf_evsel *
perf_evlist__find_tracepoint_by_name(struct perf_evlist *evlist,
                                     const char *name);

Example of it being used in 'perf trace':

        evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
                                                     "raw_syscalls:sys_enter");
        /* older kernels have syscalls tp versus raw_syscalls */
        if (evsel == NULL)
                evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
                                                             "syscalls:sys_enter");


Applied 1-5, can you please resubmit this one with this change?

- Arnaldo

> +		if (!found) {
> +			pr_err(errmsg, "slab", "slab");
> +			return -1;
> +		}
> +	}
> +
>  	if (kmem_page) {
> -		struct perf_evsel *evsel = perf_evlist__first(session->evlist);
> +		struct perf_evsel *evsel;
> +		bool found = false;
>  
> -		if (evsel == NULL || evsel->tp_format == NULL) {
> -			pr_err("invalid event found.. aborting\n");
> +		evlist__for_each(session->evlist, evsel) {
> +			if (!strcmp(perf_evsel__name(evsel),
> +				    "kmem:mm_page_alloc")) {
> +				found = true;
> +				break;
> +			}
> +		}
> +		if (!found) {
> +			pr_err(errmsg, "page", "page");
>  			return -1;
>  		}
>  
> -- 
> 2.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ