From patchwork Thu Jul 18 01:00:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735910 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 8DAA4C3DA60 for ; Thu, 18 Jul 2024 01:07:08 +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=m98Flvn2VBr3LNYvnCJEqVyEBIqxTtcaN90lyN420CY=; b=KZFlETrY69RvoCZDyI7fTL0KJw mzFN7DrzOIUpPY84Fk62Budeq3NwDep6Sf/g1rAUn2ZAr7YnE1v4KwNG1Keha0DEYrVctbgER0U7z YFc3xEeueJcScRKYC2iPyh8agsz+W+jr3VrWUKxdnzRnCUWIlsin8zZgC/holgre+hnA6CiR63qTc QZCidQeJXyRFN1OJWsFupVYexnq6muGYnUdSF8wSNcIGWpumhv4Njo5T8STpJXcog4O04UCQHi/M9 M+Drw68g80ZOtWo6iYntY50MWETNlDCNQiLZGiexhDCl6pAfaGB5RRYx09BhUCQCHlAy6YY4wsgjZ ijgl42pA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFbj-0000000FLyH-2NxA; Thu, 18 Jul 2024 01:06:55 +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 1sUFWM-0000000FJm3-36zt for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:24 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-664fc7c4e51so5221817b3.3 for ; Wed, 17 Jul 2024 18:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264481; x=1721869281; 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=m98Flvn2VBr3LNYvnCJEqVyEBIqxTtcaN90lyN420CY=; b=a//8xifOhNwYz0/kQ8U12WndP7hZAr1k479zdRQubEvpNjPRbeMcBA81jjL69FMRGM 8IlcciJ2xoO6h+UuGEGjW70xKGnV3DWLf9huSVnYgAmyVNRT2XyNusNjL6BRyoqEFM5c p0axyiCAR1tQTztvXkpu8MLgygAhtBvMLW/vbdrjlY4X+pij5NKYQSG+uWeEUVL8GYgi 4vOydJ5Sc9OccioxoqL5Mfy/wrDj4TZbOAzIWhfhLP5g0YJp/nP//VOj1fyzHfWQGx6l H+spBUreoMfzraTugSqSuugwKMWnk2tB+IrY418CJBGgzO3W+8l5ibZsP5ytNC14LAmJ RCCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264481; x=1721869281; 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=m98Flvn2VBr3LNYvnCJEqVyEBIqxTtcaN90lyN420CY=; b=uJTdeNNS3pen9GaFsNqSoa7epY+zClXXGwmgu+FM/8njEkBZTLbJFcPXrse+6oTYvl GztycWiItaU0xKsZaIMgTli3k1+/E1ozM/x2oiZTPqitrj0IOQo7ktUfLF5BHG4G9FPe H7saAVmrbcwwRXZLQS4uHPCFD0Ys+DMl466a1j80ltHXPg4fx74B3b05MbmMVDuFt+10 kcUbAVLfya38EHj+rEU0pF+DoAIx1RJCf5btm5xkyMPszUntDRtBIv+lYzp0JGIl1uLU 4qIVzcl8Wv9BqWpciW7yh6RxTsvSkE9vSVIluDD5KPnLLwHw+lk4g3Zy+zX4iwiIadCg 7c4Q== X-Forwarded-Encrypted: i=1; AJvYcCW3LnVJD43xcWWNYZfzxoUlKp8koJE6BvB7iKH2q8ilF3nKmpO7hSp9oXkQcKoRyNDJbta1piOrd+id21n/ExPY9NWpE1ofE/koTMh7htKg4keQNa0= X-Gm-Message-State: AOJu0Yzp32GKfjpDC2su3JMIRO7iH2VMuiGlUjVqal6kh5O8HwuO4KOr VDLQ/7yhz9c7RW+C4yKpHFNsQ3mfI+KdDeXQX56t0EDW/i3zsSwofzLYyRSRbA2sTSNSSKI4YID cJ4tC7g== X-Google-Smtp-Source: AGHT+IEWEjgKHZq/295YiLw+T2zNbbynCG/+Of132DZ6uzEmgnVr1Fi3xV7AcLhcv2Pa2K2jMXGhS06h3I/A X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:fce:b0:666:e184:4dfe with SMTP id 00721157ae682-666e1845003mr139337b3.6.1721264481114; Wed, 17 Jul 2024 18:01:21 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:15 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-20-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 19/27] perf mem: 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_180122_806872_F76D1B6E X-CRM114-Status: GOOD ( 12.56 ) 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-mem.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index c2038a32543c..c12ca0ec1237 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -285,7 +285,23 @@ static int report_raw_events(struct perf_mem *mem) .force = mem->force, }; int ret; - struct perf_session *session = perf_session__new(&data, &mem->tool); + struct perf_session *session; + + perf_tool__init(&mem->tool, /*ordered_events=*/true); + mem->tool.sample = process_sample_event; + mem->tool.mmap = perf_event__process_mmap; + mem->tool.mmap2 = perf_event__process_mmap2; + mem->tool.comm = perf_event__process_comm; + mem->tool.lost = perf_event__process_lost; + mem->tool.fork = perf_event__process_fork; + mem->tool.attr = perf_event__process_attr; + mem->tool.build_id = perf_event__process_build_id; + mem->tool.namespaces = perf_event__process_namespaces; + mem->tool.auxtrace_info = perf_event__process_auxtrace_info; + mem->tool.auxtrace = perf_event__process_auxtrace; + mem->tool.auxtrace_error = perf_event__process_auxtrace_error; + + session = perf_session__new(&data, &mem->tool); if (IS_ERR(session)) return PTR_ERR(session); @@ -449,21 +465,6 @@ int cmd_mem(int argc, const char **argv) { struct stat st; struct perf_mem mem = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .lost = perf_event__process_lost, - .fork = perf_event__process_fork, - .attr = perf_event__process_attr, - .build_id = perf_event__process_build_id, - .namespaces = perf_event__process_namespaces, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .auxtrace_error = perf_event__process_auxtrace_error, - .ordered_events = true, - }, .input_name = "perf.data", /* * default to both load an store sampling