From patchwork Mon Nov 21 07:52:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 23573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1442836wrr; Sun, 20 Nov 2022 23:57:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf7g/HlwHePSHTUFAh9+iI1ND4Qu33fJ1aZe7faOVaCweIH+iMrYFEnHlxF8R/oIbyJl1OPF X-Received: by 2002:a17:906:7852:b0:7b7:718d:22c with SMTP id p18-20020a170906785200b007b7718d022cmr454283ejm.507.1669017455728; Sun, 20 Nov 2022 23:57:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669017455; cv=none; d=google.com; s=arc-20160816; b=Uy+4FsgIj6U9VdfBt7pghNhUQ1zzGhaVfI9RrInOUMtdnwq2qMJjSDwf0tVfzYKifK wr8pIBb4bvD7U/mHlSF5j1yjF34Jx58nrovvA7snGTf+XJikCYLkveTBqllANfa5Gy13 QzpVzNLAI1AkhFx3dpCegHrmAMENa/DE8ldbIpuoFDFyTG75vPn3s0rnl8YOYAqIal1G btO+K6voX8+SyVux5e4dl0w+egDcYwvh1jLIm5YGtCZ+lSiQAYwaT2Yv7l6g2jwKOD0o o3+VscJYpKzJwv7Xr+sH3DFbcGucXbX4FsVb15Qru84+Rf0j56dIdiAc3suqRArtWy6s M2bQ== 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=GrdNyxmUm7/OayqjPE/oVvrwFtOOqyIl/5p9OFU6Fr0=; b=JOScz0npGv8qcc+OQxqTbFYoIHAU1YAI/mNjm+9I+i88yxzs6+DoMauTEfgg20NB8j LNqI6IEhAQdKWSqKmIq1IFMwqsPjl1B4sy0ihTtvv2YG/AGn1O2W+0I6l35k76DdiN/t KznmBf2Kxj/cGqTjciYua5aQZeCdVE3yNbJG+7NRtSoabUaNHHnHqEEzStu2wO9cbAmO s/N0dfg4+g5R4vUPgQUp5OfBcwC6Cb7JIsWfjm4x+EeQTDJP8U7LSh6WskZCuaZMQxCR Ot0wYPrqMzD702IgUBQTkCJJ/PoQvgg394eYbKkx1IaHzpxaugZESeLQyzNyKSnhedOi f0fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wBPQtACI; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g23-20020a170906349700b0078d8b6976eesi7409777ejb.140.2022.11.20.23.57.11; Sun, 20 Nov 2022 23:57:35 -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=wBPQtACI; 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 S229884AbiKUHxB (ORCPT + 99 others); Mon, 21 Nov 2022 02:53:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbiKUHwv (ORCPT ); Mon, 21 Nov 2022 02:52:51 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BF7EC770 for ; Sun, 20 Nov 2022 23:52:50 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id 136so10460029pga.1 for ; Sun, 20 Nov 2022 23:52:50 -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=GrdNyxmUm7/OayqjPE/oVvrwFtOOqyIl/5p9OFU6Fr0=; b=wBPQtACIGMRQsLzX5Ws93cxwnKmhVj2dH6vEvL+TNjBZDoDwssZA7uu1BLzXIx6eYP RTaocauylMpuPsr4c3/sA3yQZrEucPI16eXN3jlWPzI4BIALq12/mQzJKdPs1cbTVkig 7kNh8Fms7yQu1xYBkPuDNatC/92hoz+IIiFILeRWbxSGWeJgR1v/zwNi2WfJ3Khs3Ym5 +cpK8IIzUD4tiK1xNAaZq7tCw7GGXfUsZwTToIuVEI6CjRJJfhz1fmKXcAyLYA9fi8fK 2L3/yXsmz8mTx+vx/IaZbuU2owjVBi3A0L3McfcGzPQsv8uEgFGWH0DSQpPE2SMJ3kwf Yl0g== 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=GrdNyxmUm7/OayqjPE/oVvrwFtOOqyIl/5p9OFU6Fr0=; b=CliaWu4hWfR6mtkHPnnKudJLiyEyad3zLi862yKc+fDg0I/fHc3ycrihoOELTdfgSa cwfjQvxSMxcbaMqCd2Vn5Hs4BFGCdc85Mru+UMAqUOb/sYH0f00vj2R4pquqR574+meh MfhfU/JijUNakffg/C/g/ubOgf1rGCkC7NsQe/hWjg2l2Bh0ctMT3LU6q1Gj517fhV20 ZuHKqRLCD5pmBATUpHDKLJpssWTjJ99LZJZe1jfnZCTVzNbhu59zyWH7y/45QuEb58jf 5rNbxaFrudGUvEiZivpLmFCDRJ5JJAurYbiw3mIz4XbFSnSLN/O2ZWmAEiDVyT9atTf5 8irg== X-Gm-Message-State: ANoB5pmXJjo4UieYTTzsbMjP/mqeDEsLhTnc4dVGsfedGh4aqawDKXcQ 9g2EWTk5vo1jfAaS9x470UHXuQ== X-Received: by 2002:a63:f808:0:b0:426:9c23:97da with SMTP id n8-20020a63f808000000b004269c2397damr17469280pgh.2.1669017169852; Sun, 20 Nov 2022 23:52:49 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 23:52:49 -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 1/5] perf trace: Use macro RAW_SYSCALL_ARGS_NUM to replace number Date: Mon, 21 Nov 2022 07:52:33 +0000 Message-Id: <20221121075237.127706-2-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 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=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750091647920512720?= X-GMAIL-MSGID: =?utf-8?q?1750091647920512720?= This patch defines a macro RAW_SYSCALL_ARGS_NUM to replace the open coded number '6'. Signed-off-by: Leo Yan --- tools/perf/builtin-trace.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 3257da5cad23..22008a31684b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -88,6 +88,8 @@ # define F_LINUX_SPECIFIC_BASE 1024 #endif +#define RAW_SYSCALL_ARGS_NUM 6 + /* * strtoul: Go from a string to a value, i.e. for msr: MSR_FS_BASE to 0xc0000100 */ @@ -108,7 +110,7 @@ struct syscall_fmt { const char *sys_enter, *sys_exit; } bpf_prog_name; - struct syscall_arg_fmt arg[6]; + struct syscall_arg_fmt arg[RAW_SYSCALL_ARGS_NUM]; u8 nr_args; bool errpid; bool timeout; @@ -1229,7 +1231,7 @@ struct syscall { */ struct bpf_map_syscall_entry { bool enabled; - u16 string_args_len[6]; + u16 string_args_len[RAW_SYSCALL_ARGS_NUM]; }; /* @@ -1661,7 +1663,7 @@ static int syscall__alloc_arg_fmts(struct syscall *sc, int nr_args) { int idx; - if (nr_args == 6 && sc->fmt && sc->fmt->nr_args != 0) + if (nr_args == RAW_SYSCALL_ARGS_NUM && sc->fmt && sc->fmt->nr_args != 0) nr_args = sc->fmt->nr_args; sc->arg_fmt = calloc(nr_args, sizeof(*sc->arg_fmt)); @@ -1812,7 +1814,8 @@ static int trace__read_syscall_info(struct trace *trace, int id) sc->tp_format = trace_event__tp_format("syscalls", tp_name); } - if (syscall__alloc_arg_fmts(sc, IS_ERR(sc->tp_format) ? 6 : sc->tp_format->format.nr_fields)) + 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)) From patchwork Mon Nov 21 07:52:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 23568 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1442432wrr; Sun, 20 Nov 2022 23:56:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf7nWqZ8I/5ElRkT8qNsQ3KmetON+fRwTR/aePxe8q5tqSKvY4UVVhHbPctfIQjvyFPJY8ae X-Received: by 2002:a05:6402:1045:b0:461:68e1:ced5 with SMTP id e5-20020a056402104500b0046168e1ced5mr4602151edu.142.1669017370109; Sun, 20 Nov 2022 23:56:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669017370; cv=none; d=google.com; s=arc-20160816; b=iHjNiwxV25NEEXRGKV58puC/WE6xwhjs7gtoYKnh/AS5sdqzF+HoxBI/kPPGcvAkwp ndUt46H8Kov8O/SVbsHp2XDVJ8gMecwUBbIm/gUYZSCEPS6fDrAoIusDcrOTuOX0Uwc+ MgFJm0RESv8pLilmj+kypP15QJTahpMoY2ZTRgxuyVcctie/6TuGpcrms4Lc9jEFDzZ+ XC2PgyMWpE0u1pWa4kJ8yQqUXrZ06Kt64E/qJ9P7Yd5W/2NnOt9Q8N77SbOc0Fo7r+xP tqNk//hiY4MwrdZSr0WMW6nn8wuF3TincpSk/7m5Y6563QS9J3vdhPU9Uv4N6X4yYisx 4Bsw== 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=Pvc1zXEGR7HMHrwAlmwh9iePoKt7remHUDBQE6tcKek=; b=xRgZQZmb2BO9A6oonNzQP34Vj0hTdxh9EHed9wno5hEQz8r6l0K+KT2rCJaEQWDxCu ZavU/MsxRP3/OrAKqAPfZQV8o63iSw8VL8BxKimo0lLY5Hihg78MyMj71nlPWxjwPJqu kYEZz8Qapdqoq2kFu6KbISw11CjSC3/5LJ+dpmC76gWFMBYUTq/TIsCvXFqBUUEIdaYS o+1aewSEXK6GzwPrbOt8lnQddWDnL4qCp46lTuf7TwdA/jhSaetyuP0C5VwTE7TDQhhp lMtCzSH1h5bTcd4scnVUvn68UBumWXtJPfdpmKnuCD8fPDKx6Lw7AlK1WY93gbef9Hli HgBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fuRSF+oq; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b19-20020a056402351300b004511d552be3si3727329edd.4.2022.11.20.23.55.46; Sun, 20 Nov 2022 23:56:10 -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=fuRSF+oq; 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 S229735AbiKUHxL (ORCPT + 99 others); Mon, 21 Nov 2022 02:53:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229653AbiKUHw5 (ORCPT ); Mon, 21 Nov 2022 02:52:57 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FF741571B for ; Sun, 20 Nov 2022 23:52:54 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id y203so10618279pfb.4 for ; Sun, 20 Nov 2022 23:52:54 -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=Pvc1zXEGR7HMHrwAlmwh9iePoKt7remHUDBQE6tcKek=; b=fuRSF+oqTR6nicfjS6pFRenl0ln+tt5LxFA9pJwpIX9ZXcBuWJc1wmJU+1c8s8szwo Hu82FRt4aTLXN9hxyqyRQltl4dGqabZuZ1GFHZHk0vTbps5p8eP8bMrPzS9yKKLe+P+h /PWW2gHcTnRgislEbqElp38G+hdl8iN+Nqmmn/ZvRVzpHhklh5UeAqmT00xQwnBXFDik hqQhA0gpN7VDwK5EjADucMgGg5qaz9NAG9Vyyq41VkagnbG42V7jeaMPREtIbh/ssMm2 tVj1m0yXMBFJjxg56NKU/aPkshDlrpFep/WAbE5l+6I4D6A9FEFKmtKzQFzb7OXoO/K2 CgbQ== 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=Pvc1zXEGR7HMHrwAlmwh9iePoKt7remHUDBQE6tcKek=; b=wcTvAzxu4jUVSg32EkQcB96Xx5XIGOuNDAArGfMVV6DqaLtOVVHQrA1QnLZBs0brx1 w9uFFVUG4JY+QimhCiZ8YMW4v1ocEMTbxX7Y7M/fwkFs61Q7SS8+XpclJWWHE0B+63tc CWH5DjXg9VXXYB7NwBwNdoe5Jw1jth+Hh4zvRrfTd8i0S4AAiXp3FsD/QiF+U2n6ztar EjIatLqx15q6/I/l0hp/Uq4g84pu9BpsJ+uaYx6572vPuJBaxSRZTW87xvXgw7ArwTHo PFXD5aPYm/5XNO+sRF2ljcDigAMlD+LY0YzgmuF/R3teyaakRxvvAA1BncZFBqj0KEo1 GYhQ== X-Gm-Message-State: ANoB5plNzkYnEZxcU+xCVAmgisVtp1U2jWnBXpitLeve/ThNtCSp2KRl 0GoN3VBki98E3leRADfFB9dONQ== X-Received: by 2002:a62:542:0:b0:56c:45db:4481 with SMTP id 63-20020a620542000000b0056c45db4481mr18882213pff.86.1669017173582; Sun, 20 Nov 2022 23:52:53 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 23:52:53 -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 2/5] perf trace: Return error if a system call doesn't exist Date: Mon, 21 Nov 2022 07:52:34 +0000 Message-Id: <20221121075237.127706-3-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750091557819298445?= X-GMAIL-MSGID: =?utf-8?q?1750091557819298445?= When a system call is not detected, the reason is either because the system call ID is out of scope or failure to find the corresponding path in the sysfs, trace__read_syscall_info() returns zero. Finally, without returning an error value it introduces confusion for the caller. This patch lets the function trace__read_syscall_info() to return -EEXIST when a system call doesn't exist. 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 22008a31684b..bd5513b15cde 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1796,11 +1796,11 @@ static int trace__read_syscall_info(struct trace *trace, int id) #endif sc = trace->syscalls.table + id; if (sc->nonexistent) - return 0; + return -EEXIST; if (name == NULL) { sc->nonexistent = true; - return 0; + return -EEXIST; } sc->name = name; From patchwork Mon Nov 21 07:52:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 23569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1442454wrr; Sun, 20 Nov 2022 23:56:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf6S5pv028eR98yUjehLcCoA/LTiJRCfhrlHkz/FmtoJ6qCqnEWehD+ktCgJFws8quh1lUNr X-Received: by 2002:a17:906:882:b0:7ad:e161:b026 with SMTP id n2-20020a170906088200b007ade161b026mr8548107eje.760.1669017375252; Sun, 20 Nov 2022 23:56:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669017375; cv=none; d=google.com; s=arc-20160816; b=EkFNXI88EJ+GnHqJ7oYh70ES7UAZN7xiYY+M/pXkjdW9qWfjPP6cSIfcmPzB1TTuzV DVaaT6Gw2vJSNSv+2qUJuzXh2R2mrGH8VhDxcjJtAdVER6pzzWQ1Ge08e7YtdtiUCPqB ZmPd8gXRcwbLENgBL64FCpEf5QVKuSHXCuRiMUGp6u2gUqQP+IObORBykKhGLLV/gyD+ umZ89cqbzISJjoLQfhwG8OkeL5ujrXx/roz56CAaPVzs48dweY6EwjJxeajas+MaI7bF Zil5xPPG80BenGOUpXl1EGgSzJQM7q5KAXeW6KoJ4+RSSDEMgBcQUhko2xvLojMr/3yl Ajpg== 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 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.55.51; Sun, 20 Nov 2022 23:56:15 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750091563553762314?= X-GMAIL-MSGID: =?utf-8?q?1750091563553762314?= 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]; From patchwork Mon Nov 21 07:52:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 23572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1442767wrr; Sun, 20 Nov 2022 23:57:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf4I9GF6Xa7wFPV9CmdIezXwvC9X26c48j2quUzjSK3Hf+3GH7jpW8j2WbRpxH57APIF8/RW X-Received: by 2002:a17:906:3499:b0:7b2:75c6:6d32 with SMTP id g25-20020a170906349900b007b275c66d32mr14566274ejb.209.1669017438235; Sun, 20 Nov 2022 23:57:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669017438; cv=none; d=google.com; s=arc-20160816; b=YjOFDydeIfPf24n6ZQAVEcy9xpAxH89T7DsHfKlIVkW1LMb0pYHedK/7zx5l3lr0sx hR6QNP71dnVpGQTFvFNDfcbN1+6Ld2r8clhXgObYKhXC5moLJf/SBlkRPh+mxYPfW6zh VArWzF8feC8DrBR1L0DkNzQMo+ZphtDOoI2/VQWIqV+laPED5jaabdD7rSea1Fw2k0bS emsdsMB4exO4W5UsTRvSz6AGjhW+YIlwiiRzd8gpUdGA67tUgM2OaJuLy4zZnJASiMd7 we8x6HfiBYQ1pd3dQ9RViinDdJa99ZZYfApG94mgx3Ek8rklZxEfvA5NM3e4OXnQpr+E w7BQ== 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=4nLzWG/ZTlfyMH+jybHcXaVQUlUlVa+L1Vc5qu2tDhc=; b=F/2hJiAnCcw6KmVq3mdHj6ZhibXPq+X1fmquw16QLp60xPO1rFKuCVWP2v4NvddlYv vnAcTgOvg6tq4LSjywC5XiZj9b7juqn1HPzo/a0iaidc8tMbtiPMfx+Aj4gefmKrqwD9 ICylQtyGuRWrG3Q00LOUd3Vxaz6ICx1Ya/cheOmOKx6iqooqorgRB0FSWnrW5JtTZNjN DXusDD2e53S8ky25KAWcUFCNJwWSasGR6OPLQwymlwpsNG+mTmqMc3BHXe4SLteTLRY0 Mzq+8hYfrg8xjpFjfLAAyNVJXsIJoqOaB4oaXaQ6kt+iSGDgcg87LMheO7/zWzA0+eh3 mQkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LBszov47; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a1709064ac100b007ae21bbb010si7013795ejt.462.2022.11.20.23.56.54; Sun, 20 Nov 2022 23:57:18 -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=LBszov47; 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 S230017AbiKUHxY (ORCPT + 99 others); Mon, 21 Nov 2022 02:53:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbiKUHxI (ORCPT ); Mon, 21 Nov 2022 02:53:08 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37DA819288 for ; Sun, 20 Nov 2022 23:53:02 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id u6-20020a17090a5e4600b0021881a8d264so8215879pji.4 for ; Sun, 20 Nov 2022 23:53:02 -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=4nLzWG/ZTlfyMH+jybHcXaVQUlUlVa+L1Vc5qu2tDhc=; b=LBszov47TdVdBRHvE1cfnPBOe3cxsDJcrikL+M/vEKKxTQ/1XRbnsDBXfi0ePFG6gj ztTpDO8zLTFE3hLkjMN31cjLxh32u4WfDHpgvfXC52n/khIGcvE2RmdQtAb5CUfn+efb XLsVB/XW1MQgrAKGPLokqKPXBmfsNJVbXwp5D/DCBiSKz20SbNoTLRToQ48H/2mpyhxs h2tB1hHR43Qy5H/vEQHr8g4kcBA7m9FpONKrjjx9KoXlT/eMRFkcykAdIB2wkCUfcx8f 9pwADcqEhGL7eiPFOTBJwG+ZkCEBUCbWU3vlMC882xV1yBZGFLCbbmwr4ZdD3DvqxSLm B1Bg== 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=4nLzWG/ZTlfyMH+jybHcXaVQUlUlVa+L1Vc5qu2tDhc=; b=7ev2cK0TLws27trDAiCSAAugDw6/5yNQH26/LSNq8XYx59dni28QBT749j2fzaiOG+ U0b0/ZtmVF6AoUMGhUVmxMlt/u19BVgobTQWPIcKL0LDmx1bb8e9TmqgSAVNSdyKS4C3 kEUtTx8aLWnrKP19+YwmwkIXhImg89RucauzddP65bfHSMgisW/DiDQH3PrT5yY+h44R 3TOa/43Q35SBe+vFTDhxnYsh9evTb92/YM7AKHunDnetROVBFKMjq5WhIbDbwkGCbnrz 4mZKJNoyXC5ixOjW+IfCVwtbjBa6s6Xe0avYrwSc0gbeBd8NqPa59F71LwEQgazxf0Uz 6e8w== X-Gm-Message-State: ANoB5pl6wGi5NwZnMbyG2AddviWBrq//yK/ZCwKaWi/+s8ECjyhqmTkg ztKEP+PsezJAojbmvnTy5wPtlg== X-Received: by 2002:a17:902:e40a:b0:17a:a81:2a52 with SMTP id m10-20020a170902e40a00b0017a0a812a52mr4100105ple.159.1669017181614; Sun, 20 Nov 2022 23:53:01 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 23:53:01 -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 4/5] perf augmented_raw_syscalls: Remove unused variable 'syscall' Date: Mon, 21 Nov 2022 07:52:36 +0000 Message-Id: <20221121075237.127706-5-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 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=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750091629652084799?= X-GMAIL-MSGID: =?utf-8?q?1750091629652084799?= The local variable 'syscall' is not used anymore, remove it. Signed-off-by: Leo Yan --- tools/perf/examples/bpf/augmented_raw_syscalls.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/perf/examples/bpf/augmented_raw_syscalls.c b/tools/perf/examples/bpf/augmented_raw_syscalls.c index 7dc24c9173a7..4203f92c063b 100644 --- a/tools/perf/examples/bpf/augmented_raw_syscalls.c +++ b/tools/perf/examples/bpf/augmented_raw_syscalls.c @@ -389,7 +389,6 @@ int sys_enter(struct syscall_enter_args *args) * initial, non-augmented raw_syscalls:sys_enter payload. */ unsigned int len = sizeof(augmented_args->args); - struct syscall *syscall; if (pid_filter__has(&pids_filtered, getpid())) return 0; From patchwork Mon Nov 21 07:52:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 23571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1442725wrr; Sun, 20 Nov 2022 23:57:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf4l1pf4QOa1jkvAYhE58PzReX0gSq9XsK6/4p6MKFsIgiMaTVvnpGfb6krLPMGnzo4FU3sF X-Received: by 2002:a17:906:3a5b:b0:78d:f3f4:b1a0 with SMTP id a27-20020a1709063a5b00b0078df3f4b1a0mr14470162ejf.489.1669017429848; Sun, 20 Nov 2022 23:57:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669017429; cv=none; d=google.com; s=arc-20160816; b=TkWdcFV41gjGyN2KVJL5igE2Ql754p17lsQ6GK7Wi8qjbNIokR5QryHWiz1eajkJ8V jZSODW7Y/DWapkNpDUeM9x7xsXWNwziooLs6qvOIrqz60yu2ICKil9Q+r5gcZxf/s1Km PFDjrA7ypA/YFnfFbUMd/8BGQSv5jpb899T9TduzNwC5XQ7hpd4OiZ3tzFEeUD52dt+4 VykByeaPYqPnMGg1HgVmxrdmCSGnevxpA0pFZyqsnC8LRr5kJG9o1K9Epfcsg2Avrs98 aJZxOfaIKL6Vd/MdWaAmYyvaZxZM3DMDHp4I5LpkMd6R+h+7RVIpZAqsnloLsCE03TLl sEhA== 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=RqA7GnPEIDi0/ln9UnpZAyxUmAWvsJa7ceEccOKwVB0=; b=lG/h8BsFPy0HGabdquxFFkwk63eV4lVu/7yeoDHQ0uHDRUewQv6ivzeCu/umncR4+8 YICZWcpvuIOLL+qJwrCzX5nEDawzuzAAAyJR/et1TjkRDryXS77GZv/wr7xlZPGZr5VA IfpRKOwJF2UW0bNFohDE7ZPdeV91lSWbUSPghMZ4U84e3FOjx7bDTyccyRDDjq2lqAYA vgVfuQ7ti9cjc/O2uXCDPGb9+qFDXX6qtQ2A5CtJq7VMb9F/inlDiUez3afLqxRuB6Ve 1dENbvoHE+TLbkV29AcJF2tgcQdf1XwNURgDq54LH6LoIkSTsBSXxW6/1MiY9/EKKMA3 ZKYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rwgDPnz7; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs31-20020a1709073e9f00b0078e27ef9501si8260100ejc.750.2022.11.20.23.56.45; Sun, 20 Nov 2022 23:57:09 -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=rwgDPnz7; 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 S230034AbiKUHxf (ORCPT + 99 others); Mon, 21 Nov 2022 02:53:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbiKUHxK (ORCPT ); Mon, 21 Nov 2022 02:53:10 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DC8B1DDFA for ; Sun, 20 Nov 2022 23:53:06 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id k5so9713511pjo.5 for ; Sun, 20 Nov 2022 23:53:06 -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=RqA7GnPEIDi0/ln9UnpZAyxUmAWvsJa7ceEccOKwVB0=; b=rwgDPnz7eCaF4kgAd9T7GJdBS3tW0j1x+nZ44ErKxzCxS4sj2PoNoSlmkjajdBRKlo ZS4g/r2LZ9LLSKP676o3Ns9xN+pYYId5xf9C+QqO7tQVOZ9npERxwB1ksmOuTxiri3tD ZoNhrGqYaTqRh3m72uUYjdJcYPtlpF1FdNo86FCTHKqegwdOABvpRoIGldv2NhQJ1zTy SEAnXARWfj9tm2P8aU6WzLuxGlzJW7BBeHc4gH2SexwIl2YNqzlrMRmRH2e0ePt4eu7D pPGcXv8C2uIe3m+2rHfQZqWOPF7RZCLYAD6d/tdtbOmcy69TOAed4MXTJZfkPfQ9yHK/ jHmg== 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=RqA7GnPEIDi0/ln9UnpZAyxUmAWvsJa7ceEccOKwVB0=; b=n78LkBdm5u2ZqK5rM3cM09uO/kYMoGH3QrbY1nYjsMvmr1DEItJB8Fbv1BMkLBu6UF BST+/Wb2MwtZb9oKbpuXGS00WNQr1vw9wko3fHTvsROc2egoMgFK7yElroHOvalWJ3NH kMCXCigj+/25R6lw1bQ5JVtLed1kTjqn7rLFfhAkK22A5TdEmrD4dLtXCRVWJuTkdCks CLR20u6RG59XaYN242Y/cK5IWqXAOZsFhIky1M1gJf1DJ/i38ZCcKlbmop9d7q1GaWv9 /u0swZ1GHlyz1xmvYqojGyul1IWamaHfslBKU0/QMMYHcs4hJjhStFsDWt8vSguUojvr qp/A== X-Gm-Message-State: ANoB5pnLGXHVYPsUfXbn7zWOKY24pPewBn0V7C1EtasQpQ8989jRR0BC ETqaLCOx/TS89v+cHcftZE5luvDdAZccU15a X-Received: by 2002:a17:902:ebc1:b0:176:a6c5:20c9 with SMTP id p1-20020a170902ebc100b00176a6c520c9mr1297669plg.57.1669017185355; Sun, 20 Nov 2022 23:53:05 -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.53.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 23:53:04 -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 5/5] perf trace: Remove unused bpf map 'syscalls' Date: Mon, 21 Nov 2022 07:52:37 +0000 Message-Id: <20221121075237.127706-6-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750091620552158348?= X-GMAIL-MSGID: =?utf-8?q?1750091620552158348?= augmented_raw_syscalls.c defines the bpf map 'syscalls' which is initialized by perf tool in user space to indicate which system calls are enabled for tracing, on the other flip eBPF program relies on the map to filter out the trace events which are not enabled. The map also includes a field 'string_args_len[6]' which presents the string length if the corresponding argument is a string type. Now the map 'syscalls' is not used, bpf program doesn't use it as filter anymore, this is replaced by using the function bpf_tail_call() and PROG_ARRAY syscalls map. And we don't need to explicitly set the string length anymore, bpf_probe_read_str() is smart to copy the string and return string length. Therefore, it's safe to remove the bpf map 'syscalls'. To consolidate the code, this patch removes the definition of map 'syscalls' from augmented_raw_syscalls.c and drops code for using the map in the perf trace. Note, since function trace__set_ev_qualifier_bpf_filter() is removed, calling trace__init_syscall_bpf_progs() from it is also removed. We don't need to worry it because trace__init_syscall_bpf_progs() is still invoked from trace__init_syscalls_bpf_prog_array_maps() for initialization the system call's bpf program callback. After: # perf trace -e examples/bpf/augmented_raw_syscalls.c,open* --max-events 10 perf stat --quiet sleep 0.001 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3 openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libelf.so.1", O_RDONLY|O_CLOEXEC) = 3 openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libdw.so.1", O_RDONLY|O_CLOEXEC) = 3 openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libunwind.so.8", O_RDONLY|O_CLOEXEC) = 3 openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libunwind-aarch64.so.8", O_RDONLY|O_CLOEXEC) = 3 openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libcrypto.so.3", O_RDONLY|O_CLOEXEC) = 3 openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libslang.so.2", O_RDONLY|O_CLOEXEC) = 3 openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libperl.so.5.34", O_RDONLY|O_CLOEXEC) = 3 openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 # perf trace -e examples/bpf/augmented_raw_syscalls.c --max-events 10 perf stat --quiet sleep 0.001 ... [continued]: execve()) = 0 brk(NULL) = 0xaaaab1d28000 faccessat(-100, "/etc/ld.so.preload", 4) = -1 ENOENT (No such file or directory) openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 close(3) = 0 openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3 read(3, 0xfffff33f70d0, 832) = 832 munmap(0xffffb5519000, 28672) = 0 munmap(0xffffb55b7000, 32880) = 0 mprotect(0xffffb55a6000, 61440, PROT_NONE) = 0 Signed-off-by: Leo Yan --- tools/perf/builtin-trace.c | 101 ------------------ .../examples/bpf/augmented_raw_syscalls.c | 17 --- 2 files changed, 118 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 071e7598391f..543c379d2a57 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -122,7 +122,6 @@ struct trace { struct syscalltbl *sctbl; struct { struct syscall *table; - struct bpf_map *map; struct { // per syscall BPF_MAP_TYPE_PROG_ARRAY struct bpf_map *sys_enter, *sys_exit; @@ -1224,16 +1223,6 @@ struct syscall { struct syscall_arg_fmt *arg_fmt; }; -/* - * Must match what is in the BPF program: - * - * tools/perf/examples/bpf/augmented_raw_syscalls.c - */ -struct bpf_map_syscall_entry { - bool enabled; - u16 string_args_len[RAW_SYSCALL_ARGS_NUM]; -}; - /* * We need to have this 'calculated' boolean because in some cases we really * don't know what is the duration of a syscall, for instance, when we start @@ -3259,7 +3248,6 @@ static void trace__set_bpf_map_filtered_pids(struct trace *trace) static void trace__set_bpf_map_syscalls(struct trace *trace) { - trace->syscalls.map = trace__find_bpf_map_by_name(trace, "syscalls"); trace->syscalls.prog_array.sys_enter = trace__find_bpf_map_by_name(trace, "syscalls_sys_enter"); trace->syscalls.prog_array.sys_exit = trace__find_bpf_map_by_name(trace, "syscalls_sys_exit"); } @@ -3339,80 +3327,6 @@ static int trace__bpf_prog_sys_exit_fd(struct trace *trace, int id) return sc ? bpf_program__fd(sc->bpf_prog.sys_exit) : bpf_program__fd(trace->syscalls.unaugmented_prog); } -static void trace__init_bpf_map_syscall_args(struct trace *trace, int id, struct bpf_map_syscall_entry *entry) -{ - struct syscall *sc = trace__syscall_info(trace, NULL, id); - int arg = 0; - - if (sc == NULL) - goto out; - - for (; arg < sc->nr_args; ++arg) { - entry->string_args_len[arg] = 0; - if (sc->arg_fmt[arg].scnprintf == SCA_FILENAME) { - /* Should be set like strace -s strsize */ - entry->string_args_len[arg] = PATH_MAX; - } - } -out: - for (; arg < 6; ++arg) - entry->string_args_len[arg] = 0; -} -static int trace__set_ev_qualifier_bpf_filter(struct trace *trace) -{ - int fd = bpf_map__fd(trace->syscalls.map); - struct bpf_map_syscall_entry value = { - .enabled = !trace->not_ev_qualifier, - }; - int err = 0; - size_t i; - - for (i = 0; i < trace->ev_qualifier_ids.nr; ++i) { - int key = trace->ev_qualifier_ids.entries[i]; - - if (value.enabled) { - trace__init_bpf_map_syscall_args(trace, key, &value); - trace__init_syscall_bpf_progs(trace, key); - } - - err = bpf_map_update_elem(fd, &key, &value, BPF_EXIST); - if (err) - break; - } - - return err; -} - -static int __trace__init_syscalls_bpf_map(struct trace *trace, bool enabled) -{ - int fd = bpf_map__fd(trace->syscalls.map); - struct bpf_map_syscall_entry value = { - .enabled = enabled, - }; - int err = 0, key; - - for (key = 0; key < trace->sctbl->syscalls.nr_entries; ++key) { - if (enabled) - trace__init_bpf_map_syscall_args(trace, key, &value); - - err = bpf_map_update_elem(fd, &key, &value, BPF_ANY); - if (err) - break; - } - - return err; -} - -static int trace__init_syscalls_bpf_map(struct trace *trace) -{ - bool enabled = true; - - if (trace->ev_qualifier_ids.nr) - enabled = trace->not_ev_qualifier; - - return __trace__init_syscalls_bpf_map(trace, enabled); -} - static struct bpf_program *trace__find_usable_bpf_prog_entry(struct trace *trace, struct syscall *sc) { struct tep_format_field *field, *candidate_field; @@ -3627,16 +3541,6 @@ static void trace__set_bpf_map_syscalls(struct trace *trace __maybe_unused) { } -static int trace__set_ev_qualifier_bpf_filter(struct trace *trace __maybe_unused) -{ - return 0; -} - -static int trace__init_syscalls_bpf_map(struct trace *trace __maybe_unused) -{ - return 0; -} - static struct bpf_program *trace__find_bpf_program_by_title(struct trace *trace __maybe_unused, const char *name __maybe_unused) { @@ -3670,8 +3574,6 @@ static bool trace__only_augmented_syscalls_evsels(struct trace *trace) static int trace__set_ev_qualifier_filter(struct trace *trace) { - if (trace->syscalls.map) - return trace__set_ev_qualifier_bpf_filter(trace); if (trace->syscalls.events.sys_enter) return trace__set_ev_qualifier_tp_filter(trace); return 0; @@ -4045,9 +3947,6 @@ static int trace__run(struct trace *trace, int argc, const char **argv) if (err < 0) goto out_error_mem; - if (trace->syscalls.map) - trace__init_syscalls_bpf_map(trace); - if (trace->syscalls.prog_array.sys_enter) trace__init_syscalls_bpf_prog_array_maps(trace); diff --git a/tools/perf/examples/bpf/augmented_raw_syscalls.c b/tools/perf/examples/bpf/augmented_raw_syscalls.c index 4203f92c063b..9a03189d33d3 100644 --- a/tools/perf/examples/bpf/augmented_raw_syscalls.c +++ b/tools/perf/examples/bpf/augmented_raw_syscalls.c @@ -37,23 +37,6 @@ struct __augmented_syscalls__ { __uint(max_entries, __NR_CPUS__); } __augmented_syscalls__ SEC(".maps"); -/* - * string_args_len: one per syscall arg, 0 means not a string or don't copy it, - * PATH_MAX for copying everything, any other value to limit - * it a la 'strace -s strsize'. - */ -struct syscall { - bool enabled; - __u16 string_args_len[6]; -}; - -struct syscalls { - __uint(type, BPF_MAP_TYPE_ARRAY); - __type(key, int); - __type(value, struct syscall); - __uint(max_entries, 512); -} syscalls SEC(".maps"); - /* * What to augment at entry? *