From patchwork Sun Sep 6 07:13:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 53184 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 4FB1422B05 for ; Sun, 6 Sep 2015 07:18:46 +0000 (UTC) Received: by wisv5 with SMTP id v5sf17647822wis.0 for ; Sun, 06 Sep 2015 00:18:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=HDM5wuV0nFIvhpvrA+4FZf4eeAVh/GegRHlI3T5XMyg=; b=QE1j0o+vPeQlsZ4Mvq6HUIHmc9Iq/ppwepmNrYWzRfhB0VaTPRsiblB2VepTHAghSh 1C+AvN7KwUdaCPHqnq70eBKc2yGNiFF8sW8TTe3yD+4VZdjUHdwVgQgE1397xofRJbfl f4HpMJeFD332u82joh5Y/OamnWzpba2QM4/qKr6ScU/jJo5WCeCmxlV/U42/xF/+m6Y5 a5w2i3U/Ru4UbJD2apR6VIDvewZL78EE2XUhpZXxAcbVpjx/ySaE7seIPvj/GOBoIMQ7 4wk29a4YFcxUkdpADmMTndr7u9eXlMoj8FqoeCHPufekogAnVRSLq9kSQ0SDDYMWVFMn S2WA== X-Gm-Message-State: ALoCoQlv1N2eVsqrjXoj30SlahAuo0zoN8OGIhL9d71h79FRIsA762A9FjDpg9Due1ipbV67cN3R X-Received: by 10.152.1.164 with SMTP id 4mr3344921lan.2.1441523925596; Sun, 06 Sep 2015 00:18:45 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.225 with SMTP id e1ls91937laa.108.gmail; Sun, 06 Sep 2015 00:18:45 -0700 (PDT) X-Received: by 10.152.6.41 with SMTP id x9mr10551645lax.120.1441523925424; Sun, 06 Sep 2015 00:18:45 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id o9si3973349laf.80.2015.09.06.00.18.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Sep 2015 00:18:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbcjc2 with SMTP id jc2so26945482lbc.0 for ; Sun, 06 Sep 2015 00:18:45 -0700 (PDT) X-Received: by 10.152.18.133 with SMTP id w5mr1437312lad.72.1441523925300; Sun, 06 Sep 2015 00:18:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.164.42 with SMTP id yn10csp844605lbb; Sun, 6 Sep 2015 00:18:44 -0700 (PDT) X-Received: by 10.66.148.136 with SMTP id ts8mr31049143pab.15.1441523924144; Sun, 06 Sep 2015 00:18:44 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a10si13807673pat.46.2015.09.06.00.18.43; Sun, 06 Sep 2015 00:18:44 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753052AbbIFHSf (ORCPT + 28 others); Sun, 6 Sep 2015 03:18:35 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:54481 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751516AbbIFHOq (ORCPT ); Sun, 6 Sep 2015 03:14:46 -0400 Received: from 172.24.1.49 (EHLO SZXEML423-HUB.china.huawei.com) ([172.24.1.49]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BMJ96284; Sun, 06 Sep 2015 15:14:21 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by SZXEML423-HUB.china.huawei.com (10.82.67.154) with Microsoft SMTP Server id 14.3.235.1; Sun, 6 Sep 2015 15:14:11 +0800 From: Wang Nan To: , , , CC: , , , , , , , , , , , Subject: [PATCH 18/27] perf tools: Add BPF_PROLOGUE config options for further patches Date: Sun, 6 Sep 2015 07:13:34 +0000 Message-ID: <1441523623-152703-19-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1441523623-152703-1-git-send-email-wangnan0@huawei.com> References: <1441523623-152703-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.0A090202.55EBE7CF.0073, 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: bdc88fbd9c5d819f6aacb817f3767fdd Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: wangnan0@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , If both LIBBPF and DWARF are detected, it is possible to create prologue for eBPF programs to help them accessing kernel data. HAVE_BPF_PROLOGUE and CONFIG_BPF_PROLOGUE is added as flags for this feature. PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET indicates an architecture supports converting name of a register to its offset in 'struct pt_regs'. Without this support, BPF_PROLOGUE should be turned off. HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET is introduced as the corresponding CFLAGS of PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Zefan Li Cc: pi3orama@163.com Cc: Arnaldo Carvalho de Melo Link: http://lkml.kernel.org/n/1441090789-108382-2-git-send-email-wangnan0@huawei.com [wangnan: - Simplify Makefile based on Namhyung Kim's suggestion. ] --- tools/perf/config/Makefile | 17 +++++++++++++++++ tools/perf/util/include/dwarf-regs.h | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 38a4144..25c9ffc 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -110,6 +110,11 @@ FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/arch/$(AR # include ARCH specific config -include $(src-perf)/arch/$(ARCH)/Makefile +ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET + CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET +endif + + include $(src-perf)/config/utilities.mak ifeq ($(call get-executable,$(FLEX)),) @@ -314,6 +319,18 @@ ifndef NO_LIBELF CFLAGS += -DHAVE_LIBBPF_SUPPORT $(call detected,CONFIG_LIBBPF) endif + + ifndef NO_DWARF + ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET + CFLAGS += -DHAVE_BPF_PROLOGUE + $(call detected,CONFIG_BPF_PROLOGUE) + else + msg := $(warning BPF prologue is not supported by architecture $(ARCH), missing regs_query_register_offset()); + endif + else + msg := $(warning DWARF support is off, BPF prologue is disabled); + endif + endif # NO_LIBBPF endif # NO_LIBELF diff --git a/tools/perf/util/include/dwarf-regs.h b/tools/perf/util/include/dwarf-regs.h index 8f14965..07c644e 100644 --- a/tools/perf/util/include/dwarf-regs.h +++ b/tools/perf/util/include/dwarf-regs.h @@ -5,4 +5,12 @@ const char *get_arch_regstr(unsigned int n); #endif +#ifdef HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET +/* + * Arch should support fetching the offset of a register in pt_regs + * by its name. See kernel's regs_query_register_offset in + * arch/xxx/kernel/ptrace.c. + */ +int regs_query_register_offset(const char *name); +#endif #endif