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:	Fri, 27 Nov 2015 15:31:58 +0800
From:	"Wangnan (F)" <wangnan0@...wei.com>
To:	<acme@...nel.org>, <masami.hiramatsu.pt@...achi.com>,
	<ast@...nel.org>
CC:	<lizefan@...wei.com>, <pi3orama@....com>,
	<linux-kernel@...r.kernel.org>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Namhyung Kim <namhyung@...nel.org>
Subject: Re: [PATCH 12/16] perf tools: Support setting different slots in
 a BPF map separately



On 2015/11/24 21:36, Wang Nan wrote:
> This patch introduces basic facilities to support config different
> slots in a BPF map one by one.
>
> array.nr_ranges and array.ranges are introduced into 'struct
> parse_events_term', where ranges is an array of indices range (start,
> length) which will be configured by this config term. nr_ranges
> is the size of the array. The array is passed to 'struct bpf_map_priv'.
> To indicate the new type of configuration, BPF_MAP_KEY_RANGES is
> added as a new key type. bpf_map_config_foreach_key() is extended to
> iterate over those indices instead of all possible keys.
>
> Code in this commit will be enabled by following commit which enables
> the indices syntax for array configuration.
>
> Signed-off-by: Wang Nan <wangnan0@...wei.com>
> Cc: Alexei Starovoitov <ast@...nel.org>
> Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
> Cc: Namhyung Kim <namhyung@...nel.org>
> Cc: Zefan Li <lizefan@...wei.com>
> Cc: pi3orama@....com
> ---
>   tools/perf/util/bpf-loader.c   | 133 ++++++++++++++++++++++++++++++++++++++---
>   tools/perf/util/bpf-loader.h   |   1 +
>   tools/perf/util/parse-events.c |  33 +++++++++-
>   tools/perf/util/parse-events.h |  12 ++++
>   4 files changed, 171 insertions(+), 8 deletions(-)
>
> diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
> index a6e4bde..185d2cf 100644
> --- a/tools/perf/util/bpf-loader.c
> +++ b/tools/perf/util/bpf-loader.c

[SNIP]

> +static int
> +bpf_map_op_setkey(struct bpf_map_op *op, struct parse_events_term *term,
> +		  const char *map_name)
> +{
> +	op->key_type = BPF_MAP_KEY_ALL;
> +
> +	if (term->array.nr_ranges) {
> +		size_t memsz = term->array.nr_ranges *
> +				sizeof(op->k.array.ranges[0]);
> +
> +		op->k.array.ranges = malloc(memsz);
> +		if (!op->k.array.ranges) {
> +			pr_debug("No enough memory to alloc indices for %s\n",
> +				 map_name);
> +			return -ENOMEM;
> +		}
> +		memcpy(op->k.array.ranges, term->array.ranges, memsz);

Here can use memdup.

> +		op->key_type = BPF_MAP_KEY_RANGES;
> +		op->k.array.nr_ranges = term->array.nr_ranges;
> +	}
> +	return 0;
> +}
> +


--
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