From patchwork Mon Jul 7 13:45:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Pihet X-Patchwork-Id: 33160 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E0FC320969 for ; Mon, 7 Jul 2014 13:45:47 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id eu11sf32762815pac.10 for ; Mon, 07 Jul 2014 06:45:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=TVDpdK/iEnGASMaE86i8r9e3HJ+09VN+p/pI49Ne1MQ=; b=gUslvCVEq0EsUSjyeYUBzSaSvQ9y2JZZoKxS4sYUuVjHhTYK0pqJ3v86aWW5x0+vRm iQ8t38kEEFTehyR8WXUVG5Vsw9ebeyNkUzhru4P3uwM0armc9UAKeTNSPSdSc2UFbwTt D4bWbUQPt3m73uxKcOJyEoVWmubYbRhAG5WviQNgHEaveBePuGCodrxwMZ+L8r+abLYQ BnHkQvUeimUL6LS5u6kFmjgaKPwloxY7/yZgqGNWZ2UBKYvumLHWFTqjNP3A6c/luUkW DKE9HS6wWj8HmvaWtDgEA/UuDWpNryJBmCKmV/N/BlSEngNFP6+T04pq0hfhLEaA+jub PeBA== X-Gm-Message-State: ALoCoQkFNrLSqGywV5WfFMFSkbp2AUm10AEIVPyB8LcKaTmoSRo6PYxgM/YA4c8nmdMSv5XhXbtG X-Received: by 10.68.195.9 with SMTP id ia9mr14000625pbc.7.1404740747101; Mon, 07 Jul 2014 06:45:47 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.81.169 with SMTP id f38ls1298737qgd.24.gmail; Mon, 07 Jul 2014 06:45:47 -0700 (PDT) X-Received: by 10.58.37.106 with SMTP id x10mr27964565vej.2.1404740746983; Mon, 07 Jul 2014 06:45:46 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id y17si18769106vdg.107.2014.07.07.06.45.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Jul 2014 06:45:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.169 as permitted sender) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id pa12so4057284veb.14 for ; Mon, 07 Jul 2014 06:45:46 -0700 (PDT) X-Received: by 10.221.26.10 with SMTP id rk10mr27979288vcb.0.1404740746901; Mon, 07 Jul 2014 06:45:46 -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.221.37.5 with SMTP id tc5csp668209vcb; Mon, 7 Jul 2014 06:45:46 -0700 (PDT) X-Received: by 10.70.34.39 with SMTP id w7mr28518777pdi.19.1404740745702; Mon, 07 Jul 2014 06:45:45 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bw16si4874688pdb.227.2014.07.07.06.45.45; Mon, 07 Jul 2014 06:45:45 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753610AbaGGNpj (ORCPT + 27 others); Mon, 7 Jul 2014 09:45:39 -0400 Received: from mail-wg0-f51.google.com ([74.125.82.51]:40296 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753276AbaGGNpe (ORCPT ); Mon, 7 Jul 2014 09:45:34 -0400 Received: by mail-wg0-f51.google.com with SMTP id x12so4362493wgg.34 for ; Mon, 07 Jul 2014 06:45:33 -0700 (PDT) X-Received: by 10.194.82.198 with SMTP id k6mr32906889wjy.10.1404740733411; Mon, 07 Jul 2014 06:45:33 -0700 (PDT) Received: from rachael.linaro.local ([213.122.173.130]) by mx.google.com with ESMTPSA id e18sm26653901wic.0.2014.07.07.06.45.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jul 2014 06:45:32 -0700 (PDT) From: Jean Pihet To: linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Will Deacon Cc: Jiri Olsa , Ingo Molnar , Arnaldo Carvalho de Melo , steve.capper@linaro.org, Jean Pihet Subject: [PATCH 3/3] ARM: perf: allow tracing with kernel tracepoints events Date: Mon, 7 Jul 2014 15:45:10 +0200 Message-Id: <1404740710-14691-4-git-send-email-jean.pihet@linaro.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1404740710-14691-1-git-send-email-jean.pihet@linaro.org> References: <1404740710-14691-1-git-send-email-jean.pihet@linaro.org> 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: jean.pihet@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.169 as permitted sender) smtp.mail=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: , When tracing with tracepoints events the IP and CPSR are set to 0, preventing the perf code to resolve the symbols: ./perf record -e kmem:kmalloc cal [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.007 MB perf.data (~321 samples) ] ./perf report Overhead Command Shared Object Symbol ........ ....... ............. ........... 40.78% cal [unknown] [.]00000000 31.6% cal [unknown] [.]00000000 The examination of the gathered samples (perf report -D) shows the IP is set to 0 and that the samples are considered as user space samples, while the IP should be set from the registers and the samples should be considered as kernel samples. The fix is to implement perf_arch_fetch_caller_regs for ARM, which fills the necessary registers used for the callchain unwinding and to determine the user/kernel space property of the samples: - program counter for PERF_SAMPLE_IP, as used by dwarf unwinding, - sp & fp for fp based callchain unwinding, - cpsr for user_mode() tests. Tested with perf record and tracepoints triggering (-e ), with unwinding using fp (--call-graph fp) and dwarf info (--call-graph dwarf). Reported by Sneha Priya on linaro-dev, cf. http://lists.linaro.org/pipermail/linaro-dev/2014-May/017151.html Signed-off-by: Jean Pihet Cc: Will Deacon Cc: Steve Capper Reported-by: Sneha Priya --- arch/arm/include/asm/perf_event.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arch/arm/include/asm/perf_event.h b/arch/arm/include/asm/perf_event.h index 7558775..b02b5d3 100644 --- a/arch/arm/include/asm/perf_event.h +++ b/arch/arm/include/asm/perf_event.h @@ -26,6 +26,25 @@ struct pt_regs; extern unsigned long perf_instruction_pointer(struct pt_regs *regs); extern unsigned long perf_misc_flags(struct pt_regs *regs); #define perf_misc_flags(regs) perf_misc_flags(regs) + +/* + * Take a snapshot of the regs. + * We only need a few of the regs: + * - program counter for PERF_SAMPLE_IP, as used by dwarf unwinding, + * - sp & fp for fp based callchain unwinding, + * - cpsr for user_mode() tests. + */ +#define perf_arch_fetch_caller_regs(regs, __ip) { \ + instruction_pointer(regs)= (__ip); \ + __asm__ ( \ + "str sp, %[_ARM_sp] \n\t" \ + "str fp, %[_ARM_fp] \n\t" \ + "mrs %[_ARM_cpsr], cpsr \n\t" \ + : [_ARM_sp] "=m" (regs->ARM_sp), \ + [_ARM_fp] "=m" (regs->ARM_fp), \ + [_ARM_cpsr] "=r" (regs->ARM_cpsr) \ + ); \ +} #endif #endif /* __ARM_PERF_EVENT_H__ */