public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Wangnan (F)" <wangnan0@huawei.com>
To: <acme@kernel.org>, <masami.hiramatsu.pt@hitachi.com>, <ast@kernel.org>
Cc: <lizefan@huawei.com>, <pi3orama@163.com>,
	<linux-kernel@vger.kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>
Subject: Re: [PATCH 12/16] perf tools: Support setting different slots in a BPF map separately
Date: Fri, 27 Nov 2015 15:31:58 +0800	[thread overview]
Message-ID: <565806EE.8030105@huawei.com> (raw)
In-Reply-To: <1448372181-151723-13-git-send-email-wangnan0@huawei.com>



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@huawei.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Zefan Li <lizefan@huawei.com>
> Cc: pi3orama@163.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;
> +}
> +



  reply	other threads:[~2015-11-27  7:32 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-24 13:36 [PATCH 00/16] perf tools: BPF related update Wang Nan
2015-11-24 13:36 ` [PATCH 01/16] tools build: Clean CFLAGS and LDFLAGS for fixdep Wang Nan
2015-11-26  8:21   ` [tip:perf/core] " tip-bot for Wang Nan
2015-11-24 13:36 ` [PATCH 02/16] tools lib bpf: Don't feature check when cleaning Wang Nan
2015-11-26  8:22   ` [tip:perf/core] tools lib bpf: Don' t do a " tip-bot for Wang Nan
2015-11-24 13:36 ` [PATCH 03/16] bpf tools: Add helper function for updating bpf maps elements Wang Nan
2015-11-27  7:47   ` [tip:perf/core] " tip-bot for He Kuang
2015-11-24 13:36 ` [PATCH 04/16] bpf tools: Collect map definition in bpf_object Wang Nan
2015-11-26 20:56   ` Arnaldo Carvalho de Melo
2015-11-27  6:16     ` Wangnan (F)
2015-11-27  6:21       ` Wangnan (F)
2015-11-24 13:36 ` [PATCH 05/16] bpf tools: Extract and collect map names from BPF object file Wang Nan
2015-11-24 13:36 ` [PATCH 06/16] perf tools: Rename bpf config to program config Wang Nan
2015-11-24 13:36 ` [PATCH 07/16] perf tools: Add API to config maps in bpf object Wang Nan
2015-11-27  7:32   ` Wangnan (F)
2015-11-24 13:36 ` [PATCH 08/16] perf tools: Enable BPF object configure syntax Wang Nan
2015-11-24 13:36 ` [PATCH 09/16] perf record: Apply config to BPF objects before recording Wang Nan
2015-11-24 13:36 ` [PATCH 10/16] perf tools: Support perf event alias name Wang Nan
2015-11-24 13:36 ` [PATCH 11/16] perf tools: Enable passing event to BPF object Wang Nan
2015-11-24 13:36 ` [PATCH 12/16] perf tools: Support setting different slots in a BPF map separately Wang Nan
2015-11-27  7:31   ` Wangnan (F) [this message]
2015-11-24 13:36 ` [PATCH 13/16] perf tools: Enable indices setting syntax for BPF maps Wang Nan
2015-11-24 13:36 ` [PATCH 14/16] perf tools: Introduce bpf-output event Wang Nan
2015-11-24 13:36 ` [PATCH 15/16] perf data: Add u32_hex data type Wang Nan
2015-11-24 13:36 ` [PATCH 16/16] perf data: Support converting data from bpf_perf_event_output() Wang Nan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=565806EE.8030105@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=ast@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=namhyung@kernel.org \
    --cc=pi3orama@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox