From patchwork Tue Sep 24 17:43:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 20555 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6ABD625E03 for ; Tue, 24 Sep 2013 17:43:40 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id h10sf4757479vbh.9 for ; Tue, 24 Sep 2013 10:43:39 -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:date:from:to:cc:subject:message-id :references:mime-version:in-reply-to:user-agent:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-disposition; bh=GRUoXgCJmCa7+Lr5/hMmgRhRVzYxczj/QEJqsrAj2ww=; b=Gj/EuKMDbhL2z8yrCRJrHUFoeGOJlEmoANXI4HFqcDSwnnGtJVrg30HuAtObxJ30Lp rRpf+Xslp+RpmhMmuhLUTKJF7rcxg2YimlIEM8cgqZ2zKs4EV3HvGaK+ibf8CgGFiXT8 wECSt5y81U8jTRDG2tqjDu1fd05ON6h00P1KT+PauGRXOMDIMkhHMXXAvR3AmSjuAmss fQ5J+6x9JS0s86QLQlfa8SAxM4GZ8SN5gbsiQdZGU5Lbnbg+cqllalVUihivWCUAv+6q UE/gR99lzxn6OR0E8U00AtoXblfDJN+1lR4/SSwFEJpTyvFEx4qLe4mHWbHl2ONMCe8a VmCg== X-Gm-Message-State: ALoCoQkuwogmDmwhuy5aTEuakmuDZYi3/os2zJSJDIJLmqv9Lb+/TylQEUEyt413VrKylhhvzg9v X-Received: by 10.236.147.18 with SMTP id s18mr10050735yhj.28.1380044619673; Tue, 24 Sep 2013 10:43:39 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.64.38 with SMTP id l6ls251741qes.89.gmail; Tue, 24 Sep 2013 10:43:39 -0700 (PDT) X-Received: by 10.52.187.138 with SMTP id fs10mr23222997vdc.10.1380044619520; Tue, 24 Sep 2013 10:43:39 -0700 (PDT) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id dt10si8712436vdb.21.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 24 Sep 2013 10:43:39 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.180; Received: by mail-ve0-f180.google.com with SMTP id jz11so3668457veb.25 for ; Tue, 24 Sep 2013 10:43:39 -0700 (PDT) X-Received: by 10.52.75.228 with SMTP id f4mr23201143vdw.6.1380044619394; Tue, 24 Sep 2013 10:43:39 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp257105vcz; Tue, 24 Sep 2013 10:43:38 -0700 (PDT) X-Received: by 10.49.129.166 with SMTP id nx6mr13617835qeb.75.1380044618637; Tue, 24 Sep 2013 10:43:38 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTP id d1si15397586qaf.102.1969.12.31.16.00.00; Tue, 24 Sep 2013 10:43:38 -0700 (PDT) Received-SPF: pass (google.com: domain of jolsa@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8OHhLCW020645 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 24 Sep 2013 13:43:22 -0400 Received: from krava.brq.redhat.com (dhcp-1-243.brq.redhat.com [10.34.1.243]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id r8OHhIeg007297; Tue, 24 Sep 2013 13:43:19 -0400 Date: Tue, 24 Sep 2013 19:43:18 +0200 From: Jiri Olsa To: Jean Pihet Cc: Will Deacon , Ingo Molnar , Arnaldo Carvalho de Melo , "linux-kernel@vger.kernel.org" , "linaro-kernel@lists.linaro.org" , "linux-arm-kernel@lists.infradead.org" , "patches@linaro.org" Subject: Re: [PATCH 3/4] perf tools: Check libunwind for availability of dwarf parsing feature Message-ID: <20130924174318.GE3080@krava.brq.redhat.com> References: <1379323053-11458-1-git-send-email-jean.pihet@linaro.org> <1379323053-11458-4-git-send-email-jean.pihet@linaro.org> <20130917102904.GA27258@mudshark.cambridge.arm.com> <20130924093450.GB1008@krava.brq.redhat.com> <20130924100620.GG15119@mudshark.cambridge.arm.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: jolsa@redhat.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Content-Disposition: inline On Tue, Sep 24, 2013 at 02:03:47PM +0200, Jean Pihet wrote: > Hi Jiri, Will, > > On 24 September 2013 12:06, Will Deacon wrote: > > On Tue, Sep 24, 2013 at 10:34:50AM +0100, Jiri Olsa wrote: > >> On Tue, Sep 24, 2013 at 10:55:32AM +0200, Jean Pihet wrote: > >> > Ping on the series. The two patches above (3/4 and 4/4) are generic > >> > while the two others are impacting ARM only. > >> > Is it possible to get an Ack for the generic ones? > >> > >> I'm fine with those changes.. still I'm sort of worried about > >> current DWARF unwind users (but not sure if there're any), > >> who depends on packaged libunwind compiled without > >> --enable-debug-frame option. > > > > Since x86 is the only architecture using libunwind with perf at the moment, > > and I'd expect it to use .eh_frame for unwinding, I'm also not sure there > > are any existing users to worry about. > Right > > > > >> I've seen your libunwind patch to make it default, but > >> not sure if it was accepted.. if not, maybe we should > >> detect this and build that code conditionaly. > > > > It certainly defaults to "on" for ARM, but other architectures have to > > enable it explicitly afaict. > Yes that is correct. > This patch (3/4) detects if the debug frame code is enabled in > libunwind and uses the lib only if it is the case. My concern is about users (again, not sure if there are any ;-) ) that use this with packaged libunwind compiled without --enable-debug-frame option. For them perf will consider libunwind as 'not available' with your changes: ... CHK libunwind config/Makefile:223: No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1 ... and they'll need to compile their own libunwind (thats the case on Fedora). This could be solved by detecting this and make your code conditional as attached below (not much tested). thanks, jirka diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 134b36e..d40cf0a 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -223,6 +223,10 @@ ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y) msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1); NO_LIBUNWIND := 1 endif # Libunwind support +ifneq ($(call try-cc,$(SOURCE_LIBUNWIND_DEBUG_FRAME),$(FLAGS_UNWIND),libunwind debug_frame),y) + msg := $(warning No debug_frame support found in libunwind); +CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME +endif endif # NO_LIBUNWIND ifndef NO_LIBUNWIND diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak index 87124d0..645141c 100644 --- a/tools/perf/config/feature-tests.mak +++ b/tools/perf/config/feature-tests.mak @@ -178,6 +178,28 @@ extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as, #define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table) +int main(void) +{ + unw_addr_space_t addr_space; + addr_space = unw_create_addr_space(NULL, 0); + unw_init_remote(NULL, addr_space, NULL); + dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL); + return 0; +} +endef + +define SOURCE_LIBUNWIND_DEBUG_FRAME +#include +#include + +extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as, + unw_word_t ip, + unw_dyn_info_t *di, + unw_proc_info_t *pi, + int need_unwind_info, void *arg); + +#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table) + extern int UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug, unw_word_t ip, @@ -189,11 +211,7 @@ UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug, int main(void) { - unw_addr_space_t addr_space; - addr_space = unw_create_addr_space(NULL, 0); - unw_init_remote(NULL, addr_space, NULL); dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0); - dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL); return 0; } endef diff --git a/tools/perf/util/unwind.c b/tools/perf/util/unwind.c index 429a99c..231c941 100644 --- a/tools/perf/util/unwind.c +++ b/tools/perf/util/unwind.c @@ -277,6 +277,7 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine, return ret; } +#ifndef NO_LIBUNWIND_DEBUG_FRAME static int read_unwind_spec_debug_frame(struct dso *dso, struct machine *machine, u64 *offset) { @@ -294,6 +295,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso, return -EINVAL; } +#endif static struct map *find_map(unw_word_t ip, struct unwind_info *ui) { @@ -334,6 +336,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, need_unwind_info, arg); } +#ifndef NO_LIBUNWIND_DEBUG_FRAME /* Check the .debug_frame section for unwinding info */ if (!read_unwind_spec_debug_frame(map->dso, ui->machine, &segbase)) { memset(&di, 0, sizeof(di)); @@ -342,7 +345,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, return dwarf_search_unwind_table(as, ip, &di, pi, need_unwind_info, arg); } - +#endif return -EINVAL; }