Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3026419pxu; Mon, 14 Dec 2020 18:22:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBVsU09LCWDlNp4LWcO7cQhYIGXpOcNHLlKkd0yvbw1hxsiHA37OKYyeP10Yhn+gwgDUYr X-Received: by 2002:a50:e846:: with SMTP id k6mr27920068edn.245.1607998956780; Mon, 14 Dec 2020 18:22:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607998956; cv=none; d=google.com; s=arc-20160816; b=Mp6tH76U3VvnSIUrNA/GrEdP8XsOnhNwHJ1fQa+WxbqF9aqdoXd5lrMkWGedTL0vUd sZ8FxI1txEJ1696hoaIb3nN3Mq2tqOQ++W1eral0TzrQFoHiVNTLrU1PHzzfu1kamdwr 4aRqlRTWQYnXWTq1huZN6uApSF+62FcfW/FjeN/xAIcUFwo6hGOa+hxLrV8KivtsxVM5 WlvWjHFVksA93bqwp3UKzuJPmqSQUsvUjZq6UDKjDpgTeUFVBGDFhzKxehm/01G1NHW5 iMK+doqg9OVDpoNu1Vb0NtNsjK4vIrkeKAViwrnd8c2UQEdCGzDCineaf50s00Vm8Ax4 r1sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=3BnDNy0Sq8x965NQNhCzYs9w6t7pKG+3gjOGCwvs9Vk=; b=FJR4XS9RdXDGUNIDIidgi902zu3uerC2oRruMCw28O6QGFTw5EwJJjg3kmbaX0vQQz 6vKOyb1DJRvyLHVqRkYalToYjFb29Jn22LuCL+QC7f+0ljuLxwEYG+mppZmbQbKewKZD sLJDu378BcdrCUJ13eDkn+JzPEZNwmysnawHUJ5lGLh7c2LEipQVwfpC6+M8xmWUqRZb itQuLcDvuQtLg8k2HTD9hpRG2gAni0mwRVsvpMDkjnBkFHzfBozdwmGT5w+SzJigUpUn R7qcOUbkudGJCtDwhe2dNmT5SLK4idtzYhufjI9i9UJF0hNsUlRZfe5qWrKa451oN9Fk L1Sg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id re20si170791ejb.112.2020.12.14.18.22.13; Mon, 14 Dec 2020 18:22:36 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730269AbgLOBgh (ORCPT + 99 others); Mon, 14 Dec 2020 20:36:37 -0500 Received: from mail.loongson.cn ([114.242.206.163]:38790 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729820AbgLOBgX (ORCPT ); Mon, 14 Dec 2020 20:36:23 -0500 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxGcrkEthfl20AAA--.1046S2; Tue, 15 Dec 2020 09:35:33 +0800 (CST) From: Tiezhu Yang To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim Cc: linux-kernel@vger.kernel.org, Xuefeng Li Subject: [PATCH v2] perf callchain: Return directly when use '--call-graph dwarf' under !HAVE_DWARF_SUPPORT Date: Tue, 15 Dec 2020 09:35:31 +0800 Message-Id: <1607996131-9340-1-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf9AxGcrkEthfl20AAA--.1046S2 X-Coremail-Antispam: 1UD129KBjvJXoW7ZFW3ZF4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Mailing-List: linux-kernel@vger.kernel.org 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 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