Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752582AbcDTSCq (ORCPT ); Wed, 20 Apr 2016 14:02:46 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:26299 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752443AbcDTSCj (ORCPT ); Wed, 20 Apr 2016 14:02:39 -0400 From: Wang Nan To: , , CC: , , Wang Nan , Arnaldo Carvalho de Melo , "Alexei Starovoitov" , Jiri Olsa , Li Zefan Subject: [RFC PATCH 03/13] bpf tools: Add ubpf include and makefile options Date: Wed, 20 Apr 2016 18:01:43 +0000 Message-ID: <1461175313-38310-4-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1461175313-38310-1-git-send-email-wangnan0@huawei.com> References: <1461175313-38310-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.5717C425.00DE,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: 4f4c1cf739929814a71ab76df76cbaf7 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2988 Lines: 103 Prepare to use libubpf. Add ubpf.h into libbpf.c. Add corresponding makefile options. Allow ignoring UBPF when building libbpf by setting NO_UBPF=1 for libbpf building. Allow perf controling ubpf using NO_UBPF=1. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Jiri Olsa Cc: Li Zefan --- tools/lib/bpf/Makefile | 16 ++++++++++++++-- tools/lib/bpf/libbpf.c | 3 +++ tools/perf/Makefile.perf | 2 ++ tools/perf/config/Makefile | 7 +++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index 8dfa512..6944d02 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -64,9 +64,17 @@ ifndef VERBOSE VERBOSE = 0 endif +ifndef NO_UBPF + FEATURE_UBPF := ubpf + CFLAGS_UBPF := -DHAVE_UBPF_SUPPORT +else + FEATURE_UBPF := + CFLAGS_UBPF := +endif + FEATURE_USER = .libbpf -FEATURE_TESTS = libelf libelf-getphdrnum libelf-mmap bpf ubpf -FEATURE_DISPLAY = libelf bpf ubpf +FEATURE_TESTS = libelf libelf-getphdrnum libelf-mmap bpf $(FEATURE_UBPF) +FEATURE_DISPLAY = libelf bpf $(FEATURE_UBPF) INCLUDES = -I. -I$(srctree)/tools/include -I$(srctree)/arch/$(ARCH)/include/uapi -I$(srctree)/include/uapi FEATURE_CHECK_CFLAGS-bpf = $(INCLUDES) @@ -120,6 +128,10 @@ ifeq ($(feature-libelf-getphdrnum), 1) override CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT endif +ifeq ($(feature-ubpf), 1) + override CFLAGS += $(CFLAGS_UBPF) +endif + # Append required CFLAGS override CFLAGS += $(EXTRA_WARNINGS) override CFLAGS += -Werror -Wall diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 7e543c3..55b739e 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -21,6 +21,9 @@ #include #include +#ifdef HAVE_UBPF_SUPPORT +# include +#endif #include "libbpf.h" #include "bpf.h" diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index bde8cba..5334e29 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -81,6 +81,8 @@ include ../scripts/utilities.mak # # Define NO_LIBBPF if you do not want BPF support # +# Define NO_UBPF if you do not want user space BPF support +# # Define FEATURES_DUMP to provide features detection dump file # and bypass the feature detection diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 1e46277..89d0470 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -315,6 +315,13 @@ ifndef NO_LIBELF ifeq ($(feature-bpf), 1) CFLAGS += -DHAVE_LIBBPF_SUPPORT $(call detected,CONFIG_LIBBPF) + ifndef NO_UBPF + ifeq ($(feature-ubpf), 1) + CFLAGS += -DHAVE_UBPF_SUPPORT + EXTLIBS += -lubpf + $(call detected,CONFIG_UBPF) + endif + endif endif ifndef NO_DWARF -- 1.8.3.4