From patchwork Wed Jun 26 20:36:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13713396 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 17DF2C27C4F for ; Wed, 26 Jun 2024 20:37:56 +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=xUgjNt0xneeMqPZ/Mwlp/Zt17wNAbGBqOmTw4fJjROQ=; b=H3L4TbiiIeya6ja68wqDZB6mAB OP80nuW3WMl2mVP3XIGsm1U9Nr7tDLEn2uXm7kTFYidPQ2y3VAOseVDgBmdwG1BcqmWeNnMoaxguk HrEOF/ONhbfeaJedQzcNyTQrI9Bq0RETwryQ7ISEjXKl4NNgfDiBs3HOQ7UV1HkQasmPNdknzePAc M0Yo+1PFEAAWUCs5h+66I/gOld/xIMfAtQJd7SXuhqKCENjkPOWygTJ+t2zM2m0HKqeWRiGPciNfe unpRi5QYZrkFH9C7etL93YQBXxf718AWvmZkDCOfgVYT5+BoSHvkT2gtfa9U3BRXaa+DXRXHH7Z92 UsXo9bFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZOh-00000008FfP-1m1p; Wed, 26 Jun 2024 20:37:43 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMZNu-00000008F8w-34lT for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 20:36:58 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-dfeff1ae480so13556521276.2 for ; Wed, 26 Jun 2024 13:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719434212; x=1720039012; 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=xUgjNt0xneeMqPZ/Mwlp/Zt17wNAbGBqOmTw4fJjROQ=; b=Hay+oN6/K6L8FDTP2ofGb1SalYTrVcwvvb3xaE9HP8w8y2uPhJMLlwWsYuOJ5rji2T eO/UnbkYG4Vtdi6LF6tzLRq3Uta5bAvKoBrySe1HcpXfJQqfCsiSzDiGccY2ryae+Pzk UdYAc0VG+TgsIt4Im0GNkrPiGclvS54PP3SYhn4wCq0urXktSAct7WGtE1ugt5dmOvpg T7G4hXF4YkJ8ADl4a3QqIdXzJWmpPl5ShBvafjgTiBLOyubp14FeTqfjzJZF6Xq2EM+M mxshaLZSsKFaLKxm9gS162i6wosr3B9FVdvqk4HvlQBXwLG/N4Xq6kWMqQMCkecZy07Y a+Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719434212; x=1720039012; 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=xUgjNt0xneeMqPZ/Mwlp/Zt17wNAbGBqOmTw4fJjROQ=; b=VczbVk2TKLrpL+kqfWqhnB/KSF9jUHWlp6gVHlU8XI9qjzJ+n6qIPv7mF6wvUm1RK5 MLbq5AKCpaA6Jq1UX909cO0LIkhvMG3k8hTQxZZOOgtE2WwXKTK9SAe0wSMO61VFt5vx 9FtaZnpEFhuwr4QePExp82hziMcmCTbh/EiTlpxOCBRP3Cic3jcygBw6VUOOnUIZY/ib x1UH1H0zjGwc4AsPIsG2pxtKeqQfh33Q3y+OcHAic6a+IJ12EQW69nKtGlbBzf7eUbHH OmcGHO0CfdDD0PFn8Buz4dVWbr+Kt+pjYjzAWDl/WzuI3xnpaCzSchwRnUO7pm6lPP8j WU7Q== X-Forwarded-Encrypted: i=1; AJvYcCVU/xXmNhJbuudTdrLV+uhSc5O8v3Pv1d/T5+CMYHzS2uV0T3DDuw68nC6ku9DXKWqVxt5r69QCjy+agDIlGhi+JjNXCmheZH/4YII3hlvLZlqyKh0= X-Gm-Message-State: AOJu0YzD+nKhlhSTfrELocj+rkyiZ2mfuYLqKe1z6B1TOGdHbvN9lZPo GHjnr8LV/aqTyKb9D31zAY6M74MT/6kYMtRK8pp8B5AIQG1YkMocCk84GpgKAcPW1RJhzWxi+3D h0v5DhA== X-Google-Smtp-Source: AGHT+IFkDSWMucqUyPP/weWWjzyS2QYWG8qQwQFISbqoPdxZMm5/69UxoFZkkGsqMZ6C+gcONv53ELx2EAOp X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:23a1:25b9:2412:56de]) (user=irogers job=sendgmr) by 2002:a05:6902:1241:b0:dff:3ec0:71c1 with SMTP id 3f1490d57ef6-e0303fbf483mr458676276.8.1719434212285; Wed, 26 Jun 2024 13:36:52 -0700 (PDT) Date: Wed, 26 Jun 2024 13:36:08 -0700 In-Reply-To: <20240626203630.1194748-1-irogers@google.com> Message-Id: <20240626203630.1194748-7-irogers@google.com> Mime-Version: 1.0 References: <20240626203630.1194748-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Subject: [PATCH v2 06/27] perf kmem: 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 , 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-20240626_133654_843300_97521B02 X-CRM114-Status: GOOD ( 14.74 ) 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 Reduce the scope of the tool from global/static to just that of the cmd_kmem function where the session is scoped. Use the perf_tool__init to initialize default values. Signed-off-by: Ian Rogers --- tools/perf/builtin-kmem.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 859ff018eace..b3cbac40b8c7 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -986,15 +986,6 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused, return err; } -static struct perf_tool perf_kmem = { - .sample = process_sample_event, - .comm = perf_event__process_comm, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .namespaces = perf_event__process_namespaces, - .ordered_events = true, -}; - static double fragmentation(unsigned long n_req, unsigned long n_alloc) { if (n_alloc == 0) @@ -1971,6 +1962,7 @@ int cmd_kmem(int argc, const char **argv) NULL }; struct perf_session *session; + struct perf_tool perf_kmem; static const char errmsg[] = "No %s allocation events found. Have you run 'perf kmem record --%s'?\n"; int ret = perf_config(kmem_config, NULL); @@ -1998,6 +1990,13 @@ int cmd_kmem(int argc, const char **argv) data.path = input_name; + perf_tool__init(&perf_kmem, /*ordered_events=*/true); + perf_kmem.sample = process_sample_event; + perf_kmem.comm = perf_event__process_comm; + perf_kmem.mmap = perf_event__process_mmap; + perf_kmem.mmap2 = perf_event__process_mmap2; + perf_kmem.namespaces = perf_event__process_namespaces; + kmem_session = session = perf_session__new(&data, &perf_kmem); if (IS_ERR(session)) return PTR_ERR(session);