From patchwork Fri Jun 27 14:57:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Pihet X-Patchwork-Id: 32623 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 672D520CE6 for ; Fri, 27 Jun 2014 14:58:25 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id n16sf29561055oag.6 for ; Fri, 27 Jun 2014 07:58:24 -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=dPF1bshJB1YwpjrQM+Jxsw6MNus+zCeqS6WynZAclMM=; b=YkfS1FO/e4d2HAwIxgXLMNnM835Dx1yYpOCEBauZ1OwNAFCuJs8ueUfqTu/4ZNTJNg MSP26IdcqkwGMbf3WWohTfkBpJIKjAo0uD3rPslFARpv65Je4ZQppv6a57B0qviwyiA0 yQq+ebD/mGrKvM31K2NC0cRU4KbI2ci355vN7A2N5mL5QgTPViDG+mniIM7Kj3jkV1q9 R1lI6u8UGVegC4yPBwQElt33+kbxtD0sn1ndgyD5UZKxzCnjMVfdSqHUD5K/FLINnwrK 4oBTGwYrzwRgrNlB7+UdWjoDS5kg8UP3xSWLPdAaksyJrhC3CrSlFgOmHuMH4swmoN2C auEg== X-Gm-Message-State: ALoCoQkhslJm8wDruZacJb1xH5pQpRWxvetN9zNFM4DOKbURK8NIzw+vzdo0PGNMn6NFVpm3k62t X-Received: by 10.182.134.133 with SMTP id pk5mr12659268obb.31.1403881104904; Fri, 27 Jun 2014 07:58:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.203 with SMTP id c69ls123900qgd.85.gmail; Fri, 27 Jun 2014 07:58:24 -0700 (PDT) X-Received: by 10.58.69.76 with SMTP id c12mr20035286veu.35.1403881104711; Fri, 27 Jun 2014 07:58:24 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id fx3si6485619vdc.84.2014.06.27.07.58.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 07:58:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id il7so5227406vcb.12 for ; Fri, 27 Jun 2014 07:58:24 -0700 (PDT) X-Received: by 10.58.46.141 with SMTP id v13mr20305972vem.18.1403881104602; Fri, 27 Jun 2014 07:58:24 -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 tc5csp113478vcb; Fri, 27 Jun 2014 07:58:24 -0700 (PDT) X-Received: by 10.68.163.197 with SMTP id yk5mr31162983pbb.57.1403881103830; Fri, 27 Jun 2014 07:58:23 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qv2si14221198pbb.188.2014.06.27.07.58.23; Fri, 27 Jun 2014 07:58:23 -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 S1754082AbaF0O6N (ORCPT + 27 others); Fri, 27 Jun 2014 10:58:13 -0400 Received: from mail-wg0-f48.google.com ([74.125.82.48]:52507 "EHLO mail-wg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754033AbaF0O6K (ORCPT ); Fri, 27 Jun 2014 10:58:10 -0400 Received: by mail-wg0-f48.google.com with SMTP id n12so5146890wgh.19 for ; Fri, 27 Jun 2014 07:58:09 -0700 (PDT) X-Received: by 10.194.63.228 with SMTP id j4mr25726116wjs.7.1403881089314; Fri, 27 Jun 2014 07:58:09 -0700 (PDT) Received: from localhost.localdomain (216.193-240-81.adsl-dyn.isp.belgacom.be. [81.240.193.216]) by mx.google.com with ESMTPSA id 19sm21920749wjz.3.2014.06.27.07.58.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jun 2014 07:58:08 -0700 (PDT) From: Jean Pihet To: Will Deacon , linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, Sneha Priya , linux-kernel@vger.kernel.org, Jiri Olsa , Arnaldo Carvalho de Melo Cc: Jean Pihet Subject: [PATCH 3/3] ARM: perf: allow tracing with kernel tracepoints events Date: Fri, 27 Jun 2014 16:57:47 +0200 Message-Id: <1403881067-22690-4-git-send-email-jean.pihet@linaro.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1403881067-22690-1-git-send-email-jean.pihet@linaro.org> References: <1403881067-22690-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.220.181 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: ip, sp, fp and cpsr. 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 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: + * - ip for PERF_SAMPLE_IP, + * - sp & fp for fp & dwarf 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__ */