From patchwork Fri Dec 1 20:30:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 172659 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp1399304vqy; Fri, 1 Dec 2023 12:31:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfYWsPr9RpRHtXmW0rqpk/7Z+tXk+2xBXwdyOt+/9se6t7DAQ8C7I88FL847wz9W/4NW9u X-Received: by 2002:a17:903:24c:b0:1cf:cf34:d4cf with SMTP id j12-20020a170903024c00b001cfcf34d4cfmr123874plh.18.1701462681843; Fri, 01 Dec 2023 12:31:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701462681; cv=none; d=google.com; s=arc-20160816; b=h9ienx36qeUsATNzRI6/Nvps1Txyfbj/X6tkZ3F+eCS2AbMkhc6xEBkS0XqA7MnpB+ GcW5aHCl9rHCX4shC3VWE4YVz0d3zcTbw17ukCdeS41qtc+HV7x728eWpT7VitoBMI5D ITcLGTzgiWh3BRb6maiPyNngag6ks/fccxxSJArTjXFaJIRtV9APZtU/yhJ6IkL5vaRs yR7jJJ9hT32uyYtsjjWrg1ecjhSAQEkto7D700IP+L+IXBROQiKlx7eMUE6sEZm46JTL H6PbOH5Ibgy+LQ+KROE0Mchbd+k9OsJ1TdfwUZ2zEUL8hZScjw/IGt7o81wLbZOHZiVi amZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SFje6ypj7ABQA76pkPtDKKYjSSfWfcYU0fjlsAuOksc=; fh=uZsD07co8Icydw+TJ5RhxP40OBPNx7zXkeQ59T5yII8=; b=TM5dFbY6e4L0eOHtnS3q8MydhttNId2Zj1uUiL9MPX0wPh11MPiuCSOS4cddQ8WKT/ bLLXBTEFdZnVfTzrTYKvdLqR+zLL4E0S/BIKZZM6DJeZs0J+sdpwhoUwG5zNa7iVsMrF GNkD3kGFYGaToqc4UbTSoTuWbuh2XB4SvSsO7SJbrqosdMTfeN+Qcwh5KWfmcSPAToMf S6/YDSuSquCHl9t6KdGYaANmMbex7pPu6jBrBipXQL0VcNfzQk2MQKmtqZeOqqrglEVh SGluZrWt6tMcnmOClLF1SkZ9mxVdj9tPxm+l8YVry/XReQaVxgdHeowRU1NTmDbkRbnK 2qbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f70uuGix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id d17-20020a170903231100b001cfd5a36b31si4054515plh.495.2023.12.01.12.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 12:31:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f70uuGix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7D4948047846; Fri, 1 Dec 2023 12:31:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379561AbjLAUax (ORCPT + 99 others); Fri, 1 Dec 2023 15:30:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379547AbjLAUav (ORCPT ); Fri, 1 Dec 2023 15:30:51 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EEAD10DF for ; Fri, 1 Dec 2023 12:30:57 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CBE7C433CB; Fri, 1 Dec 2023 20:30:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701462657; bh=QVbACnLUnYQMYgOMYoEehYGakqfQw3HgLVP3m0AP9nI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f70uuGixlDaJcgsf2n6YchS57/ri8BALDiEeWnOumwvDZDqwy67PHfV8h9LsE8s3N /VGa3UkO5I1x9vdByVOcmKTE75IcwsAx/Od2IhZe/kEunB0yu2/Vwd7bTz7mdYl0nT QJ1GvffFGrB0Sz1CoqFoSSeYjRmzYDgxQpKBG9/AxedGGYO8/VSBDuVLh+PFma13tV p5Zl+97ISlp1A5ISIy+amkTI89UhCQA6lvAN4YfImzZo1oVdIaK8/RpFP2IBzYCViH Ripio0j/StTd1uSV91lBO/4ICDL1cVVpvOs/n0DWngSw2fuiJX+tH3ltB3hL463Hwj Kfj+P5ng5F9SQ== From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , Jiri Olsa , Ian Rogers , Adrian Hunter , Clark Williams , Kate Carcia , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , David Laight Subject: [PATCH 1/2] perf env: Introduce perf_env__arch_strerrno() Date: Fri, 1 Dec 2023 17:30:45 -0300 Message-ID: <20231201203046.486596-2-acme@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231201203046.486596-1-acme@kernel.org> References: <20231201203046.486596-1-acme@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 01 Dec 2023 12:31:17 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784112933001225916 X-GMAIL-MSGID: 1784112933001225916 From: Arnaldo Carvalho de Melo That will cache the arch specific function translating error numbers to strings. Cc: Adrian Hunter Cc: David Laight Cc: Ian Rogers Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lore.kernel.org/lkml/ Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 6 ++---- tools/perf/util/env.c | 7 +++++++ tools/perf/util/env.h | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index e541d0e2777ab935..109b8e64fe69ae32 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2470,9 +2470,8 @@ static int trace__fprintf_callchain(struct trace *trace, struct perf_sample *sam static const char *errno_to_name(struct evsel *evsel, int err) { struct perf_env *env = evsel__env(evsel); - const char *arch_name = perf_env__arch(env); - return arch_syscalls__strerrno(arch_name, err); + return perf_env__arch_strerrno(env, err); } static int trace__sys_exit(struct trace *trace, struct evsel *evsel, @@ -4264,12 +4263,11 @@ static size_t thread__dump_stats(struct thread_trace *ttrace, printed += fprintf(fp, " %9.3f %9.2f%%\n", max, pct); if (trace->errno_summary && stats->nr_failures) { - const char *arch_name = perf_env__arch(trace->host->env); int e; for (e = 0; e < stats->max_errno; ++e) { if (stats->errnos[e] != 0) - fprintf(fp, "\t\t\t\t%s: %d\n", arch_syscalls__strerrno(arch_name, e + 1), stats->errnos[e]); + fprintf(fp, "\t\t\t\t%s: %d\n", perf_env__arch_strerrno(trace->host->env, e + 1), stats->errnos[e]); } } } diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index cbc18b22ace5231e..fdd62ea00173ccf5 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -12,6 +12,7 @@ #include #include "pmus.h" #include "strbuf.h" +#include "trace/beauty/beauty.h" struct perf_env perf_env; @@ -453,6 +454,12 @@ const char *perf_env__arch(struct perf_env *env) return normalize_arch(arch_name); } +const char *perf_env__arch_strerrno(struct perf_env *env, int err) +{ + const char *arch_name = perf_env__arch(env); + return arch_syscalls__strerrno(arch_name, err); +} + const char *perf_env__cpuid(struct perf_env *env) { int status; diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h index 94596ff124d54188..79f371879f45bafc 100644 --- a/tools/perf/util/env.h +++ b/tools/perf/util/env.h @@ -164,6 +164,7 @@ int perf_env__read_cpu_topology_map(struct perf_env *env); void cpu_cache_level__free(struct cpu_cache_level *cache); const char *perf_env__arch(struct perf_env *env); +const char *perf_env__arch_strerrno(struct perf_env *env, int err); const char *perf_env__cpuid(struct perf_env *env); const char *perf_env__raw_arch(struct perf_env *env); int perf_env__nr_cpus_avail(struct perf_env *env);