Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932775AbbERUej (ORCPT ); Mon, 18 May 2015 16:34:39 -0400 Received: from mail.kernel.org ([198.145.29.136]:35013 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932494AbbERUef (ORCPT ); Mon, 18 May 2015 16:34:35 -0400 Date: Mon, 18 May 2015 17:34:31 -0300 From: Arnaldo Carvalho de Melo To: Alexei Starovoitov Cc: Wang Nan , paulus@samba.org, a.p.zijlstra@chello.nl, mingo@redhat.com, namhyung@kernel.org, jolsa@kernel.org, dsahern@gmail.com, daniel@iogearbox.net, brendan.d.gregg@gmail.com, masami.hiramatsu.pt@hitachi.com, lizefan@huawei.com, linux-kernel@vger.kernel.org, pi3orama@163.com Subject: Re: [RFC PATCH v3 12/37] bpf tools: Collect version and license from ELF sections Message-ID: <20150518203431.GF18563@kernel.org> References: <1431860222-61636-1-git-send-email-wangnan0@huawei.com> <1431860222-61636-13-git-send-email-wangnan0@huawei.com> <555A2F05.207@plumgrid.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <555A2F05.207@plumgrid.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2362 Lines: 66 Em Mon, May 18, 2015 at 11:27:17AM -0700, Alexei Starovoitov escreveu: > On 5/17/15 3:56 AM, Wang Nan wrote: > >Expand bpf_obj_elf_collect() to collect license and kernel version > >information in eBPF object file. eBPF object file should have a section > >named 'license', which contains a string. It should also have a section > >named 'version', contains a u32 LINUX_VERSION_CODE. > > > >bpf_obj_validate() is introduced to validate object file after loaded. > >Currently it only check existance of 'version' section. > > > >Signed-off-by: Wang Nan > ... > >+#ifdef min > >+# undef min > >+#endif > >+#define min(x, y) ({ \ > >+ typeof(x) _min1 = (x); \ > >+ typeof(y) _min2 = (y); \ > >+ (void) (&_min1 == &_min2); \ > >+ _min1 < _min2 ? _min1 : _min2; }) > >+ > > copy-paste from lib traceevent? > there is another container_of copy-paste later in the patches. > please use something like tools/lib/bpf/utils.h file for such > things, so we can consolidate and share this code later. Better, ask what the kernel does, find out where it does and replicate that in tools/include/, i.e. a min function?!? This looks like useful stuff! ;-) So, the kernel has this one, in include/linux/kernel.h: /* * min()/max()/clamp() macros that also do * strict type-checking.. See the * "unnecessary" pointer comparison. */ #define min(x, y) ({ \ typeof(x) _min1 = (x); \ typeof(y) _min2 = (y); \ (void) (&_min1 == &_min2); \ _min1 < _min2 ? _min1 : _min2; }) Looks a lot like that one above, no? :-) So, lets take a look at: tools/include/linux/kernel.h... bummer, that one wasn't yet moved from tools/perf/util/include/linux/kernel.h there. Will do, and then it has this: #ifndef min #define min(x, y) ({ \ typeof(x) _min1 = (x); \ typeof(y) _min2 = (y); \ (void) (&_min1 == &_min2); \ _min1 < _min2 ? _min1 : _min2; }) #endif We should minimize this mess :-) - Arnaldo -- 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/