From patchwork Thu Jul 11 17:59:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1DF8EC3DA45 for ; Thu, 11 Jul 2024 18:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jf/366lvU4AUPtbGBpn9zhF7c/C+EcohgCe44YuCQ7Y=; b=Mnlx8gzsi8qUuHc5/62M1ERlYV 5TzHigfv9nGaksJALnxphvvdBlASAKGBNcWcJUpUBni2S2Y8jtD6skCM3RclXBUIAsujEtq7KC5gH tFb+0pEio83Nqg6dNbDDUItzNO+itFwI1Fd73Ppfe1j49o+xa2lSAhw3ifTrWhVPIHE6SI+eWTlwH 4RB0P5shLDuLgkHQ8ZNRZ7wkrY0g7ig3cOMqzO8oBNM7Gnmx1dRrDtlYhMy/6uEoZTu0wQvVrYuEK jIJMR7qq+LcK+rr+HcHd+NMqW8Y7EaVGIvBf4V/FtC8Bo+47/xNRuJv5WqVe0wGZ2TM5LomO82SYn ICJWnIWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy8Z-0000000ExXf-2PPL; Thu, 11 Jul 2024 18:03:23 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy5s-0000000EwDF-2lcK for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:38 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-65be82a3241so19001837b3.0 for ; Thu, 11 Jul 2024 11:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720835; x=1721325635; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=jf/366lvU4AUPtbGBpn9zhF7c/C+EcohgCe44YuCQ7Y=; b=qGH+0FEPRirPrmMZqovIy5PsQGpS4xxe6D2MWoFH1UuL2nnsVZoK2B3bvPTIZxira3 WZQ/NoiUchIXJkvrAAR0uOvgIg9V+EmRjOQVj3gzHJrqU5B9vofWM5xYNX4Z3MIZY6VV c5zQtDGbYFaLaV5LPH522YG4BFYDloj4Rm/+clnyhGG5RFrBM5bj21fVhGpQbBouFcQB T2nc8RDIitdh7LESUJsMjWkPWZoQY8vW2ecOYHv26Et9GBuJ5XYryKa7rTYCJiS3a0UT 0bYw+KgSAm4WfHsVsreGwn2anlgtU/wCq1AC5ylMIPiJ4qmevDCYcHAKsSn2y6O2cqA0 yIzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720835; x=1721325635; 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=jf/366lvU4AUPtbGBpn9zhF7c/C+EcohgCe44YuCQ7Y=; b=NFyviQxhps7kzUJNlw5KdDycw/SYLI7sSytg3BK3SJN4HednjPV9lADH76B/hqGUAx 9cS/URcbRtjSPqiMJljwoH6z8krf+O6holMvp31fxTtDCi5vYdp2iu8d+AjIShgWbIpV aPNlPSzNUZhZUhsUbnlKXKGS7ApwmxblJndRajts7TGjGPRa2DDS3cLIb/iI20eHtUrL +v78Y97E9P6LIq40EemDCZfWhJZOKeU8ZNROcJnUTgoeOF0nT5mLEupZKcdEVPpVgQQG vJwHCI4QSqMpe+l++36CHFdSTXfEO0SqtPZhNqrLDASa7gQyUUcBz+RM3Uk31n/29c7v lY/g== X-Forwarded-Encrypted: i=1; AJvYcCU06mvov3FbagYQ3Ws8KFp0dBpJM3YlQOS1N1E8LlzPuC5mJVOi1pqu54FqdDC1FYnNIvVfoaN7MpqW8n8iDu7uvTzx+KsH639LS00YCyQdt9AeJNk= X-Gm-Message-State: AOJu0YwvCZtafE7vrtkfPG1hTtd4Pi32ciR2pRgggtPjZn/xtvdLG/e3 NJ7Ptmdt97bfP+257ujHcZmIHiQwt3qSwsHfRNneaRSm9gbVHlsyHfLLxrfZ508LvCHCISSV/nL 6SmrWZA== X-Google-Smtp-Source: AGHT+IHgRRHzENtJjdaIKJzPMb2H1HDZVK/Rf4u2rJiQyfph07pK93KyOLIPHnJjFuZcvCLU340y0vsp3u3Z X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:3510:b0:64b:5dc3:e4fe with SMTP id 00721157ae682-658ee699c87mr1323597b3.1.1720720835320; Thu, 11 Jul 2024 11:00:35 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:50 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-11-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 10/28] perf lock: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110036_813750_4D382C9B X-CRM114-Status: GOOD ( 13.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-lock.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 6efa9d646637..2c216427e929 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1933,22 +1933,21 @@ static bool force; static int __cmd_report(bool display_info) { int err = -EINVAL; - struct perf_tool eops = { - .attr = perf_event__process_attr, - .event_update = process_event_update, - .sample = process_sample_event, - .comm = perf_event__process_comm, - .mmap = perf_event__process_mmap, - .namespaces = perf_event__process_namespaces, - .tracing_data = perf_event__process_tracing_data, - .ordered_events = true, - }; + struct perf_tool eops; struct perf_data data = { .path = input_name, .mode = PERF_DATA_MODE_READ, .force = force, }; + perf_tool__init(&eops, /*ordered_events=*/true); + eops.attr = perf_event__process_attr; + eops.event_update = process_event_update; + eops.sample = process_sample_event; + eops.comm = perf_event__process_comm; + eops.mmap = perf_event__process_mmap; + eops.namespaces = perf_event__process_namespaces; + eops.tracing_data = perf_event__process_tracing_data; session = perf_session__new(&data, &eops); if (IS_ERR(session)) { pr_err("Initializing perf session failed\n"); @@ -2069,15 +2068,7 @@ static int check_lock_contention_options(const struct option *options, static int __cmd_contention(int argc, const char **argv) { int err = -EINVAL; - struct perf_tool eops = { - .attr = perf_event__process_attr, - .event_update = process_event_update, - .sample = process_sample_event, - .comm = perf_event__process_comm, - .mmap = perf_event__process_mmap, - .tracing_data = perf_event__process_tracing_data, - .ordered_events = true, - }; + struct perf_tool eops; struct perf_data data = { .path = input_name, .mode = PERF_DATA_MODE_READ, @@ -2100,6 +2091,14 @@ static int __cmd_contention(int argc, const char **argv) con.result = &lockhash_table[0]; + perf_tool__init(&eops, /*ordered_events=*/true); + eops.attr = perf_event__process_attr; + eops.event_update = process_event_update; + eops.sample = process_sample_event; + eops.comm = perf_event__process_comm; + eops.mmap = perf_event__process_mmap; + eops.tracing_data = perf_event__process_tracing_data; + session = perf_session__new(use_bpf ? NULL : &data, &eops); if (IS_ERR(session)) { pr_err("Initializing perf session failed\n");