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]
Date:	Mon, 11 May 2015 15:28:12 +0900
From:	Namhyung Kim <namhyung@...nel.org>
To:	Wang Nan <wangnan0@...wei.com>
Cc:	ast@...mgrid.com, davem@...emloft.net, acme@...nel.org,
	mingo@...hat.com, a.p.zijlstra@...llo.nl,
	masami.hiramatsu.pt@...achi.com, jolsa@...nel.org,
	lizefan@...nel.org, linux-kernel@...r.kernel.org, pi3orama@....com,
	hekuang@...wei.com
Subject: Re: [RFC PATCH 04/22] perf tools: Add new 'perf bpf' command.

Hi,

On Thu, Apr 30, 2015 at 10:52:27AM +0000, Wang Nan wrote:
> Adding new 'perf bpf' command to provide eBPF program loading and
> management support.
> 
> Signed-off-by: Wang Nan <wangnan0@...wei.com>
> ---
>  tools/perf/Build                      |  1 +
>  tools/perf/Documentation/perf-bpf.txt | 18 ++++++++++
>  tools/perf/builtin-bpf.c              | 63 +++++++++++++++++++++++++++++++++++
>  tools/perf/builtin.h                  |  1 +
>  tools/perf/perf.c                     |  1 +
>  tools/perf/util/Build                 |  1 +
>  tools/perf/util/bpf-loader.c          | 35 +++++++++++++++++++
>  tools/perf/util/bpf-loader.h          | 21 ++++++++++++
>  8 files changed, 141 insertions(+)
>  create mode 100644 tools/perf/Documentation/perf-bpf.txt
>  create mode 100644 tools/perf/builtin-bpf.c
>  create mode 100644 tools/perf/util/bpf-loader.c
>  create mode 100644 tools/perf/util/bpf-loader.h
> 
> diff --git a/tools/perf/Build b/tools/perf/Build
> index b77370e..c69f0c1 100644
> --- a/tools/perf/Build
> +++ b/tools/perf/Build
> @@ -19,6 +19,7 @@ perf-y += builtin-kvm.o
>  perf-y += builtin-inject.o
>  perf-y += builtin-mem.o
>  perf-y += builtin-data.o
> +perf-y += builtin-bpf.o
>  
>  perf-$(CONFIG_AUDIT) += builtin-trace.o
>  perf-$(CONFIG_LIBELF) += builtin-probe.o
> diff --git a/tools/perf/Documentation/perf-bpf.txt b/tools/perf/Documentation/perf-bpf.txt
> new file mode 100644
> index 0000000..634d588
> --- /dev/null
> +++ b/tools/perf/Documentation/perf-bpf.txt
> @@ -0,0 +1,18 @@
> +perf-bpf(1)
> +==============
> +
> +NAME
> +----
> +perf-bpf - loads eBPF programs into kernel.
> +
> +SYNOPSIS
> +--------
> +[verse]
> +'perf bpf' [<common options>] <bpfprogram.o>",
> +
> +DESCRIPTION
> +-----------
> +Loading eBPF programs into kernel.
> +
> +OPTIONS
> +-------
> diff --git a/tools/perf/builtin-bpf.c b/tools/perf/builtin-bpf.c
> new file mode 100644
> index 0000000..0fc7a82
> --- /dev/null
> +++ b/tools/perf/builtin-bpf.c
> @@ -0,0 +1,63 @@
> +/*
> + * buildin-bpf.c

s/buildin/builtn/

> + *
> + * Buildin bpf command: Load bpf and attach bpf programs onto kprobes.

ditto.

> + */
> +#include "builtin.h"
> +#include "perf.h"
> +#include "debug.h"
> +#include "parse-options.h"
> +#include "bpf-loader.h"
> +
> +static const char *bpf_usage[] = {
> +	"perf bpf [<options>] <bpfobj>",
> +	NULL
> +};
> +
> +static void print_usage(void)
> +{
> +	printf("Usage:\n");
> +	printf("\t%s\n\n", bpf_usage[0]);
> +}

Why not using usage_with_options() for this?

Thanks,
Namhyung


> +
> +struct option __bpf_options[] = {
> +	OPT_INCR('v', "verbose", &verbose, "be more verbose"),
> +	OPT_END()
> +};
> +
> +struct option *bpf_options = __bpf_options;
> +
> +int cmd_bpf(int argc, const char **argv,
> +	    const char *prefix __maybe_unused)
> +{
> +	int err;
> +	const char **pfn;
> +
> +	if (argc < 2)
> +		goto usage;
> +
> +	argc = parse_options(argc, argv, bpf_options, bpf_usage,
> +			    PARSE_OPT_STOP_AT_NON_OPTION);
> +	if (argc < 1)
> +		goto usage;
> +
> +	pfn = argv;
> +	while (*pfn != NULL) {
> +		const char *fn = *pfn++;
> +
> +		err = bpf__load(fn);
> +		if (err) {
> +			pr_err("bpf: load bpf program from %s: result: %d\n",
> +					fn, err);
> +			break;
> +		}
> +	}
> +
> +	if (!err)
> +		bpf__run();
> +	return err;
> +usage:
> +	print_usage();
> +	return -1;
> +}
> +
--
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