From patchwork Thu Jul 18 01:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735900 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 65BEEC3DA60 for ; Thu, 18 Jul 2024 01:04:01 +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=+bihPZPBGJ6d8qN0fHDZAaoj4FmhnLovUYATiB5ueYI=; b=LYGHNkUXevQ2fNAOQmF18X9nKy 6IJYodixr3tPv6ksk/bPrMNVhSU/itBCUBXMKdSgc5pDSNkWx2FGcjTGpB8lGMxn8o22CNr6KYW77 n27aYAWOcOh43slWUnDU9tS7sZLfT70D6f2z/Z4JIzd9wb2ZCzC/s9RkoZprs7eE/ywbQgoH6EoZU ivwaP0H6hTRDw4zu4kLd6mWSWTV5OVMi6xgdx0Wir31f/B2PxpsoqK6TfK34SYQ31meNzMaozRqLa G5Qv6mJTLRSU4H9FtT1K/ebJevvRqcOVf5M7sj3oLQJup+RkvfGBEc04A9XcUXdDpYY5LTaWfRoOv 7fFfT3BQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFYg-0000000FKmp-1Q6k; Thu, 18 Jul 2024 01:03:46 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFVy-0000000FJYw-46t3 for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:00 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-66480c1a6b5so7330497b3.1 for ; Wed, 17 Jul 2024 18:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264458; x=1721869258; 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=+bihPZPBGJ6d8qN0fHDZAaoj4FmhnLovUYATiB5ueYI=; b=N9k05I3OB3oH1N3VaEVYDd1kgPT3rAJrCCwFUf9vcp8hDb//weLRsW6o76Hp2BxzJw JUscW/NIhI7wq51WGL+xfqUIXWAG7Zk384BTZGB+JYvgoUK3zAkh++OuxXySaz/G/VJO QVn/Y/CZJTbgyTebyHraLuSZYda/HVp2jUV1Lrvf4xJyZ5p5bY7A3+b3j8dKByjqUBDB Zi/KbYZAqictWOo8VnO9UjhSspvnzu6yjj2/2d27pC7msRwWf49QbpTQc3TpR6l/JRHJ pct3KJBPh7j+ynKQiIsCrknLDaumeoNlosB2OABQ8kX3MoOR1nCzD6b5HOTeMJIUUPeF /D8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264458; x=1721869258; 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=+bihPZPBGJ6d8qN0fHDZAaoj4FmhnLovUYATiB5ueYI=; b=BDXE5+32eT2hArfnumDmvmLoRALAA4zuF6S9iwyjCrs2xRczqmbOCkl3vaM6G+F4Dr 3QfUUNMX+L9xxojlJ65vabhh21OdaRLNNCI9Q2JiSz72ebhRYAfL1R4Nvux2xMT9Fs8q AR+q8e2Lfopr+pdu0KKYfNgXMk5DjfxT7nrWCbyzBhPIF9+xU2a42e0jvalb9639YAim 3hn5YxmIveKkgqF8Zr+zPEHAPKVbdkbV9MmtOsySt4HvWOtyiF+uJgg1vRnMo1wkaXG+ MbQxWjdI/YXDDoSI/aIBHAp0YewYEDBCvHGTbYrWkAU+7hmIE91et5YdBCuatjLMtypm khuA== X-Forwarded-Encrypted: i=1; AJvYcCXxfC8aNN5nnsQuCsIgbu/igkYW2UswVqlDn18HKAPJpL4UMlIzGLbm87vR9BEyKW+cQ4Z2y0Oh4LvVEcekoJ8hnM1UJPycXQR9E3Yjqg3J6M7dkZM= X-Gm-Message-State: AOJu0YzV9LcB3kVvDZ8DhNDrQumQsKa9kzUCR7BXOBhdA6qiXDct/gsv 8iVAqQvRiay6X9x58hJMpsmaKnk8wxi4L3kYeZBX1ItgeXdt9x9Xml3NGJeKVwgHDQRFCblunrs 8TABWjQ== X-Google-Smtp-Source: AGHT+IGDEF3uZXg4slq61N/gjbSuBnIZfH69MFL5bkSpRqZ+m4jNhYliSi0lDnLt9dM73d7tpplzPVLMX02w X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a81:ae04:0:b0:64b:a85:e2c5 with SMTP id 00721157ae682-666019e3b2amr337027b3.3.1721264457820; Wed, 17 Jul 2024 18:00:57 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:05 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-10-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 09/27] 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-20240717_180059_050570_0863EBB8 X-CRM114-Status: GOOD ( 12.88 ) 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 Reviewed-by: Adrian Hunter --- 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");