Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1363766lqo; Fri, 17 May 2024 23:14:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9IM4808jJNtV20LPSUdzSpybU1FjACJUHTHSZyk7wQzCMEg5BvVKEaoAD3cjLYE8ljhUUm3ZXccVkosRMu5rop03iYtGPV6t59b9Mbg== X-Google-Smtp-Source: AGHT+IHUccZ7BHtJKWPRbRCSUGsHTqwWKRACaW9kl3D06DQUIB7u6LMgvGGkZ9ehUVA5xf+vHnam X-Received: by 2002:a17:903:32c4:b0:1e4:2879:3a38 with SMTP id d9443c01a7336-1ef43f51f37mr306668695ad.47.1716012887758; Fri, 17 May 2024 23:14:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716012887; cv=pass; d=google.com; s=arc-20160816; b=PIN25qXp90h86FcpfY5N/3xktJiPv0Q/ow3Ge1WX5eJ3Ywsb7Nhd08osyMnkEpUXKA HObzu0RV4mEA3kbXEMd8CCUWH/efQGHA/yokEjjSXS0Vx7fnsCDeTjEPXS9wG9BLMagk tS2D05v/AbInJzjrkmWn2u06tJqIhDVcIYjg3wxUkPz2Dj1QItZ5Smk3gp9s/DM+J5St 0gNoXg/lnEqnHtdIhNjpkWrOTL2LZZjMk53fFt7F06DsoP0KWp+hntj6BPC++V7fvp5X J4EZdFqrXQkcACg4paBwRKUcthxB7La1x+86dlL0iwGspEE1x7qvZuMPSbvilzLLKKRy LgdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id :subject:from:to; bh=QuZm9GTXDOaBQyLMScAprc3hijkD/J1kwAVTRQQmuGI=; fh=C1j0UlX0SvZQJnFQuzuN6HwLhD/OI/kg3EnSvQbQea8=; b=EF+yPnaBcXgunvmkUHLAPMUEmtKacwo7zTA+xOd8EEai935L1HJANFqzXxBqgimW5N zG4ZQLn648gJUDltLNqepapF/IBORE+x22Ybo9yjZM9fk0Wm7HwlhfpKAgh+DLplBkVA HbJdtBUwm80TDf1VChNUElL4/Q07jx0QmVWu0RECE9a1/TkFlvmrPuXjbLrOSBT0/+cn RnBueDq6jC83l/Xsh45IHBB0cxAsw9a2R/bw0rAKbQLSo24TPNQtAZWSBX0vfeyyC+0o 0f+g17wnHpNZyKSZWrSrMe4a0T76id57zQ6YbGC+4ZiAkQNY1cVODF4Bzmo45m01ut+D wduA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=loongson.cn); spf=pass (google.com: domain of linux-kernel+bounces-182781-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182781-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c269c8csi37701205ad.585.2024.05.17.23.14.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 23:14:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182781-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=loongson.cn); spf=pass (google.com: domain of linux-kernel+bounces-182781-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182781-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7A84BB219B0 for ; Sat, 18 May 2024 06:14:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2FCA6BE68; Sat, 18 May 2024 06:14:36 +0000 (UTC) Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1FCEE8F44; Sat, 18 May 2024 06:14:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716012875; cv=none; b=WHB/1//n9zEylrwF6g09M699KYxoGYmcH4T24LIAvQtCYqpVIbawn7v49c0/C0XTU1lcpq1M6BNxGoEjLg1Gj9PnmTLf3nazDeP5n12uDOEdJljnQtNKoeVQGmpIzmwWOETc37kqU6wsjdBLbMDk8aWRHtbqIDREcmj3Y/jb7nI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716012875; c=relaxed/simple; bh=7AWQZ0E7xEqFD3ZduGzUbfk7ddpl4dqsvVPkuMElqg8=; h=To:From:Subject:Message-ID:Date:MIME-Version:Content-Type; b=J0ybsolKnuAG9D+ieEOP5sxjspyng/D7AzerwIqXuDgRjFRTVp/Y4zPgbBv4BwngPpEcHIvA9PrNPXrVaO+dzmaSxfBlePFENkFpXyNjJYiyMI/R4fphfHd7iW8N2ydg5HQgAJtuMSQ4aHSwOZrViHqsNzGJWw8DoBla7C97gXM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxherfRkhmgUkAAA--.1408S3; Sat, 18 May 2024 14:12:49 +0800 (CST) Received: from [10.130.0.149] (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxTt7eRkhmj_QAAA--.5908S3; Sat, 18 May 2024 14:12:47 +0800 (CST) To: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org From: Tiezhu Yang Subject: Question about "perf list" Message-ID: <4b101d3d-e216-0a43-30f3-19ef20c0522a@loongson.cn> Date: Sat, 18 May 2024 14:12:46 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID:AQAAf8CxTt7eRkhmj_QAAA--.5908S3 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoWxWr45JFWkGF4kKF47Ww47ZFc_yoW5AF45pF 4rArn3tw4xXw4UJ34fAFn5ury3CryxCr1fK3WDAw4akFyFqFs0qFs2gr15Z3W5Kry5G3ya qa1j9r4ktrW8XFXCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUv0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lc7I2V7IY0VAS07AlzV AYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jrv_JF1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r 4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU1CPfJUU UUU== Hi all, Please let me know whether it makes sense to do the following change, if yes, I will post a formal patch after the merge window, thank you. -- >8 -- diff --git a/tools/perf/util/print-events.c b/tools/perf/util/print-events.c index 7b54e9385442..9fa15b32280f 100644 --- a/tools/perf/util/print-events.c +++ b/tools/perf/util/print-events.c @@ -67,11 +67,12 @@ void print_tracepoint_events(const struct print_callbacks *print_cb __maybe_unus struct dirent **sys_namelist = NULL; int sys_items; - put_tracing_file(events_path); if (events_fd < 0) { pr_err("Error: failed to open tracing events directory\n"); + pr_err("%s: %s\n", events_path, strerror(errno)); return; } + put_tracing_file(events_path); sys_items = tracing_events__scandir_alphasort(&sys_namelist); Here are the motivations: I met "Error: failed to open tracing events directory" twice when execute "perf list", the first reason is there is no "/sys/kernel/tracing/events" directory due to it does not enable the kernel tracing infrastructure with CONFIG_FTRACE, the second reason is there is no root privileges, so add the error string to tell the users what should to do, and also call put_tracing_file() to free events_path a little later to avoid messy code in the error message. (1) Without CONFIG_FTRACE $ file /sys/kernel/tracing/events /sys/kernel/tracing/events: cannot open `/sys/kernel/tracing/events' (No such file or directory) # file /sys/kernel/tracing/events /sys/kernel/tracing/events: cannot open `/sys/kernel/tracing/events' (No such file or directory) (2) With CONFIG_FTRACE but no root privileges $ file /sys/kernel/tracing/events /sys/kernel/tracing/events: cannot open `/sys/kernel/tracing/events' (Permission denied) # file /sys/kernel/tracing/events /sys/kernel/tracing/events: directory Before: $ ./perf list Error: failed to open tracing events directory After: (1) Without CONFIG_FTRACE $ ./perf list Error: failed to open tracing events directory /sys/kernel/tracing//events: No such file or directory (2) With CONFIG_FTRACE but no root privileges $ ./perf list Error: failed to open tracing events directory /sys/kernel/tracing//events: Permission denied At the same time, maybe it needs to do the following tiny change to avoid duplicate "/" in the file path. -- >8 -- diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c index 30745f35d0d2..834fd64c7130 100644 --- a/tools/lib/api/fs/tracing_path.c +++ b/tools/lib/api/fs/tracing_path.c @@ -69,7 +69,7 @@ char *get_tracing_file(const char *name) { char *file; - if (asprintf(&file, "%s/%s", tracing_path_mount(), name) < 0) + if (asprintf(&file, "%s%s", tracing_path_mount(), name) < 0) return NULL; return file; Before: /sys/kernel/tracing//events After: /sys/kernel/tracing/events Thanks, Tiezhu