Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3862423rwb; Sun, 20 Nov 2022 23:57:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf6YBJFk18Ewwb1J/WZgpJ5TZlYw6GfLK2Y5CCtH0fLRUUul9Z9/8PC6Kn/ipqTIGjoOFTRl X-Received: by 2002:a05:6402:291b:b0:461:60b1:5c6d with SMTP id ee27-20020a056402291b00b0046160b15c6dmr3130164edb.182.1669017452837; Sun, 20 Nov 2022 23:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669017452; cv=none; d=google.com; s=arc-20160816; b=OeASj6K4fUpslpNeqO696PD5zRB/Ogm7Cc028ApD67J2vkyYPlSEURncdymPT7zKlE 73hhbDFGNo6pXEsIqJDIl7Loc0DHGyqH6a5NJTl29PY0XcEW1Po7lujmnnirk6+hvk24 nCts4LnkqQooH2BJv+mkrAJ/cXVl35FKmepR2zeQWuQp9KylXk4gscygPQlVLA3jtSed mkiy3WvbUSJ1JpKrP1xbBlB9dOHsV3cNLJ7aZiJtcRNtlA+rw8ZAvtcYee6Lk3+kWoK0 rSKXQnP5rrTVKT+kVzTXHa3/tueiA3/N/lfaNvvIr6bQGLel2Wl3auRlvsmoYNVYwPvg 5gaw== 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=z6Y107DNA2h9x1jFeZux4gnXIStbDXBkeJQpL1mBr6o=; b=O695AYDrp4GVSaw4l9mvu280E0t5Wo8cq/o3Yo5RRbywJT2j0at4lQluCMN8mRqHke HVSA4l57JJzy8gxOJlEbki9yvuVeSoCS8xt4lzEnc19mOUSwLPCSeOs4bTRNys9ejw7l a117qrumk099F8Pasbv9tS1tx++b3BU6DNfAeSnCfa9Eu+Yj9NUpIdzmgI9CCPxYy1GC Cj+UkWPzldQQjx4eDTNAsm7VzDwp3WVo2VpDymjcwjuIDq+oun77e6QRxQ82JGTBFOhf k79dCd4tk535e6hCw04xCTAgYcjQ2LBZ54PoWxQ8ohiO0NxmJWhomZV6wEMrrK2zaDjX 7Rvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="C/0DTzrf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a05640227c600b00462e5235356si9312700ede.619.2022.11.20.23.57.09; Sun, 20 Nov 2022 23:57:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="C/0DTzrf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229641AbiKUHxW (ORCPT + 91 others); Mon, 21 Nov 2022 02:53:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229967AbiKUHxB (ORCPT ); Mon, 21 Nov 2022 02:53:01 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D414B18B2F for ; Sun, 20 Nov 2022 23:52:58 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id l22-20020a17090a3f1600b00212fbbcfb78so13593326pjc.3 for ; Sun, 20 Nov 2022 23:52:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z6Y107DNA2h9x1jFeZux4gnXIStbDXBkeJQpL1mBr6o=; b=C/0DTzrfe1WiC81ULqWXVG8uqC+cxWZaE46z38bg2ldaZUyDoMboRI6+YTdf7UEWM4 Pf635lAErhsUFqKe/pFEMAURdZTLRijqz3LqQWeTUgK403nR79SGis+uf6rbYi5ex6v0 LH03gj4MlW/af7YyhHPQxqq3CoLyy8kJNF6fakvv9eeK0V5kOnAoZZoe/a7JS8EYpMXp X3FQl4YKFyWRejDIg/9DYzt0S7QHhdPHyrK0t9hgbby8zrb36fN+jM9hU8d/hlzWuVKL tEWnB1+7t30ZkygZfvfkqb83K0EKNNyFC8yrqoa/R4xdu5xf1xjqyFs3sJke9micx/6y lztA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z6Y107DNA2h9x1jFeZux4gnXIStbDXBkeJQpL1mBr6o=; b=ZLKvHo4m6a34DIF+iSg1bpPNOTF7d/TAmkkbcXBGgpnbbpN9NTtgdzSPOCtf+I6Qxf dhe8v75aoxjPwApvEt4faQI1+zZxXQU/zBjwphDwAGcAELZZwcusmELrlTX6158fP+JH mZD3V6Zk4wMbS2EWm8sr1Psa8zGL20XUZX/59WueeivqVNv2dBfeAK0cicUxrrDjc0Es f2YbOWpiO0kmIl7eh7stOdRe9VPBtKwTPftz2FFgjm9NPtO0piRizPf2cPCPBde01rv/ jdtEQ9wV6+Oqjhs7AJO2Q7S/WRXajWazj/FwCcaC/4VSruu20vaMexcN6/uDwmM9PCXP fnfQ== X-Gm-Message-State: ANoB5pnhNRsHSm/Rec7eFodnPHaQ26uqtvPfIYTizqsAiXBiTsslQ+0X h3drs52KhyLIObUhf09GSa6RJg== X-Received: by 2002:a17:902:c409:b0:182:bccf:619f with SMTP id k9-20020a170902c40900b00182bccf619fmr10787696plk.9.1669017177711; Sun, 20 Nov 2022 23:52:57 -0800 (PST) Received: from leoy-huangpu.lan (211-75-219-204.hinet-ip.hinet.net. [211.75.219.204]) by smtp.gmail.com with ESMTPSA id h31-20020a63575f000000b0047696938911sm7006277pgm.74.2022.11.20.23.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 23:52:57 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , linux-perf-users@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 3/5] perf trace: Handle failure when trace point folder is missed Date: Mon, 21 Nov 2022 07:52:35 +0000 Message-Id: <20221121075237.127706-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221121075237.127706-1-leo.yan@linaro.org> References: <20221121075237.127706-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Arm64 a case is perf tools fails to find the corresponding trace point folder for system calls listed in the table 'syscalltbl_arm64', e.g. the generated system call table contains "lookup_dcookie" but we cannot find out the matched trace point folder for it. We need to figure out if there have any issue for the generated system call table, on the other hand, we need to handle the case when trace point folder is missed under sysfs, this patch sets the flag syscall::nonexistent as true and returns the error from trace__read_syscall_info(). Another problem is for trace__syscall_info(), it returns two different values if a system call doesn't exist: at the first time calling trace__syscall_info() it returns NULL when the system call doesn't exist, later if call trace__syscall_info() again for the same missed system call, it returns pointer of syscall. trace__syscall_info() checks the condition 'syscalls.table[id].name == NULL', but the name will be assigned in the first invoking even the system call is not found. So checking system call's name in trace__syscall_info() is not the right thing to do, this patch simply checks flag syscall::nonexistent to make decision if a system call exists or not, finally trace__syscall_info() returns the consistent result (NULL) if a system call doesn't existed. Fixes: b8b1033fcaa0 ("perf trace: Mark syscall ids that are not allocated to avoid unnecessary error messages") Signed-off-by: Leo Yan --- tools/perf/builtin-trace.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index bd5513b15cde..071e7598391f 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1814,13 +1814,19 @@ static int trace__read_syscall_info(struct trace *trace, int id) sc->tp_format = trace_event__tp_format("syscalls", tp_name); } + /* + * Fails to read trace point format via sysfs node, so the trace point + * doesn't exist. Set the 'nonexistent' flag as true. + */ + if (IS_ERR(sc->tp_format)) { + sc->nonexistent = true; + return PTR_ERR(sc->tp_format); + } + if (syscall__alloc_arg_fmts(sc, IS_ERR(sc->tp_format) ? RAW_SYSCALL_ARGS_NUM : sc->tp_format->format.nr_fields)) return -ENOMEM; - if (IS_ERR(sc->tp_format)) - return PTR_ERR(sc->tp_format); - sc->args = sc->tp_format->format.fields; /* * We need to check and discard the first variable '__syscall_nr' @@ -2137,11 +2143,8 @@ static struct syscall *trace__syscall_info(struct trace *trace, (err = trace__read_syscall_info(trace, id)) != 0) goto out_cant_read; - if (trace->syscalls.table[id].name == NULL) { - if (trace->syscalls.table[id].nonexistent) - return NULL; + if (trace->syscalls.table && trace->syscalls.table[id].nonexistent) goto out_cant_read; - } return &trace->syscalls.table[id]; -- 2.34.1