From patchwork Tue May 6 15:55:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Pihet X-Patchwork-Id: 29723 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C613E202E6 for ; Tue, 6 May 2014 15:56:54 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id oz11sf8194817veb.2 for ; Tue, 06 May 2014 08:56:54 -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=AKg+jtY7yb9V+RvynjtEHN5ix4pE/igOwFrvQOxQUcc=; b=XVCHU7E6PaauIVcyFdJryiTAUAlyBvkke0+L48Lqb/s2R3u04fkiGgNv7SxC1+KbfF tdsHsrKb+/kmbhNEnjkR3Da+vdxb9kD3HHysP7EaKGYytYcpFiiT5IaKuxO9Suiz48Nb DcLQETMcdBt+amHY0u7pExSIArdy1+K+IfNty+49usFa+b2yQVxfARjraKSbzWFZPr7a 4TJDp4qYyIiyc5/syvssnRmtP8EZMcV0+EGupZT/KQ+8vaqCc0bjNzANCcMjwXQpdvxF o/BZNvyRCN/cqFg2yy90QoVU8DkJnnuIXAM1pHxxYyJ+OUuLmNoQ5SEVp/6PMBkg4e+S Ks6g== X-Gm-Message-State: ALoCoQnipUolLcuMRNKonRKSu1RsFFtbCnNcvz0SZ0lW3fDdeR8VF67HXfE2x1mFBmjIHwb7794B X-Received: by 10.58.195.202 with SMTP id ig10mr1479552vec.38.1399391814044; Tue, 06 May 2014 08:56:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.40.74 with SMTP id w68ls3028809qgw.53.gmail; Tue, 06 May 2014 08:56:53 -0700 (PDT) X-Received: by 10.52.235.97 with SMTP id ul1mr751291vdc.87.1399391813955; Tue, 06 May 2014 08:56:53 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id sc7si2394110vdc.67.2014.05.06.08.56.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 06 May 2014 08:56:53 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id la4so1260809vcb.27 for ; Tue, 06 May 2014 08:56:53 -0700 (PDT) X-Received: by 10.52.181.132 with SMTP id dw4mr729300vdc.86.1399391813840; Tue, 06 May 2014 08:56:53 -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.220.221.72 with SMTP id ib8csp234999vcb; Tue, 6 May 2014 08:56:53 -0700 (PDT) X-Received: by 10.66.160.34 with SMTP id xh2mr7751272pab.109.1399391812960; Tue, 06 May 2014 08:56:52 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tf5si8422447pac.295.2014.05.06.08.56.52; Tue, 06 May 2014 08:56:52 -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 S1758101AbaEFP4i (ORCPT + 27 others); Tue, 6 May 2014 11:56:38 -0400 Received: from mail-ee0-f49.google.com ([74.125.83.49]:49940 "EHLO mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754792AbaEFPzx (ORCPT ); Tue, 6 May 2014 11:55:53 -0400 Received: by mail-ee0-f49.google.com with SMTP id e53so6501800eek.22 for ; Tue, 06 May 2014 08:55:52 -0700 (PDT) X-Received: by 10.14.115.195 with SMTP id e43mr10915152eeh.76.1399391752227; Tue, 06 May 2014 08:55:52 -0700 (PDT) Received: from localhost.localdomain (193.219-240-81.adsl-dyn.isp.belgacom.be. [81.240.219.193]) by mx.google.com with ESMTPSA id x45sm39543683eef.15.2014.05.06.08.55.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 06 May 2014 08:55:51 -0700 (PDT) From: Jean Pihet To: Jiri Olsa , Arnaldo Carvalho de Melo , will.deacon@arm.com Cc: "linux-kernel@vger.kernel.org" , "linaro-kernel@lists.linaro.org" , "linux-arm-kernel@lists.infradead.org" , Jean Pihet , Corey Ashford , Frederic Weisbecker , Ingo Molnar , Namhyung Kim , Paul Mackerras , Peter Zijlstra , David Ahern Subject: [PATCH 2/3] perf tests: Add dwarf unwind test on ARM64 Date: Tue, 6 May 2014 17:55:32 +0200 Message-Id: <1399391733-11927-3-git-send-email-jean.pihet@linaro.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1399391733-11927-1-git-send-email-jean.pihet@linaro.org> References: <1399391733-11927-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=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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: , Adding dwarf unwind test, that setups live machine data over the perf test thread and does the remote unwind. Need to use -fno-optimize-sibling-calls for test compilation, otherwise 'krava_*' function calls are optimized into jumps and ommited from the stack unwind. Cc: Jiri Olsa Cc: Corey Ashford Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Arnaldo Carvalho de Melo Cc: David Ahern Signed-off-by: Jean Pihet --- tools/perf/Makefile.perf | 2 +- tools/perf/arch/arm64/Makefile | 1 + tools/perf/arch/arm64/include/perf_regs.h | 3 ++ tools/perf/arch/arm64/tests/dwarf-unwind.c | 59 ++++++++++++++++++++++++++++++ tools/perf/tests/builtin-test.c | 3 +- tools/perf/tests/tests.h | 3 +- 6 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 tools/perf/arch/arm64/tests/dwarf-unwind.c diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index dea2d633..6cde50f 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -411,7 +411,7 @@ LIB_OBJS += $(OUTPUT)tests/code-reading.o LIB_OBJS += $(OUTPUT)tests/sample-parsing.o LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o ifndef NO_DWARF_UNWIND -ifeq ($(ARCH),$(filter $(ARCH),x86 arm)) +ifeq ($(ARCH),$(filter $(ARCH),x86 arm arm64)) LIB_OBJS += $(OUTPUT)tests/dwarf-unwind.o endif endif diff --git a/tools/perf/arch/arm64/Makefile b/tools/perf/arch/arm64/Makefile index 9b8f87e..221f21d 100644 --- a/tools/perf/arch/arm64/Makefile +++ b/tools/perf/arch/arm64/Makefile @@ -5,4 +5,5 @@ endif ifndef NO_LIBUNWIND LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libunwind.o LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/regs_load.o +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/dwarf-unwind.o endif diff --git a/tools/perf/arch/arm64/include/perf_regs.h b/tools/perf/arch/arm64/include/perf_regs.h index 1e052f1..e74df99 100644 --- a/tools/perf/arch/arm64/include/perf_regs.h +++ b/tools/perf/arch/arm64/include/perf_regs.h @@ -9,6 +9,9 @@ #define PERF_REG_IP PERF_REG_ARM64_PC #define PERF_REG_SP PERF_REG_ARM64_SP +#define PERF_REGS_MAX PERF_REG_ARM64_MAX +#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_64 + void perf_regs_load(u64 *regs); static inline const char *perf_reg_name(int id) diff --git a/tools/perf/arch/arm64/tests/dwarf-unwind.c b/tools/perf/arch/arm64/tests/dwarf-unwind.c new file mode 100644 index 0000000..0aa64f3 --- /dev/null +++ b/tools/perf/arch/arm64/tests/dwarf-unwind.c @@ -0,0 +1,59 @@ +#include +#include "perf_regs.h" +#include "thread.h" +#include "map.h" +#include "event.h" +#include "tests/tests.h" + +#define STACK_SIZE 8192 + +static int sample_ustack(struct perf_sample *sample, + struct thread *thread, u64 *regs) +{ + struct stack_dump *stack = &sample->user_stack; + struct map *map; + unsigned long sp; + u64 stack_size, *buf; + + buf = malloc(STACK_SIZE); + if (!buf) { + pr_debug("failed to allocate sample uregs data\n"); + return -1; + } + + sp = (unsigned long) regs[PERF_REG_ARM64_SP]; + + map = map_groups__find(&thread->mg, MAP__FUNCTION, (u64) sp); + if (!map) { + pr_debug("failed to get stack map\n"); + return -1; + } + + stack_size = map->end - sp; + stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size; + + memcpy(buf, (void *) sp, stack_size); + stack->data = (char *) buf; + stack->size = stack_size; + return 0; +} + +int test__arch_unwind_sample(struct perf_sample *sample, + struct thread *thread) +{ + struct regs_dump *regs = &sample->user_regs; + u64 *buf; + + buf = malloc(sizeof(u64) * PERF_REGS_MAX); + if (!buf) { + pr_debug("failed to allocate sample uregs data\n"); + return -1; + } + + perf_regs_load(buf); + regs->abi = PERF_SAMPLE_REGS_ABI; + regs->regs = buf; + regs->mask = PERF_REGS_MASK; + + return sample_ustack(sample, thread, buf); +} diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 5e0764b..7921aa0 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -115,7 +115,8 @@ static struct test { .desc = "Test parsing with no sample_id_all bit set", .func = test__parse_no_sample_id_all, }, -#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) +#if defined(__x86_64__) || defined(__i386__) || \ + defined(__arm__) || defined(__aarch64__) #ifdef HAVE_DWARF_UNWIND_SUPPORT { .desc = "Test dwarf unwind", diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 8f91fb0..426680e 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -45,7 +45,8 @@ int test__hists_filter(void); int test__mmap_thread_lookup(void); int test__thread_mg_share(void); -#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) +#if defined(__x86_64__) || defined(__i386__) || \ + defined(__arm__) || defined(__aarch64__) #ifdef HAVE_DWARF_UNWIND_SUPPORT struct thread; struct perf_sample;