Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753336AbbKWLVo (ORCPT ); Mon, 23 Nov 2015 06:21:44 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:23573 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751675AbbKWLVn (ORCPT ); Mon, 23 Nov 2015 06:21:43 -0500 Message-ID: <5652F669.1010405@huawei.com> Date: Mon, 23 Nov 2015 19:20:09 +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 Subject: Re: [RFC PATCH 1/7] perf tools: Add API to config maps in bpf object References: <1445078910-73699-1-git-send-email-wangnan0@huawei.com> <1445078910-73699-2-git-send-email-wangnan0@huawei.com> In-Reply-To: <1445078910-73699-2-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.5652F67A.00FA,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 1ccd2f410a820047b08373debcb8894a Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3345 Lines: 107 On 2015/10/17 18:48, Wang Nan wrote: > bpf__config_obj() is introduced as a core API to config BPF object > after loading. One configuration option of maps is introduced. After > this patch BPF object can accept configuration like: > > maps.my_map.value=1234 > > This patch is more complex than the work it really does because the > consideration of extension. In designing of BPF map configuration, > following things should be considered: > > 1. Array indics selection: perf should allow user setting different > value to different slots in an array, with syntax like: > maps.my_map.value[0,3-6]=1234; > > 2. Type of value: integer is not the only valid value type. Perf > event can also be put into a map after commit 35578d7984003097af2b1e3 > (bpf: Implement function bpf_perf_event_read() that get the selected > hardware PMU conuter); > > 3. For hash table, it is possible to use string or other as key; > > 4. It is possible that map configuration is unable to be setup > during parsing. Perf event is an example. > > Therefore, this patch does tie following thing for extension: > > 1. Instead of update map element during parsing, this patch stores > map config options in 'struct bpf_map_priv'. Following patches > would apply those configs at proper time; Because of this delay-updating manner, current implementation forbid setting a map with different configuration. For example: # perf record -e test_bpf.c/maps:channel:value[0...9]=1,maps:channel:value[10...19]=2/ ... is equal to # perf record -e test_bpf.c/maps:channel:value[10...19]=2/ ... because [see follow] > 2. Make 'struct bpf_map_priv' extensible so following patches can > add new key and value operations; > > 3. Use bpf_config_map_funcs array to support more maps configuration. > > Signed-off-by: Wang Nan > Signed-off-by: He Kuang > Cc: Arnaldo Carvalho de Melo > Cc: Alexei Starovoitov > Cc: Brendan Gregg > Cc: Daniel Borkmann > Cc: David Ahern > Cc: He Kuang > Cc: Jiri Olsa > Cc: Kaixu Xia > Cc: Masami Hiramatsu > Cc: Namhyung Kim > Cc: Paul Mackerras > Cc: Peter Zijlstra > Cc: Zefan Li > Cc: pi3orama@163.com > Link: http://lkml.kernel.org/n/ebpf-36xcrahy9n0ayc05mu7aajpk@git.kernel.org > --- > [SNIP] > > +enum bpf_map_priv_key_type { > + BPF_MAP_PRIV_KEY_ALL, > +}; > + > +enum bpf_map_priv_value_type { > + BPF_MAP_PRIV_VAL_VALUE, > +}; > + > +struct bpf_map_priv { > + struct { > + enum bpf_map_priv_key_type type; > + } key; > + > + struct { > + enum bpf_map_priv_value_type type; > + union { > + u64 val; > + }; > + } value; > +}; > + ... because this structure holds only one config term. In next version I'd like to save multiple setting operations in this structure. Thank you. -- 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/