Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753886AbbK0Hcd (ORCPT ); Fri, 27 Nov 2015 02:32:33 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:59745 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751278AbbK0Hcb (ORCPT ); Fri, 27 Nov 2015 02:32:31 -0500 Message-ID: <565806EE.8030105@huawei.com> Date: Fri, 27 Nov 2015 15:31:58 +0800 From: "Wangnan (F)" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: , , CC: , , , Arnaldo Carvalho de Melo , Namhyung Kim Subject: Re: [PATCH 12/16] perf tools: Support setting different slots in a BPF map separately References: <1448372181-151723-1-git-send-email-wangnan0@huawei.com> <1448372181-151723-13-git-send-email-wangnan0@huawei.com> In-Reply-To: <1448372181-151723-13-git-send-email-wangnan0@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.565806FB.0091,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 89180fea6421259a1a62bed2491fcbc2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2426 Lines: 71 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 > Cc: Alexei Starovoitov > Cc: Arnaldo Carvalho de Melo > Cc: Masami Hiramatsu > Cc: Namhyung Kim > Cc: Zefan Li > 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; > +} > + -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/