From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751567AbbE2EAN (ORCPT ); Fri, 29 May 2015 00:00:13 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:23009 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750701AbbE2EAH (ORCPT ); Fri, 29 May 2015 00:00:07 -0400 Message-ID: <5567E416.2080206@huawei.com> Date: Fri, 29 May 2015 11:59:18 +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: Alexei Starovoitov CC: , , , , , , , , , , , , , xiakaixu 00238161 Subject: Re: [RFC PATCH v4 10/29] bpf tools: Collect map definitions from 'maps' section References: <1432704004-171454-1-git-send-email-wangnan0@huawei.com> <1432704004-171454-11-git-send-email-wangnan0@huawei.com> <20150528015307.GE20764@Alexeis-MacBook-Pro.local> <55667758.1070206@huawei.com> <20150528022833.GI20764@Alexeis-MacBook-Pro.local> <556686FE.105@huawei.com> <20150528060957.GA21013@Alexeis-MBP.westell.com> <5566C064.6020205@huawei.com> <20150529033518.GA21616@Alexeis-MacBook-Pro.local> In-Reply-To: <20150529033518.GA21616@Alexeis-MacBook-Pro.local> 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.0A020202.5567E437.0032,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: 1aac5719b4388bb3219182ed03b94a75 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2015/5/29 11:35, Alexei Starovoitov wrote: > On Thu, May 28, 2015 at 03:14:44PM +0800, Wangnan (F) wrote: >> >> On 2015/5/28 14:09, Alexei Starovoitov wrote: >>> On Thu, May 28, 2015 at 11:09:50AM +0800, Wangnan (F) wrote: >>>> However this breaks a law in current design that opening phase doesn't >>>> talk to kernel with sys_bpf() at all. All related staff is done in loading >>>> phase. This principle ensures that in every systems, no matter it support >>>> sys_bpf() or not, can read eBPF object without failure. >>> I see, so you want 'parse elf' and 'create maps + load programs' >>> to be separate phases? >>> Fair enough. Then please add a call to release the information >>> collected from elf after program loading is done. >>> relocations and other things are not needed at that point. >> What about appending a flag into bpf_object__load() to let it know >> whether to cleanup resource it taken or not? for example: >> >> int bpf_object__load(struct bpf_object *obj, bool clean); >> >> then we can further wrap it by a macro: >> >> #define bpf_object__load_clean(o) bpf_object__load(o, true) >> >> If 'clear' is true, after loading resources will be freed, and the same >> object will be unable to reload again after unload. B doing this we can >> avoid adding a new function. > imo that would be an ugly API. You only want to do that to have > one less library API function? I think it's cleaner to let user of > the library call it when necessary. > Or do cleaning unconditionally. I don't see a use case when the > same set of maps and programs would need to be loaded twice into the kernel. OK. Let bpf_object__load() clean resources unconditionally. Thank you.