From patchwork Mon Aug 12 20:46:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761023 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 76028C52D7C for ; Mon, 12 Aug 2024 20:51:20 +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=GSnhy3Vr2qERdCmMnBMzUq3MwYF2csqFbHWhPN6IO30=; b=PNezMlO+UUBJggF4ABz2kHNNjh AW0ptO4cUieGq41L6KTrxM+ZlMqcg2iXJs14GYO1SBwH/khCYDxT9ZWUOuedPedGL0QR5tzWjAPFG PEczsfZoXIETyv/0c+848NBNvWbaqcUBtpI3tK+jp4+DsGxuyVWE7uYiSTD0Ng+FaU1Wr93CYROuL Qr1ygAs8qbglO51/HD7/KEzl+T+Cj6Hm9gKNqVtnuMZGoEIwIJEAAF6mONKlHBSs1BOHFtDz1tqi6 l+niJ3TkXjCFth0A7odl0r2ThdYmooXbWOMKjYn7XNG2PKhjfhJKVIv8DfOIllHpyUTGz6WRlk8xh Zf6JNVUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc0U-00000001Vi3-1Ln3; Mon, 12 Aug 2024 20:51:10 +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 1sdbx6-00000001UUR-2KWQ for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:41 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-66a8ce9eecfso77884637b3.1 for ; Mon, 12 Aug 2024 13:47:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495659; x=1724100459; 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=GSnhy3Vr2qERdCmMnBMzUq3MwYF2csqFbHWhPN6IO30=; b=X+RfK+qT+ZTEKxWJa4+ILWRWDpjecd6PTGi11DjuJYEjQJBT8j2XMKpIcRx+6lVHSs kTVhg6M4jYhFtVjpOfkw7UfpKzVgT3r9nahlvPOccAvG0nzZWleOJ5FX4NwpSGR6OQUL uG5pRyIrDIp/AYRyJEuS5O9+f4749lY6zDuum5NX5a7KepYaiB+WeyrAvg233yzBNxxN T20WRRF1sFIfUOs/lasexNe1tR/JoFJeegMdaEycVqr3n5DMZ/29QK+nOg8urRnh8vbw BedQVBOvDcZtSwMMwOxB2UvdUBCw7c5Jf7pLa2XRH7BKOHoGvnZpGyehWS0NdQJE396s eSPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495659; x=1724100459; 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=GSnhy3Vr2qERdCmMnBMzUq3MwYF2csqFbHWhPN6IO30=; b=uFBny9A87cnzpoZxDgOYCD8YhfL/X8OdD50eHn8EnP+T9O8I8UcV0pTYVQFaDwmM9m Ii2vimBYnsnqtwexPMt2W1tpfiwlGQrhKzGsuCyiSYU5PEMvS8WYzWfEtlbwBFYdZ+44 Ped98l7YWZOsdlwBgGkYTp3GDO3YGJ9gqQNahtIAL658KI0+6EwsLCPhKXEQVWRQGxR1 xxLBPBKPvbddhdBcqSqNOJJwfSEX6aX1m8VWplz3PylJuVhoRRRrS4/OjYGa+P53o4Ae jVECi5bPs8MsMTpF4w3rRrggP9EE41Bw+G7n08G2qfld97RqEr2i2ZoX2Itu+F7EpbMz 2gYg== X-Forwarded-Encrypted: i=1; AJvYcCUGzhEu/mOGvU1NdkoN4TvK0r3WeqpZSUF5X/FMvHnTh+r4riwOKiVvHSku/rN4k3gSh55q/F1d6HDxf1rPsUJR799YtLZDnBapjCWGhyOBrtFr3Nw= X-Gm-Message-State: AOJu0YyzJqb8tej56zWlBzpXKao2d56Ze/OGjQtGRAdzS6IkJ4FDXUgr gLfz/c+FJWPe6oMzHTIc+ykUII5z+m3upU+VuOkt2j0VAaFx+wSWaKnhiqWCc+Y8F+geFkayZUW Qn+AThA== X-Google-Smtp-Source: AGHT+IEblpJwdl6278PFoZ+5cEGAgnioMooSJ+8EN/KwaqJevyVV+yvBEdMZq1rxI0gSMePlMu8pFsWGn/7c X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a0d:ce01:0:b0:6a1:741b:b723 with SMTP id 00721157ae682-6a9ea8e5238mr117867b3.5.1723495658586; Mon, 12 Aug 2024 13:47:38 -0700 (PDT) Date: Mon, 12 Aug 2024 13:46:58 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-7-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 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 , 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-20240812_134740_646711_B0678780 X-CRM114-Status: GOOD ( 15.60 ) 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);