From patchwork Tue Sep 1 06:59:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 52916 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 9DA2A2157D for ; Tue, 1 Sep 2015 07:01:02 +0000 (UTC) Received: by labd1 with SMTP id d1sf48795080lab.0 for ; Tue, 01 Sep 2015 00:01:01 -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=t9Dt3PZMxS7TnL/9WupBfzoXj0SDXM3Ctz/5cnafJyI=; b=MKGe38ucQPPZpC6qz/PxVVtC6nNaS2d1XpifaHHxxwhYIicuhPDPbg2UdL6vnsDViW jXqdOxqggaNKFwFVXNkoXyVW5IidaSPRJaR5VlbmQhBytSHr1sa68B8HWZ2lTJxrMPpO 9vxJ7y/NNQHX9YmJErUNx0bnk8qvshf2qtPg9aft+bCNmPjwNJzcPpORSSjr2OPEuEr1 z2etdlaMJbKz5es7qOTP671wv9ghein/jFSz5fjFppeBr1ItTn1u5tEoG/zZ42ac+EOc 1KpEB88+eY2VikPnxsJmc0ZeviCzRU+WJA3Xww8GIiUeGAh6jeaySnckbsEFEgp9LB17 CDtA== X-Gm-Message-State: ALoCoQmUYszGUcnMdqroJ2ci3mcN5qVg/X9Kgauh+I8IjzLPJ/Pz2JEIplnGStfxMMhyroft9Yry X-Received: by 10.112.167.201 with SMTP id zq9mr7288859lbb.2.1441090861454; Tue, 01 Sep 2015 00:01:01 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.229 with SMTP id z5ls566032lal.8.gmail; Tue, 01 Sep 2015 00:01:01 -0700 (PDT) X-Received: by 10.112.125.194 with SMTP id ms2mr12610332lbb.58.1441090861165; Tue, 01 Sep 2015 00:01:01 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id p5si15568991laj.140.2015.09.01.00.01.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2015 00:01:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbbsx3 with SMTP id sx3so73322782lbb.0 for ; Tue, 01 Sep 2015 00:01:01 -0700 (PDT) X-Received: by 10.112.77.10 with SMTP id o10mr12421314lbw.73.1441090860903; Tue, 01 Sep 2015 00:01:00 -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 yn10csp322991lbb; Tue, 1 Sep 2015 00:00:59 -0700 (PDT) X-Received: by 10.66.243.70 with SMTP id ww6mr44808697pac.88.1441090859744; Tue, 01 Sep 2015 00:00:59 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rt13si28249201pab.132.2015.09.01.00.00.58; Tue, 01 Sep 2015 00:00:59 -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 S1754362AbbIAHAz (ORCPT + 28 others); Tue, 1 Sep 2015 03:00:55 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:34057 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751546AbbIAHAx (ORCPT ); Tue, 1 Sep 2015 03:00:53 -0400 Received: from 172.24.1.48 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.48]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CUD41982; Tue, 01 Sep 2015 15:00:06 +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; Tue, 1 Sep 2015 14:59:55 +0800 From: Wang Nan To: CC: , Wang Nan , "Alexei Starovoitov" , Brendan Gregg , Daniel Borkmann , David Ahern , "He Kuang" , Jiri Olsa , Kaixu Xia , Masami Hiramatsu , Namhyung Kim , Paul Mackerras , Peter Zijlstra , Zefan Li , , Arnaldo Carvalho de Melo Subject: [PATCH 22/31] perf tools: Add BPF_PROLOGUE config options for further patches Date: Tue, 1 Sep 2015 06:59:48 +0000 Message-ID: <1441090789-108382-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1440822125-52691-23-git-send-email-wangnan0@huawei.com> References: <1440822125-52691-23-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected 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.182 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/1436445342-1402-33-git-send-email-wangnan0@huawei.com [wawngnan: - Introduce new CFLAGS to control BPF prologue and arch_get_reg_info() separately. - Rename ARCH_GET_REG_INFO to ARCH_REGS_QUERY_REGISTER_OFFSET, arch_get_reg_info() to regs_query_register_offset(), change its API accordingly to make it similar to kernel's regs_query_register_offset(). ] --- 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..33785a1 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 +ifneq ($(origin PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET), undefined) + 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 + ifneq ($(origin PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET), undefined) + 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