Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3770841ybv; Tue, 25 Feb 2020 07:03:28 -0800 (PST) X-Google-Smtp-Source: APXvYqzHLRGcUmECavQYekZSK8btVF9YL7wXZQ6kMt8PmdcL7ASIif8pm+FPU3NNlYfit/wXRblN X-Received: by 2002:aca:1a17:: with SMTP id a23mr3742296oia.84.1582643008488; Tue, 25 Feb 2020 07:03:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582643008; cv=none; d=google.com; s=arc-20160816; b=aH1bTrveRiTzjHBGyoul2nIyiWfGyqyZxOS3e3+RBiL1HjAZ0govzNMQTdAUJ6xapr Gl8SBgKDrjrIeGOHYRmQHTvYUy1bRcSrgaoxIZGnGHP+Uj5yCA2tMrMZGQZO6BP5hvnx IbYdcLlXWLyIIlLC09GhnWGRfyQL8icUoUQ7IbNfq4pXmj/5YMMtuWcGSZ+PyRP0wxGC WX5cR4s7yZnogsrXxrPIA+WJZ2tolaxV/QLtoK6dujZGNWM4iw4J6Gc6Tp8t33NS2In4 V15KtVDJhRB3y+Rzfw9yuQ+WMwojJsXIRQt+qIL7QjEKfLQtAlbqPvW7ue0mOO6vZs5Z uFkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:to :from; bh=gEAElKUjHtGyrZa3szzGMaTTKY9J/P89AD2QV2Qm20o=; b=fkbzeYWWeGHXhLCUsipRBOOr6952GJmfBXhHqthB5OGUylItgGJVj0qmzNpGhrrH5G qHVVLHNPAyJ3Q21cxAAoIuWKm66rA9M/M61A9yCEdct28fIusq1rZNZGKP/1c/QwxhHq O77EREpjdlYFABDFyM38MVENmToLv2bwF611yj2MxfjjO++Ho4hCjZnhezhDF7/Ou+BR KxkAQGHAAWtXWH1jcIsyubJ+5LcKNmMF14X6H57JCbD9mmszVmDt1wlYCBps4ai3UYwR l/S/GHNiUraJy7Hib0JbBxKg0PclMGg1MwXGxxkTy+YJGKJnAyMHR11odp11+SVjAHT0 xAfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si8233076ota.43.2020.02.25.07.03.10; Tue, 25 Feb 2020 07:03:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730854AbgBYOox (ORCPT + 99 others); Tue, 25 Feb 2020 09:44:53 -0500 Received: from mail5.windriver.com ([192.103.53.11]:39988 "EHLO mail5.wrs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730627AbgBYOox (ORCPT ); Tue, 25 Feb 2020 09:44:53 -0500 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id 01PEfvnc028868 (version=TLSv1 cipher=AES256-SHA bits=256 verify=FAIL); Tue, 25 Feb 2020 06:42:07 -0800 Received: from pek-lpg-core2.corp.ad.wrs.com (128.224.153.41) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.3.468.0; Tue, 25 Feb 2020 06:41:46 -0800 From: To: , , , , , , , , , , , Subject: [PATCH 1/2] perf: Fix checking of duplicate probe to give proper hint Date: Tue, 25 Feb 2020 22:41:42 +0800 Message-ID: <1582641703-233485-1-git-send-email-zhe.he@windriver.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: He Zhe Since commit 72363540c009 ("perf probe: Support multiprobe event") and its series, if there are multiple probes for one event, __probe_file__get_namelist would return -EEXIST and cause the following failure without proper hint, due to adding existing entry to output list. root@qemuarm64:~# perf probe -x /lib64/libc.so.6 free Added new events: probe_libc:free (on free in /lib64/libc-2.31.so) probe_libc:free (on free in /lib64/libc-2.31.so) You can now use it in all perf tools, such as: perf record -e probe_libc:free -aR sleep 1 root@qemuarm64:~# perf probe -l probe_libc:free (on free@plt in /lib64/libc-2.31.so) probe_libc:free (on cfree in /lib64/libc-2.31.so) root@qemuarm64:~# perf probe -x /lib64/libc.so.6 free Error: Failed to add events. As we just want to check if there is any probe with the same name, -EEXIST can be ignored, so we can have the right hint as before. root@qemuarm64:~# perf probe -x /lib64/libc.so.6 free Error: event "free" already exists. Hint: Remove existing event by 'perf probe -d' or force duplicates by 'perf probe -f' or set 'force=yes' in BPF source. Error: Failed to add events. Signed-off-by: He Zhe --- tools/perf/util/probe-file.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 5003ba403345..cf44c05f89c1 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -201,10 +201,16 @@ static struct strlist *__probe_file__get_namelist(int fd, bool include_group) if (include_group) { ret = e_snprintf(buf, 128, "%s:%s", tev.group, tev.event); - if (ret >= 0) + if (ret >= 0) { ret = strlist__add(sl, buf); - } else + if (ret == -EEXIST) + ret = 0; + } + } else { ret = strlist__add(sl, tev.event); + if (ret == -EEXIST) + ret = 0; + } clear_probe_trace_event(&tev); if (ret < 0) break; -- 2.24.1