Messages in this thread | | | Date | Fri, 29 May 2015 11:59:18 +0800 | From | "Wangnan (F)" <> | Subject | Re: [RFC PATCH v4 10/29] bpf tools: Collect map definitions from 'maps' section |
| |
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.
| |