Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3382758pxu; Tue, 15 Dec 2020 05:56:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzosRqOVUKGPIhM1PiRAvYnjgaAB/3A+9sc/EQZ3mWf0RCvDE7j5oRJwMnu+q8lwPWfiEEO X-Received: by 2002:a50:c315:: with SMTP id a21mr2535489edb.50.1608040560878; Tue, 15 Dec 2020 05:56:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608040560; cv=none; d=google.com; s=arc-20160816; b=s2se/qJJXuLekXobdyFsyhF9VCYB/mzIlGhzxTXH3kCUrdUEdsjlpBpvD9sbqlcJ0F MsPX4jfC8/KpAWDNOGtS9dUJEkj4no7/o42/iw1zqFlgoiPAc7lfR46tYYECiCZha1P4 lWOxpIUkKmUZm0edpDUqdUBCe34mEXM04tIcGAxhZIK20s0CmtdISUKJa5kBZZoPovHS HPCCsiHTpQZSDGJwSlUUo2F2I3+U+GIfLm8L6TTo4qFMQA2dhfQIXfDyMuGBk6NFMqtY eRZ7lGoEdKTkUY8nvolqJfJreN4bXNG9FXZ0FPHRK45Kf3Tu0ojipGmY2UoNOTo5EIPs Wnlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=cCVaoJFKEtI7Btpypz1Lyb8fOWukXtArgLnLgeKjRr0=; b=PPLeyEQf9lBxhHdSlFP7lY0dRUiSPRyKCNOAxHAVADQOzzhtelzsiFBUDNCogDn2PU 8ps5q3akHALaudVX/dT/sr/xqZBpHAbIyNCBRqVw4dY4Eo89JNH+me+PS8UN8y7/w4w6 jJC4fIzMRZ6c7XYPBmTZPNlqg6Qf7GrGjulS+bmORR29+gUcpRHE0f+fMIES4WviGnSO b3Ajfmy9W60jpYhCx9MVyg38Bfpko1mF0dx17exHGTl4QpISdJkb5MljgO6BpR6wyY6g +5kxLpcTau/ySiwRFV35xhwh125mmN1pImu2TCPwyKxD6haNree+IVct8TTStUaDDBi0 gSPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq1si829952ejc.530.2020.12.15.05.55.37; Tue, 15 Dec 2020 05:56:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728448AbgLONvG (ORCPT + 99 others); Tue, 15 Dec 2020 08:51:06 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:35184 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726819AbgLONux (ORCPT ); Tue, 15 Dec 2020 08:50:53 -0500 Received: by mail-lf1-f68.google.com with SMTP id a9so39495248lfh.2 for ; Tue, 15 Dec 2020 05:50:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cCVaoJFKEtI7Btpypz1Lyb8fOWukXtArgLnLgeKjRr0=; b=Uk3NSzsXKnursyDjV7JY81ItOuHjMH0LHFcX8psXcegaYlTBNJnzoDQMafBAvHmO8+ 59IycVJgNdH+KUPWW98ss9JeSbffRjK392vzLT7Xxfigb6fO2gBFQsOgKixNyyp+ZAoz Wponr9UKun2cqLRP/So/umQhYleFWy/eiTfkKeVcf7/YqYz69DPVJms7B24D2a/LGu5M zakkCEEIwWeekRfV8amhHHNnSwCgz9Nnw0q5tmH72FmgwnYxagHL9ogChNOGunUS+WN0 VcCaultugf1S0WnDIfegGUj28zG6Cs2b2UglGUnZyU6k+WawSNy8Kh3/zLk/Fgya+WjU S3Mw== X-Gm-Message-State: AOAM531MS8iddsmgLY519rmcgXcPv9nAIPi9etglsHZ20QPfYGgM3koU oydmQ/54QmYpq0tc2vR36WIAwMAYme+pJ3uMQuh5PifN X-Received: by 2002:a19:cc10:: with SMTP id c16mr11048202lfg.112.1608040210893; Tue, 15 Dec 2020 05:50:10 -0800 (PST) MIME-Version: 1.0 References: <1607996131-9340-1-git-send-email-yangtiezhu@loongson.cn> In-Reply-To: <1607996131-9340-1-git-send-email-yangtiezhu@loongson.cn> From: Namhyung Kim Date: Tue, 15 Dec 2020 22:49:59 +0900 Message-ID: Subject: Re: [PATCH v2] perf callchain: Return directly when use '--call-graph dwarf' under !HAVE_DWARF_SUPPORT To: Tiezhu Yang Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , linux-kernel , Xuefeng Li Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Tue, Dec 15, 2020 at 10:35 AM Tiezhu Yang wrote: > > DWARF register mappings have not been defined for some architectures, > at least for mips, so we can print an error message and then return > directly when use '--call-graph dwarf'. > > E.g. without this patch: > > [root@linux perf]# ./perf record --call-graph dwarf cd > Error: > The sys_perf_event_open() syscall returned with 89 (Function not implemented) for event (cycles). > /bin/dmesg | grep -i perf may provide additional information. > > With this patch: > > [root@linux perf]# ./perf record --call-graph dwarf cd > DWARF is not supported for architecture mips64 > > Usage: perf record [] [] > or: perf record [] -- [] > > --call-graph > setup and enables call-graph (stack chain/backtrace): > > record_mode: call graph recording mode (fp|dwarf|lbr) > record_size: if record_mode is 'dwarf', max size of stack recording () > default: 8192 (bytes) > > Default: fp > > Signed-off-by: Tiezhu Yang > --- > > v2: Use HAVE_DWARF_SUPPORT to check I'm not sure whether this is because of lack of dwarf library or kernel support. Based on the error message, I guess it's from the kernel. Then I think this patch won't be sufficient.. Thanks, Namhyung > > tools/perf/util/callchain.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c > index 1b60985..ad08554 100644 > --- a/tools/perf/util/callchain.c > +++ b/tools/perf/util/callchain.c > @@ -18,6 +18,7 @@ > #include > #include > #include > +#include > > #include "asm/bug.h" > > @@ -276,6 +277,7 @@ int parse_callchain_record(const char *arg, struct callchain_param *param) > > /* Dwarf style */ > } else if (!strncmp(name, "dwarf", sizeof("dwarf"))) { > +#ifdef HAVE_DWARF_SUPPORT > const unsigned long default_stack_dump_size = 8192; > > ret = 0; > @@ -290,6 +292,15 @@ int parse_callchain_record(const char *arg, struct callchain_param *param) > ret = get_stack_size(tok, &size); > param->dump_size = size; > } > +#else > + struct utsname uts; > + > + ret = uname(&uts); > + pr_err("DWARF is not supported for architecture %s\n", > + ret ? "unknown" : uts.machine); > + > + return -ENOTSUP; > +#endif > } else if (!strncmp(name, "lbr", sizeof("lbr"))) { > if (!strtok_r(NULL, ",", &saveptr)) { > param->record_mode = CALLCHAIN_LBR; > -- > 2.1.0 >