From patchwork Mon May 19 12:30:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 30380 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 20C15203AB for ; Mon, 19 May 2014 12:33:09 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id ey11sf30595347pad.4 for ; Mon, 19 May 2014 05:33:08 -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=8czYZ+DcN772qy3b219wn44DxXmJihBcu38IpSkko2c=; b=Lw/G9ZngX14tDsomirJWPeNWbmj2eb/1/KZlbI1StEoq0dzRpUu3ftKe2+XGRnoX2H TfReYMdizIW4ddYMAg/AMisOu7ZMPZWpgq97ldt54NUV3MepC3FhHrFjRUZdNLKrIpSF ZWHqQAmMcMU/IeWXCaZepH//NlOIYo97LOAQKo4Oe5NyJB2qSi8ZlxHRI+tKcEkmKbuD KkNQQG+Qq3DpqhG7HHl4jMfdE035ZRGWHeYScDNoq/smMnfWIfElRqtinFbvZJ/pIA+R f4Dv3ZrrI/ipCSQQSKt/YnjMnqFKZQn1rwUzxEUXN32fN8UOU6IPXMmaawHq1axAT9oU K2rA== X-Gm-Message-State: ALoCoQml+neVgMcEmDUFvxEEteqgOgjmNHUD8y0xPZb+DuR+C3NFMxH3gHz+3B1kLmkA5/VlENf1 X-Received: by 10.66.157.138 with SMTP id wm10mr2185637pab.23.1400502788468; Mon, 19 May 2014 05:33:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.44 with SMTP id a41ls1641192qge.72.gmail; Mon, 19 May 2014 05:33:08 -0700 (PDT) X-Received: by 10.58.132.228 with SMTP id ox4mr151732veb.54.1400502788238; Mon, 19 May 2014 05:33:08 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id sg6si3857484vdc.189.2014.05.19.05.33.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 May 2014 05:33:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.171 as permitted sender) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id oz11so6290377veb.16 for ; Mon, 19 May 2014 05:33:08 -0700 (PDT) X-Received: by 10.220.53.72 with SMTP id l8mr4518007vcg.16.1400502788095; Mon, 19 May 2014 05:33:08 -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 ib8csp233620vcb; Mon, 19 May 2014 05:33:07 -0700 (PDT) X-Received: by 10.67.5.233 with SMTP id cp9mr25606945pad.147.1400502787112; Mon, 19 May 2014 05:33:07 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xs3si904751pbb.369.2014.05.19.05.33.06; Mon, 19 May 2014 05:33:06 -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 S1754501AbaESMck (ORCPT + 27 others); Mon, 19 May 2014 08:32:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7327 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754311AbaESMbY (ORCPT ); Mon, 19 May 2014 08:31:24 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4JCVDKd002168 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 May 2014 08:31:13 -0400 Received: from krava.brq.redhat.com (dhcp-1-141.brq.redhat.com [10.34.1.141]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s4JCUuG2010128; Mon, 19 May 2014 08:31:11 -0400 From: Jiri Olsa To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Jean Pihet , Arnaldo Carvalho de Melo , Corey Ashford , David Ahern , Frederic Weisbecker , Namhyung Kim , Paul Mackerras , Peter Zijlstra , Jiri Olsa Subject: [PATCH 7/8] perf tests: Add dwarf unwind test on ARM Date: Mon, 19 May 2014 14:30:55 +0200 Message-Id: <1400502656-20751-8-git-send-email-jolsa@kernel.org> In-Reply-To: <1400502656-20751-1-git-send-email-jolsa@kernel.org> References: <1400502656-20751-1-git-send-email-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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: linux-kernel-owner@vger.kernel.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.171 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: , From: Jean Pihet 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 omitted from the stack unwind. So far it was enabled only for x86. Signed-off-by: Jean Pihet Reviewed-by: Will Deacon Cc: Arnaldo Carvalho de Melo Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1400229672-16104-3-git-send-email-jean.pihet@linaro.org Signed-off-by: Jiri Olsa --- tools/perf/Makefile.perf | 2 +- tools/perf/arch/arm/Makefile | 1 + tools/perf/arch/arm/include/perf_regs.h | 3 ++ tools/perf/arch/arm/tests/dwarf-unwind.c | 60 ++++++++++++++++++++++++++++++++ tools/perf/config/Makefile | 4 +-- tools/perf/tests/builtin-test.c | 2 +- tools/perf/tests/tests.h | 2 +- 7 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 tools/perf/arch/arm/tests/dwarf-unwind.c diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 2baf61c..dea2d633 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),x86) +ifeq ($(ARCH),$(filter $(ARCH),x86 arm)) LIB_OBJS += $(OUTPUT)tests/dwarf-unwind.o endif endif diff --git a/tools/perf/arch/arm/Makefile b/tools/perf/arch/arm/Makefile index 9b8f87e..221f21d 100644 --- a/tools/perf/arch/arm/Makefile +++ b/tools/perf/arch/arm/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/arm/include/perf_regs.h b/tools/perf/arch/arm/include/perf_regs.h index 33abcfa..f619c9c 100644 --- a/tools/perf/arch/arm/include/perf_regs.h +++ b/tools/perf/arch/arm/include/perf_regs.h @@ -8,6 +8,9 @@ void perf_regs_load(u64 *regs); #define PERF_REGS_MASK ((1ULL << PERF_REG_ARM_MAX) - 1) +#define PERF_REGS_MAX PERF_REG_ARM_MAX +#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32 + #define PERF_REG_IP PERF_REG_ARM_PC #define PERF_REG_SP PERF_REG_ARM_SP diff --git a/tools/perf/arch/arm/tests/dwarf-unwind.c b/tools/perf/arch/arm/tests/dwarf-unwind.c new file mode 100644 index 0000000..9f870d2 --- /dev/null +++ b/tools/perf/arch/arm/tests/dwarf-unwind.c @@ -0,0 +1,60 @@ +#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_ARM_SP]; + + map = map_groups__find(thread->mg, MAP__VARIABLE, (u64) sp); + if (!map) { + pr_debug("failed to get stack map\n"); + free(buf); + 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 = calloc(1, 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/config/Makefile b/tools/perf/config/Makefile index f2edc59..729bbdf 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -40,11 +40,11 @@ ifeq ($(ARCH),arm64) LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 endif -# So far there's only x86 libdw unwind support merged in perf. +# So far there's only x86 and arm libdw unwind support merged in perf. # Disable it on all other architectures in case libdw unwind # support is detected in system. Add supported architectures # to the check. -ifneq ($(ARCH),x86) +ifneq ($(ARCH),$(filter $(ARCH),x86 arm)) NO_LIBDW_DWARF_UNWIND := 1 endif diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 0d5afaf..5e0764b 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -115,7 +115,7 @@ 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__) +#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) #ifdef HAVE_DWARF_UNWIND_SUPPORT { .desc = "Test dwarf unwind", diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index a9d7cb0..8f91fb0 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -45,7 +45,7 @@ int test__hists_filter(void); int test__mmap_thread_lookup(void); int test__thread_mg_share(void); -#if defined(__x86_64__) || defined(__i386__) +#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) #ifdef HAVE_DWARF_UNWIND_SUPPORT struct thread; struct perf_sample;