From patchwork Wed Nov 29 08:10:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 171145 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp189170vqn; Wed, 29 Nov 2023 00:11:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHr+cEdqux8xMw92MChcT3/pR5pHnueh2twa7wn4RnWOapg4tqStVH/x/jIQBEnShGjEB1L X-Received: by 2002:a05:6870:819d:b0:1e9:bfe7:e842 with SMTP id k29-20020a056870819d00b001e9bfe7e842mr21620695oae.32.1701245460397; Wed, 29 Nov 2023 00:11:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701245460; cv=none; d=google.com; s=arc-20160816; b=nzQ+Nxv0qgfae9h0m5rwQr58qDvwvtZJkNEat+5P4GYzCCytf+PJWaWqPspRlxwhxF P766NSmrPOezmXksJivrvdJAeo8Wl6ksdNyJEjY7Yi/3imYWoKhsjVUSP05JEbOPuau2 zecxXILKZwKWH7P/ij4FRf1i5e7S0cojZnxEQwoO01kyjxcUKBHmJBmm9Dor42eE7r1q xr5rUw6sls1SrKipIQ1dpyoA/IyD2OXZI/ZAgAMdKrCaJzRFyvQ/HvEvevtpjjxrMPGN aoKIEDXvwYRkopCT3xGOMLwbILmqEQkB1pYoEGYkJt7zurpt8oLnwUDnWiWmBYBuY5IH EkJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:mime-version:message-id:date :dkim-signature; bh=cizzxjAOXVtNMhutvuRuFXeQ97rL+0eSPOInOH69jLw=; fh=OxO30iphCJ5T7Q0u7v9RAoN8TrpFE3bNOof1u+XBh30=; b=lrKZRpMz0IQuqtazYkQH9hbCa9qWWPVpxDnCroO/1tiL38jSqDMMGpQwT54Fvedrnw WDxJCmbuQ95YfLSAumolrgGkSWEfIKnlZ196ExkxjqOQU3Lgtg3EaIEn+FZJAWtbxNw/ F2I51KCqSAR7gunZakGg1okwt7Qjpz0vKNbZGkeqKfQIllrjNnlwZdZiIsfB3z4kj9BP U/hczPjd04eJlhEcMWTHpX9g3RhhmJFRo8VSaZoVdNoNL/5+gCNwv2EE6rJWDkg6KSVh RaxWcBVVXjixCwlM4dUpFqZkZqTZIYWpeU23W5ZDERHVYVNtvmfLqtGhCRHVgVRO3eXt qQ6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="X/snFXEy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id e12-20020a656bcc000000b00588fa0def2asi14108000pgw.778.2023.11.29.00.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 00:11:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="X/snFXEy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 38172807AFD1; Wed, 29 Nov 2023 00:10:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbjK2IK0 (ORCPT + 99 others); Wed, 29 Nov 2023 03:10:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbjK2IKY (ORCPT ); Wed, 29 Nov 2023 03:10:24 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B491D1990 for ; Wed, 29 Nov 2023 00:10:30 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-da39d244087so7772996276.3 for ; Wed, 29 Nov 2023 00:10:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701245430; x=1701850230; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=cizzxjAOXVtNMhutvuRuFXeQ97rL+0eSPOInOH69jLw=; b=X/snFXEy8faZNX6QoGJzhEUbNV1WjZARbZDPCvqBThRN12rlcWhd6juUuU6E+vfzIF HDnaayxQuUF+Wg33rLzJp0HqET17oiK+ooFXT1yuMAzRpaUSIpAwy71YUDItnPoNdh9T zVpN+dx/k/AY3od4+skeLV+Dv3aOsP0PGgniJTo5cvZU2RmfXGZRJgTs1y6szv57iXsj kYThJ24xeEQVP4oG979Pe/oPCrj5/8mHHO/nRFYIGRh6cqVG9y/ZxVlxvWIeetXt9qNC 1q9m9mUF1pCKhbIY3iAntfnnQBzOIHX5QfWv8JNc8DstLN72noFnuMCUiV5TSpzsMoTz lxLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701245430; x=1701850230; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=cizzxjAOXVtNMhutvuRuFXeQ97rL+0eSPOInOH69jLw=; b=dV5iDfYEE5+ZKWtGYWQr5v3oDM6OaRUKV64H39Ogk9tvVw4UQTQD9hobeIjxoV6x5L mtgvvOo00GYFW/zHv+/fu6AODsH6SmRxRpCNdlzaMxbxQ0G/a/M66Jnoa1Yt6L4vIuVp G3C+P/9btHnd4vjHZDeKtJFXh1lbgauZBHPZDtUxIo2SBvMDLn6Tcexxwsk0ZLyNsZIo TousI0ySWkJ+0wdYJ2c6BBYcq+2uIc7YYZWt4oB9RFquJZXQdA/CbFSyc0wxHvXQvKOC MxQiggeaHPZLa93nsVAXBfM750KLI795M/CRdNzsJygmxmGYjj2EeLrATLd77pldJyi/ /pDg== X-Gm-Message-State: AOJu0Yy0NotXAzj2w1ZOxaN5W1FPa5Q4pw/BpZYOAG3Voo03Jrd+S6n1 h8SIbeyrl6XDL/LroQCBwpF6E9kwmb9V X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:763b:80fa:23ca:96f8]) (user=irogers job=sendgmr) by 2002:a25:ca04:0:b0:da3:a91c:7356 with SMTP id a4-20020a25ca04000000b00da3a91c7356mr440438ybg.8.1701245429912; Wed, 29 Nov 2023 00:10:29 -0800 (PST) Date: Wed, 29 Nov 2023 00:10:03 -0800 Message-Id: <20231129081004.1918096-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Subject: [PATCH v1 1/2] perf list: Fix json segfault From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kan Liang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Wed, 29 Nov 2023 00:10:35 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783885159539027759 X-GMAIL-MSGID: 1783885159539027759 Json output didn't set the skip_duplicate_pmus callback yielding a segfault. Fixes: cd4e1efbbc40 ("perf pmus: Skip duplicate PMUs and don't print list suffix by default") Signed-off-by: Ian Rogers --- tools/perf/builtin-list.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c index a343823c8ddf..61c2c96cc070 100644 --- a/tools/perf/builtin-list.c +++ b/tools/perf/builtin-list.c @@ -434,6 +434,11 @@ static void json_print_metric(void *ps __maybe_unused, const char *group, strbuf_release(&buf); } +static bool json_skip_duplicate_pmus(void *ps __maybe_unused) +{ + return false; +} + static bool default_skip_duplicate_pmus(void *ps) { struct print_state *print_state = ps; @@ -503,6 +508,7 @@ int cmd_list(int argc, const char **argv) .print_end = json_print_end, .print_event = json_print_event, .print_metric = json_print_metric, + .skip_duplicate_pmus = json_skip_duplicate_pmus, }; ps = &json_ps; } else { From patchwork Wed Nov 29 08:10:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 171146 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp189368vqn; Wed, 29 Nov 2023 00:11:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/XZni3m+NmZnQ5eUq+1mat5NoNVNm5O3/d3p18EvKMqZYQIKSKFkdIsGnyFq3G4eGYLM8 X-Received: by 2002:a9d:6b18:0:b0:6d8:2883:cb5a with SMTP id g24-20020a9d6b18000000b006d82883cb5amr9641162otp.24.1701245486915; Wed, 29 Nov 2023 00:11:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701245486; cv=none; d=google.com; s=arc-20160816; b=vnc0p3I1rshX/bWioEbTZQdmwYMI/Tlv785l+5k8IXC3fS/rTtL1ccEt5bhpx9QgUL WoQm9YqUdIESZmOgJ74nOH2g/JyVkBk1fCo/PyLw6Z4aQ0rQrZGaNVqzFGUANeWhkNmT BIk/oGgHjYdhsSPNkdlVk31oYw8g+F4y3Wdu56AdnvdHtTskE+dkJLRUvsGZO87jtS+3 5zlGHT+XEFGMbpO/a8AzXfhRo/lUfmiRiZgFky+euHg8yrxYgETUPLBd8C5K8jx2KzCY eKGqJp9rtp2d+PEXnsa3etuLff976RGtZxFdz6IhBfBYp/ihvu8941fk6LpXGSihiRJE i70A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=pfx1JC4eBOGrcYnY6xicCWpxUTppoeccvNEbp92VzIk=; fh=OxO30iphCJ5T7Q0u7v9RAoN8TrpFE3bNOof1u+XBh30=; b=P2OKT460pIg2OL6laZEYBoXtaL/2BehDIBIDLvkX5GXhqVV/qCSLCDgjimjk04lJMg RCI2j6wGRNKat/2JIch6m0PnnAzqA4FFTfLl9fCJsCg5NxH2Kwga3z1xSfxz/MpU/nQH kNELXxWcaozQw04x0jVvOhPezR6Xm1q8ztEOYaUFMrkXS+o+t7wGp5nqwpZaSgUOT3xC pWmFQVYfOrAqw6wt6Axhfner7LTX8w0yZlgoKsr7g9kHL5QCyj66irxa+HQuxyW/b09J 4FdyByjZNVMkRY5h1jteiqZfP9YXH+w+MrEZuqXqW9f5I/wahKaTyhof1OZE8C5hWWY3 sOzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=c1+LsFpW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id i27-20020a63585b000000b005c602ff4068si1240201pgm.438.2023.11.29.00.11.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 00:11:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=c1+LsFpW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 59CED8077FFF; Wed, 29 Nov 2023 00:10:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229517AbjK2IK2 (ORCPT + 99 others); Wed, 29 Nov 2023 03:10:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbjK2IK1 (ORCPT ); Wed, 29 Nov 2023 03:10:27 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEB5F10F0 for ; Wed, 29 Nov 2023 00:10:32 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5cd1172b815so5415367b3.0 for ; Wed, 29 Nov 2023 00:10:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701245432; x=1701850232; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=pfx1JC4eBOGrcYnY6xicCWpxUTppoeccvNEbp92VzIk=; b=c1+LsFpWXVZa9f0P5WSJVas0Ky1Ns9z08OWReCQPUx8UbCCItqqEjvqKl9VaEWy/T8 +KVwuU6p8GeqL84vzu9l2ePUgs154JheZQq+kFRA6eb0XGF5SQqR0fKtljCEUlxCO4mn D4n8LB1H18QLEMUBV05lbnVllpkBtSl++Ankn+zpMLqLcPQw8UfhBeVdNAwdhXCe45ex bEN5J6Fx4j9jRZ+mKczV96Bz0+gYWgXpqBsQAdNXYxkeg+mJLCuCUnULQ0Y28bc4K4rF dJ4RyLAfPIzZ79PeyQ1kmBlcAId4DIzHFFuVS2qe4AzRYdC1nBJDRbe2b4byUD/na57w HnVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701245432; x=1701850232; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pfx1JC4eBOGrcYnY6xicCWpxUTppoeccvNEbp92VzIk=; b=hemnjsavLDh1k1cGvt7WF4Qo9y2Afvaubd8AZhQxelFQFnBgHpU+KL5HmsxwsC/3mz ghqCHhLFOc7ahYCQZtKt35mJ/S/rM79Nqzxp/JlHFeqNypqZSYBVNSuvF3lsF0FQC7FN CeApoZKOpyLCSWECnaSZJqLGvE2ugEo+sAg0+YJp/kcIE9fWnrXWGUL3HNhOUw65ehPj xZ8Y0uDcgTpZp0dlkjcQIEjAgLMkA6yZ4w+2z+tDupe/2J0G2hklYh07QsZFx/aVqrfU UshjcdFqW3o59UWZOGB/nCh9/L5kRqzgGRBj583x6YLbHb2wMAEw/j5knnHBBml0eXdi 5wSw== X-Gm-Message-State: AOJu0Yyo5WIXu7wvCgKQfLgEa2MJESetnkdtXZvysBbUyrmnbY+LrZRZ +67g9S7caoLQ42JCoTDocPMBahnRbdBe X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:763b:80fa:23ca:96f8]) (user=irogers job=sendgmr) by 2002:a05:690c:2b0a:b0:5d0:8fb3:559c with SMTP id em10-20020a05690c2b0a00b005d08fb3559cmr253486ywb.0.1701245431941; Wed, 29 Nov 2023 00:10:31 -0800 (PST) Date: Wed, 29 Nov 2023 00:10:04 -0800 In-Reply-To: <20231129081004.1918096-1-irogers@google.com> Message-Id: <20231129081004.1918096-2-irogers@google.com> Mime-Version: 1.0 References: <20231129081004.1918096-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Subject: [PATCH v1 2/2] perf test: Add basic list test From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kan Liang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 29 Nov 2023 00:10:47 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783885187789756462 X-GMAIL-MSGID: 1783885187789756462 Test that json output produces valid json. Signed-off-by: Ian Rogers --- tools/perf/tests/shell/list.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 tools/perf/tests/shell/list.sh diff --git a/tools/perf/tests/shell/list.sh b/tools/perf/tests/shell/list.sh new file mode 100755 index 000000000000..286879a9837a --- /dev/null +++ b/tools/perf/tests/shell/list.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# perf list tests +# SPDX-License-Identifier: GPL-2.0 + +set -e +err=0 + +if [ "x$PYTHON" == "x" ] +then + if which python3 > /dev/null + then + PYTHON=python3 + elif which python > /dev/null + then + PYTHON=python + else + echo Skipping test, python not detected please set environment variable PYTHON. + exit 2 + fi +fi + +test_list_json() { + echo "Json output test" + perf list -j | $PYTHON -m json.tool + echo "Json output test [Success]" +} + +test_list_json +exit $err