Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2950260pxu; Mon, 14 Dec 2020 15:36:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJybRMjiJxGZOAx1W+4/BEpSC2BfmWP3fCUV/0JAOYtcY7iEdQZSvlBLmT6C4nSiOcm0WHox X-Received: by 2002:a17:906:3899:: with SMTP id q25mr24338224ejd.173.1607988968656; Mon, 14 Dec 2020 15:36:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607988968; cv=none; d=google.com; s=arc-20160816; b=CNkzMoXvFSpcK4G5AKUSONeX62M77xeiEMEJz0wMLFTpQkZhJ4FCfySgJKEsIGYKL5 BdFa+pCZwnBecfinx24dgihqofsp4Km+/MTzaLFjUrWEl/wU5cWNe7vMgb0NPPm7xTjf scrJbbgySkvPlll24/b50tkc/MaPXhgb19cIgFbYnvsztn8yWIeVUXu8AYxWHryf9XXa SCclqLLR51uKdM0+Ph+wqkvFtd4lga/3NNf7Ogbck9LjvvP/T60Bea740QY1G+JnnzY5 hS1f7WjTwrBIcIjipJohMNV1mzQ24R1gRbctPeJDPXOjuhx+Z9c1mTP3IKJncc0xVCpR JWtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=2qNBZhff/xgdRT8KK120bLe7dK/yvcAQI3FJg5CC/Jg=; b=q3oPvG4cd8DFKuwqjY47b8N71AAqpMRsJQkGtps6UXdQbZS6aliFC73mALLt9AvKQE 3+j2HpPuUNH6jvEvKCN8Zr13WA3WIsMFvnwW9Q5SORyOL4Jwp2mY0zckvqa9WNNzZXuK MWZBK8ghSNzvDA8fW/ApjNFhNN33484YzsP5ni7qwl8IE+EVxg5aCht30qtj477ia4x3 Yg0efqzTIwk3HB0gQXBtYqzuc+xg6PJ01u5/Wk/SHjw5FYlEeniZEEfR7zJOE5fjXTq1 hSq2Ifm+z6thB6LjQSelEcZlpOLOd34lj8Sf2IkhCehkcBjY8wjDF1xdSHClFNwDzX0+ k0SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RirpLR0L; 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 gs18si8968ejb.435.2020.12.14.15.35.46; Mon, 14 Dec 2020 15:36:08 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RirpLR0L; 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 S2405915AbgLNNku (ORCPT + 99 others); Mon, 14 Dec 2020 08:40:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:37494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390539AbgLNNkU (ORCPT ); Mon, 14 Dec 2020 08:40:20 -0500 Date: Mon, 14 Dec 2020 10:39:50 -0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607953179; bh=AMC5CQEhi9XfiB5U/3SFE1EIz5yjn0jMNgojfbpGWuE=; h=From:To:Cc:Subject:References:In-Reply-To:From; b=RirpLR0LlxsoiOlfC0vwwnESoVQuUHbw3Q60GM2BiN28bWyLbUuEdPczV68sZASo2 UMz0PcaLhePvnhwmNz9zRo3go4+64iQOmcfxBekW67U5fIeEdQ6stAgpSe5NzcKLKv /MjSOidCthsI6+i55uDyU5Jl66utYAHmLiN46CXAzNbh/n0PmytQZR6BQ7iloS4xCY 0Gow2uw2sVB5zxGESjH8uJH6VFTW0Fy8q9qORg52tsdAfefhRixcgqEMznHgh2h+yy ZyTWHkoA7u/OuFzy/+m9HZsWtH1jG0hiQdCaHlWV05yCJBUKK2Sq7vpEg0jTM+Iow9 P5kLSlR1eFIiQ== From: Arnaldo Carvalho de Melo To: Tiezhu Yang Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, Xuefeng Li Subject: Re: [PATCH] perf callchain: Return directly when use '--call-graph dwarf' under !CONFIG_DWARF Message-ID: <20201214133950.GE238399@kernel.org> References: <1607950615-11825-1-git-send-email-yangtiezhu@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1607950615-11825-1-git-send-email-yangtiezhu@loongson.cn> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Dec 14, 2020 at 08:56:55PM +0800, Tiezhu Yang escreveu: > 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 Good improvement on the message! But that .config-detected file isn't available at run time, take a look if this isn't a better alternative: diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 1b60985690bba313..125178fd17482513 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -276,6 +276,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 +291,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; > 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 > --- > 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..a8cf456 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" > > @@ -278,6 +279,16 @@ int parse_callchain_record(const char *arg, struct callchain_param *param) > } else if (!strncmp(name, "dwarf", sizeof("dwarf"))) { > const unsigned long default_stack_dump_size = 8192; > > + if (system("grep -q 'CONFIG_DWARF=y' .config-detected") != 0) { > + struct utsname uts; > + > + ret = uname(&uts); > + pr_err("DWARF is not supported for architecture %s\n", > + ret ? "unknown" : uts.machine); > + > + return -ENOTSUP; > + } > + > ret = 0; > param->record_mode = CALLCHAIN_DWARF; > param->dump_size = default_stack_dump_size; > -- > 2.1.0 > -- - Arnaldo