From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751212AbdAYCTd (ORCPT ); Tue, 24 Jan 2017 21:19:33 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:64110 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751113AbdAYCTb (ORCPT ); Tue, 24 Jan 2017 21:19:31 -0500 Subject: Re: [PATCHv2 perf/core 5/7] tools lib bpf: Add bpf_program__pin() To: Joe Stringer References: <20170123011128.26534-1-joe@ovn.org> <20170123011128.26534-6-joe@ovn.org> <921d83a9-aa44-acee-4fcf-dbc45cc0a66a@huawei.com> CC: Arnaldo Carvalho de Melo , , Daniel Borkmann , LKML , netdev From: "Wangnan (F)" Message-ID: Date: Wed, 25 Jan 2017 10:18:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.194.139] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.58880B12.0237,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: ed55e10fe495adb0eb75dc835ad2125c Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/1/25 9:16, Joe Stringer wrote: > On 24 January 2017 at 17:06, Wangnan (F) wrote: >> >> On 2017/1/25 9:04, Wangnan (F) wrote: >>> >>> >>> On 2017/1/23 9:11, Joe Stringer wrote: >>>> Add a new API to pin a BPF program to the filesystem. The user can >>>> specify the path full path within a BPF filesystem to pin the program. >>>> Programs with multiple instances are pinned as 'foo', 'foo_1', 'foo_2', >>>> and so on. >>>> >>>> Signed-off-by: Joe Stringer >>>> --- >>>> v2: Don't automount BPF filesystem >>>> Split program, map, object pinning into separate APIs and separate >>>> patches. >>>> --- >> >> [SNIP] >> >>>> +int bpf_program__pin(struct bpf_program *prog, const char *path) >>> >>> In your next patch please let caller select one instance: >>> >>> int bpf_program__pin(struct bpf_program *prog, int instance, const char >>> *path) >>> (please choose a better name) >>> >>> Then your can wrap it with another function to pin all instances, >>> implement >>> naming schema (%s_%d) there. >>> >>> Then implement naming schema in bpf_object__pin like: >>> >>> %s/objectname_mapname >>> %s/objectname_progname_%d >>> >> Is it possible to use directory tree instead? >> >> %s/object/mapname >> %s/object/prog/instance > I don't think objects have names, so let's assume an object with two > program instances named foo, and one map named bar. > > A call of bpf_object__pin(obj, "/sys/fs/bpf/myobj") would mount with > the following files and directories: > /sys/fs/bpf/myobj/foo/1 > /sys/fs/bpf/myobj/foo/2 > /sys/fs/bpf/myobj/bar > > Alternatively, if you want to control exactly where you want the > progs/maps to be pinned, you can call eg > bpf_program__pin_instance(prog, "/sys/fs/bpf/wherever", 0) and that > instance will be mounted to /sys/fs/bpf/wherever, or alternatively > bpf_program__pin(prog, "/sys/fs/bpf/foo"), and you will end up with > /sys/fs/bpf/foo/{0,1}. > > This looks pretty reasonable to me. It looks good to me. Thank you.