Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2299218rda; Tue, 24 Oct 2023 20:44:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcRl4OaybSs+Ux4DYTuDkh+t8LxObYBgtoVNkgxEXS/4OtqN8P656iNZZcvTZT/Vsrudp3 X-Received: by 2002:a81:84d1:0:b0:5a8:204c:5c9b with SMTP id u200-20020a8184d1000000b005a8204c5c9bmr14086382ywf.18.1698205490951; Tue, 24 Oct 2023 20:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698205490; cv=none; d=google.com; s=arc-20160816; b=Sq9KTtMOmTb0FGThs7rCnvx+hwZ9TAAVkPL3PrUthZ3Zddxa9PCQhfUpsVmNZQANW8 /rhMmgWUY25FhlL3ZMTIBLwojU/Br1jB4SvEetPY7GYLn/JgXp9ZZbAH+e4JZPFx2vHB EDFBP2qjDDnq269rs22ie+7jzCNGdlQo/ViNq0FfK7R5Nh5u8y0FgxH+o68G+rTmLdY5 FLEwpeeCy/wUt373map0yGMFxGMg+GD0KbO208Ip4Ro23Kyix+khkBJpd32+vqlMZCNM lo7+fqq/HvA9WT0h8wASEfyY3mJEbpEJe/SyOSYLkf1AkRUxJV/V7Y20gcM2l0ZRYkCr q5Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=dXAzKvkf49LfpHocgTsA1yczF93G8HBB7kCYq64Or4M=; fh=Pbu1BQwhCOAA2d/C0IOLVYR5czI2/+Avx4u+s0uioL8=; b=MWtr+Cx7TyWXKNMk/HMTNAjQUiS5S2J40hnLGl7kWOuEIg0yG8w+673o940QEEdkqM gx7Xn2j18RbpAq3naKYZYLD/7YxWpH1kHIbODxjb4Qm7cPLaNMfK0AkW1dYm2zYp5ySM gNm2j1HQUujNrTosv96u6oscyDYj++PBtGFKqMi1l2ArZjJOS49PzMUnOZkAiJ/POhTg t3wghU42gd6sFYhDHi7rW+tVCuRdtid+//+wcXoLVeisXTJxPg8DSN6bwaeP15YQfNfT +Idzxr9ySbDN4WTBSHD9wUvW6Iw488ATnOiYQv4c+jLjql8kgrGKmM/VJ9uhopT3iaMT WhaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ElsKR7XA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id x145-20020a81a097000000b0058cda79ef9csi10113341ywg.106.2023.10.24.20.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 20:44:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ElsKR7XA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A56C280C3471; Tue, 24 Oct 2023 20:44:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232093AbjJYDnD (ORCPT + 99 others); Tue, 24 Oct 2023 23:43:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230093AbjJYDnB (ORCPT ); Tue, 24 Oct 2023 23:43:01 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F29C9B4 for ; Tue, 24 Oct 2023 20:42:58 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-507a085efa7so1575e87.0 for ; Tue, 24 Oct 2023 20:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698205377; x=1698810177; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dXAzKvkf49LfpHocgTsA1yczF93G8HBB7kCYq64Or4M=; b=ElsKR7XA3nVm9Ly+MeOdLL+ijvu82n+x1Dfjth4BBMTB4zAB2wFI56Z/wodh5tSqJp 2djBEn0I7NKaS054dssYhV074q12LVChvo0rgn0KcQuFIIbA82m+4SWNDTJUC8r7Fah8 8VFTkoEyuP7Y+NPCUA9h3Z8FPDFpmOzAzRm+pOEvVvWzwV0z19Pq/RnrkUbJ5+/n7yga L1uF94iX0XoY7mAfHsKbjcBPfU8n44R8OsYDzS/6xzYYNCswLkR9FPR2xCdTQJwtabHr C35DwW11C1Oab8xUvAQWdBYFMLXLJHh33HKObcr6RS6GBxn4yYD15moVmgvIjgcUMRvE baDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698205377; x=1698810177; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dXAzKvkf49LfpHocgTsA1yczF93G8HBB7kCYq64Or4M=; b=cRFtfILa2sZ+qdgoYLufoWYoFfbxlrNQAsi+mgb4GUzBQA95CnJWT2IKTdhbbrqmDt 4CnP2DBz8rcz0mANDP+8pKMtuF2rVInT0z+AHpcSGRAORZYTLr9KPULurld13bvZZe+o 0iUGEHVV4l6u9CePwHk9NsCfy/vZCChdZhKHw3AqBtgyhCe72XQY7Zsxk5pLdM9pPddy fazOgsMIYlua1qvllIbi9/UmrEudgvE8m8xDtNhtQ2vL2FfAVdBpvRrbGxJ2GpNb8NJ3 uhbI2Y5yzcrGhco420CPmbIJDeDVFATeY/fq209rqUmtlXYLGzMbKd2TwaG2/eG2y20S bfRg== X-Gm-Message-State: AOJu0YxroJx18k8RclBgxaXAVSDgYvxSvfzUuzEB8U/hakgcZJaN6xKc zCYgbGFRX6Q9RSss3G/xGvPjCrwn0a7eUOhCSry/EQ== X-Received: by 2002:a05:6512:3582:b0:502:932e:2e36 with SMTP id m2-20020a056512358200b00502932e2e36mr25286lfr.2.1698205376825; Tue, 24 Oct 2023 20:42:56 -0700 (PDT) MIME-Version: 1.0 References: <20231025003121.2811738-1-namhyung@kernel.org> In-Reply-To: <20231025003121.2811738-1-namhyung@kernel.org> From: Ian Rogers Date: Tue, 24 Oct 2023 20:42:45 -0700 Message-ID: Subject: Re: [PATCH] perf report: Fix hierarchy mode on pipe input To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 24 Oct 2023 20:44:48 -0700 (PDT) On Tue, Oct 24, 2023 at 5:31=E2=80=AFPM Namhyung Kim = wrote: > > The hierarchy mode needs to setup output formats for each evsel. > Normally setup_sorting() handles this at the beginning, but it cannot > do that if data comes from a pipe since there's no evsel info before > reading the data. And then perf report cannot process the samples > in hierarchy mode and think as if there's no sample. > > Let's check the condition and setup the output formats after reading > data so that it can find evsels. > > Before: > > $ ./perf record -o- true | ./perf report -i- --hierarchy -q > [ perf record: Woken up 1 times to write data ] > [ perf record: Captured and wrote 0.000 MB - ] > Error: > The - data has no samples! > > After: > > $ ./perf record -o- true | ./perf report -i- --hierarchy -q > [ perf record: Woken up 1 times to write data ] > [ perf record: Captured and wrote 0.000 MB - ] > 94.76% true > 94.76% [kernel.kallsyms] > 94.76% [k] filemap_fault > 5.24% perf-ex > 5.24% [kernel.kallsyms] > 5.06% [k] __memset > 0.18% [k] native_write_msr > > Signed-off-by: Namhyung Kim Acked-by: Ian Rogers Thanks, Ian > --- > tools/perf/builtin-report.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c > index dcedfe00f04d..ca8f2331795c 100644 > --- a/tools/perf/builtin-report.c > +++ b/tools/perf/builtin-report.c > @@ -691,10 +691,25 @@ static int report__browse_hists(struct report *rep) > > static int report__collapse_hists(struct report *rep) > { > + struct perf_session *session =3D rep->session; > + struct evlist *evlist =3D session->evlist; > struct ui_progress prog; > struct evsel *pos; > int ret =3D 0; > > + /* > + * The pipe data needs to setup hierarchy hpp formats now, becaus= e it > + * cannot know about evsels in the data before reading the data. = The > + * normal file data saves the event (attribute) info in the heade= r > + * section, but pipe does not have the luxury. > + */ > + if (perf_data__is_pipe(session->data)) { > + if (perf_hpp__setup_hists_formats(&perf_hpp_list, evlist)= < 0) { > + ui__error("Failed to setup hierachy output format= s\n"); > + return -1; > + } > + } > + > ui_progress__init(&prog, rep->nr_entries, "Merging related events= ..."); > > evlist__for_each_entry(rep->session->evlist, pos) { > -- > 2.42.0.758.gaed0368e0e-goog >