From patchwork Wed Apr 20 18:01:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 66238 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2595369qge; Wed, 20 Apr 2016 11:03:17 -0700 (PDT) X-Received: by 10.66.90.226 with SMTP id bz2mr14200490pab.31.1461175397808; Wed, 20 Apr 2016 11:03:17 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1si21358688pfa.151.2016.04.20.11.03.17; Wed, 20 Apr 2016 11:03:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752583AbcDTSCq (ORCPT + 29 others); 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 Received: from 172.24.1.137 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.137]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CAG94113; Thu, 21 Apr 2016 02:02:13 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.235.1; Thu, 21 Apr 2016 02:02:02 +0800 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 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 1.8.3.4 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