From patchwork Tue Feb 13 07:52:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 200251 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp383825dyb; Mon, 12 Feb 2024 23:54:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVcVHoFnTg4YThGbEYF8ZEYA4n1wNkT1NaUo9ipR8TsQyRaT60ZbhKRJ2qghIvFcUT3bFOLoYVwDPEEGo6b+oOwbVpKpg== X-Google-Smtp-Source: AGHT+IHpI7bnbLGfVCgnDj18mfIGauXsEIBVHW7OLuQBunrrdTd7fdOo8Xx30HWj27KNpPQJbQGO X-Received: by 2002:aa7:d1ce:0:b0:561:9d6:aa6 with SMTP id g14-20020aa7d1ce000000b0056109d60aa6mr5414894edp.41.1707810852713; Mon, 12 Feb 2024 23:54:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707810852; cv=pass; d=google.com; s=arc-20160816; b=gbrC1IYZGEbcSGp6PtIV311EqEAZ/24sthGe6Y3dHKdBoOBB0lvkhOyWbaOqQhVubN 4Y6F0NVcT+vZN+q8dG6cvk5oUZCV0uIWri4Ouk8ichmenr3RLGvXjnqtxWEbPC7qTc5H Jvs9uWmi761IWilw2DuJDWDGc+lEHFiANQnPiTjyp8waqognFKNjG6hoDKgFmE6ZKM1L 7F2OJo30NHMOVAnVUk0P+0Ia/HLLrDRrHy02e2/P8g07t2BDjqV+i7UOiPleixBuq1KB tLV3ttkAEsNkMpeSycrrOASbuGyWdsWflLyf9EHZcTqFfsMamgG8bgV4bHzj0LP4IxxB L2og== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jShWWTU9NHNLgi54yn4/SkseYjEWNIGNq0s5Njz5XRI=; fh=Tjt/cM9aDyYFrZCQEqFwPh8SBvAidaS8Wu0CcEibpS4=; b=C+Movi/BqmyaCqkQ4d1Qh6ImLYmDLBm0aMJ0Uqhauh7C68TnOWAXR+PgPdwXrT5M/p pyXkfxJziyrxvIcv+bViXlIkx+kdQj+t3rvGmuMQxxbbK170pMS4FikI0W4tzHqDSGLA VkEL12Z6IznWdP1eQzRP2YuVMqf7+7y/0baZK2oD+9EbOs92S2Dac+p4mYNdQpqA+G8F jbQKcD0KiNAaQ8YzQzY/n2S8a7uuK9RLnMcndUtwu+J1yb/Hl3lDUNOzExrWOqZfsNih 7qI5mhCwblbsCOQS+7AnMnRKQjloVpocqmN0rhlbLFqIfXbOkvKA3k2eicNp2VpaWmau fgHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g3dpFVKv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63062-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCVwhhoyHHEUbVdFH/MRe10TYkfI8OPK6EF76/Vs8Az19LkSP63t9gBt4ryKYmZmd7tTHAla2dwHq+jbA/3WYsH2lCFEKA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c9-20020a05640227c900b0056188e1a9bbsi2723814ede.508.2024.02.12.23.54.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 23:54:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g3dpFVKv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63062-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 37B431F22966 for ; Tue, 13 Feb 2024 07:54:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E30021A06; Tue, 13 Feb 2024 07:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g3dpFVKv" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FD7418036; Tue, 13 Feb 2024 07:52:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707810778; cv=none; b=DhHZhx+UVj2EAZ8xun6RN3/9ThdYbA8ai8zpr7fnfdPEZR3/9/PKCxVN5NFMXrWp6T6t2wrpjXpv0uebeUKwEq4eVHUAGQulhraa9IaE32jrOpBLwZ3qwnJyqWu9JFCqrVoL/aXw/w/Gc+9G4X3NkgFI5xC1fyaYdZWkhEAoE5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707810778; c=relaxed/simple; bh=sOy6KlficwKF5vE8HVBwVLDj0OcsjYyU8khFYs9JUiQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VqquY+QP88Dy9pqzJKwtNYyF7GGfI8hvQ0N/djndXBbxVvFDmmXdSTkHbM8FeaUd7vbgDDPR7xVJ2GAu132C1XNy8NXaCtiSfnJhejIPzGNIjEk4dNjeZ/mrfWLDNR39gVl1Th4oJRbPCS8hBjFe6ob25bkH3H+qMx3ERhoT4F4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g3dpFVKv; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F3CDC43390; Tue, 13 Feb 2024 07:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707810777; bh=sOy6KlficwKF5vE8HVBwVLDj0OcsjYyU8khFYs9JUiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g3dpFVKvINO5IweleyEFN/hEmQOIAzXGvkh7OnKH2x8GDDheWS9D/+vK4Tz0PXgt+ fAFAxgwkzfqpIf2tuIcZLaSD2ahUrfcv8rIBEcwASBzkD2Q6Rrx/BUT9iYtyJ4HMw1 9L/J2j4PzZ3x+w5K7oaKu8seXAVWfd9v64bwWuPOFB5h1nWiaMC5AJ80kqDUypo1Mi AS7YUtMaNMgvVxo7jjWMftJIsAKr+XntKtiddO+Bhk2ON66cpePHJ+GXAxTBPaRCno KZoz3IuA8qs5Xfk8SAhVQznCVRmoDlUg5TJ8BoSMLHQBmzLOLoWOrruiL36CABrxnQ +XgJBIW8OIFLw== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 1/4] libperf evlist: Update group info in perf_evlist__remove() Date: Mon, 12 Feb 2024 23:52:53 -0800 Message-ID: <20240213075256.1983638-2-namhyung@kernel.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240213075256.1983638-1-namhyung@kernel.org> References: <20240213075256.1983638-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790769472544142569 X-GMAIL-MSGID: 1790769472544142569 When an event in a group is removed, it should update the group status including the pointer to leader and number of member events. Signed-off-by: Namhyung Kim --- tools/lib/perf/evlist.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c index 058e3ff10f9b..befdb062fa1d 100644 --- a/tools/lib/perf/evlist.c +++ b/tools/lib/perf/evlist.c @@ -102,8 +102,29 @@ void perf_evlist__add(struct perf_evlist *evlist, void perf_evlist__remove(struct perf_evlist *evlist, struct perf_evsel *evsel) { + struct perf_evsel *leader = evsel->leader; + list_del_init(&evsel->node); evlist->nr_entries -= 1; + + /* return stand-alone event */ + if (leader == evsel && leader->nr_members < 2) + return; + + if (leader == evsel) { + struct perf_evsel *member; + + /* select the next event as a new leader */ + leader = member = perf_evlist__next(evlist, evsel); + + /* update members to see the new leader */ + while (member && member->leader == evsel) { + member->leader = leader; + member = perf_evlist__next(evlist, member); + } + } + + leader->nr_members = evsel->leader->nr_members - 1; } struct perf_evlist *perf_evlist__new(void) From patchwork Tue Feb 13 07:52:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 200252 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp383854dyb; Mon, 12 Feb 2024 23:54:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJj+v/C+n4B/1uVR4jGN0nPhxbiHMFayH74YFoxFzJNAxlMtD1sYAYqm1pPy37ixawWPLc X-Received: by 2002:a05:6870:b291:b0:206:6db:dff9 with SMTP id c17-20020a056870b29100b0020606dbdff9mr8508156oao.58.1707810857887; Mon, 12 Feb 2024 23:54:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707810857; cv=pass; d=google.com; s=arc-20160816; b=wejm83KAZ+eJfpqh/cfywtp/6CVGzBHXhAgRKRBqc98o9bIOKlbCKNrrDcpskh2hHZ Lvzbww+kXcOXB1Qs+4Yid7Ao/2412GxEL1ORhX0LKQzuYr+jTmPXHRgFbHbB52wiK4vy dmTJ2LDgIrzJxmHuX/sOOB16ox2mJW8RUnAkx8lNFTC6mWiYkoSLZ7ulPe/s/gYTtLYj X3/tdgVGuzxAQEkAadi4nQBsiWyyXzOtzNS3xdJWaGUmGDwCGjlwDcWeB1GTIbamTJA8 1HjfsHCCjZB6qzGE8qrrXuFRMeqIVm373GU2vJUYXd1jTFPFt7IodbJbl1CMpI+wk6A+ T3dQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=icUOIUv5aPxp/XDHfMIYwPdOZUziOwrmgWjtBk/AqOQ=; fh=qSEQRoWkWLa4t/oftrEJCnSk62mjQ9owur564gFpig8=; b=i4s2CaKeoCFm3smN6wWNyUHKANvgFyk6yAfsFAPPEb0iJyaWrVnhLkdEOyRU7E8gbr KPv6MfkiKkHNtdpqYon9QmQAR8Kz4zZBR7cLS20vJdUzNSJD8I6ebklKXOoYfjQD6UHo 2rR/76WLkaKEEU/CfWIl7GCzEX/+dt96SQEnH2gif319732X/k2qSGoqWZhVyge4ZVGR kKpUVbb8pqkOaw79z2PVO6zLpWWUD/EXowlK6jGhtpuuvZhnZT2RhPRkW+7cvjC0xgC3 n+FnOP+uiOb3LimR1aesh9mzSrQ4VM9sV4jooP0O5yQRXPS4E0wIqgp9U/q/4boJd5Lv hHEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i5Ia39o+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63063-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63063-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXLDzPfRhJnd6QftZiqSmD8YqTQ96aasw87BcPjn/ATruS5+ipZ4Y+w2juSt/OWP5Yk2UxU2DtI/YEMty9s/bIu7lZq1w== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s22-20020a639256000000b005bd27be66e1si1594880pgn.719.2024.02.12.23.54.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 23:54:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63063-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i5Ia39o+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63063-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63063-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A059C284076 for ; Tue, 13 Feb 2024 07:54:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78F9122313; Tue, 13 Feb 2024 07:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i5Ia39o+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC511182CC; Tue, 13 Feb 2024 07:52:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707810778; cv=none; b=Qmj0JJAM0rGR+b6masr7DUMgKBLPTjbPW2lafdTVbBq1QezV6XDY70r52jcb0/Npa8iBeDtYZAPf4tyYBf99zVlkWjGcf95rcyiL0kHdGtzO1F7IeVH74WX5u2Rss1/eEeXumGhVw49S8mqv8A3TBZwZa5U5kJ0V55YBRsY7HGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707810778; c=relaxed/simple; bh=jcUZpV1neXzu3Kp6ToaOsDKLDERo3W3oIzclMpmzJ1I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j6kkniChvGZSdi5VVxgfzE51psLK6mzs3T8EoX7hn0F0Je+nxV8EPnn5mUXWCEPXpHM7Q6NC+B9hfT1On7qg7/sNkEqnBSwcc0gBw4jL6q3VE8TLeV2mAKZkRyAzOUf70k3jQY1azSmkIjVyjvXazvxioQq2BZK8qH0P9flyff0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i5Ia39o+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECA87C43394; Tue, 13 Feb 2024 07:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707810778; bh=jcUZpV1neXzu3Kp6ToaOsDKLDERo3W3oIzclMpmzJ1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i5Ia39o+UXgoq87UnC132bdO3AXQ/WuaXkeWlK28XRnlkd37wk+R3d77ML+/2HZXO xhyxDBLbmlMFOQ/mAig9LIK643sPl2voIr9p5JWunqnslc6uj4iWmIkvEQPsmPkh/Q RbwNcFT3chwNv8hn17yABArqTYfI8QXSUkBVh6b9vOAG5d+4UTyJRIlw71ub9f5rq2 8qhrb5z9kAV/TRiZUQQI68JIk+DH4I3KR8cFIORO7a/dh60UcJ9XJNvciWZaa4J7e5 XuM20i5nEhyC9K7JgrZ7OkMZ9kiXS1I2qR9WzgLrM20VvfMfKbp9y5UWk7ycm7Nyrk lF9UQIbCnv3cg== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 2/4] perf hist: Simplify hist printing logic for group events Date: Mon, 12 Feb 2024 23:52:54 -0800 Message-ID: <20240213075256.1983638-3-namhyung@kernel.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240213075256.1983638-1-namhyung@kernel.org> References: <20240213075256.1983638-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790769477984190177 X-GMAIL-MSGID: 1790769477984190177 It can uses an array to save the period (or percent) values for member events and print them together in a loop. This simplify the logic to handle missing samples in members with zero values. No functional change intended. Signed-off-by: Namhyung Kim --- tools/perf/ui/hist.c | 55 +++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 2bf959d08354..5f4c110d840f 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -33,6 +33,7 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, char *buf = hpp->buf; size_t size = hpp->size; + /* print stand-alone or group leader events separately */ if (fmt_percent) { double percent = 0.0; u64 total = hists__total_period(hists); @@ -45,12 +46,19 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, ret = hpp__call_print_fn(hpp, print_fn, fmt, len, get_field(he)); if (evsel__is_group_event(evsel)) { - int prev_idx, idx_delta; + int idx; struct hist_entry *pair; int nr_members = evsel->core.nr_members; + union { + u64 period; + double percent; + } *val; - prev_idx = evsel__group_idx(evsel); + val = calloc(nr_members, sizeof(*val)); + if (val == NULL) + return 0; + /* collect values in the group members */ list_for_each_entry(pair, &he->pairs.head, pairs.node) { u64 period = get_field(pair); u64 total = hists__total_period(pair->hists); @@ -59,47 +67,26 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, continue; evsel = hists_to_evsel(pair->hists); - idx_delta = evsel__group_idx(evsel) - prev_idx - 1; - - while (idx_delta--) { - /* - * zero-fill group members in the middle which - * have no sample - */ - if (fmt_percent) { - ret += hpp__call_print_fn(hpp, print_fn, - fmt, len, 0.0); - } else { - ret += hpp__call_print_fn(hpp, print_fn, - fmt, len, 0ULL); - } - } - - if (fmt_percent) { - ret += hpp__call_print_fn(hpp, print_fn, fmt, len, - 100.0 * period / total); - } else { - ret += hpp__call_print_fn(hpp, print_fn, fmt, - len, period); - } + idx = evsel__group_idx(evsel); - prev_idx = evsel__group_idx(evsel); + if (fmt_percent) + val[idx].percent = 100.0 * period / total; + else + val[idx].period = period; } - idx_delta = nr_members - prev_idx - 1; - - while (idx_delta--) { - /* - * zero-fill group members at last which have no sample - */ + /* idx starts from 1 to skip the leader event */ + for (idx = 1; idx < nr_members; idx++) { if (fmt_percent) { ret += hpp__call_print_fn(hpp, print_fn, - fmt, len, 0.0); + fmt, len, val[idx].percent); } else { ret += hpp__call_print_fn(hpp, print_fn, - fmt, len, 0ULL); + fmt, len, val[idx].period); } } + + free(val); } /* From patchwork Tue Feb 13 07:52:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 200253 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp383902dyb; Mon, 12 Feb 2024 23:54:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIBkZfjfOSC+4a0Edl23dIUdfpFiWtI2EoUORBLONy8fQNV3lBkxXPq14q/KRwYSJbm6U8 X-Received: by 2002:a17:906:b208:b0:a3c:bb37:a676 with SMTP id p8-20020a170906b20800b00a3cbb37a676mr1585066ejz.9.1707810866891; Mon, 12 Feb 2024 23:54:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707810866; cv=pass; d=google.com; s=arc-20160816; b=URVv0KbmGrEeTAteRwvYeFwJhhxdGXDjLu08Nyrmd3+XM3YDLeNC0SsDAODVdFshAR XTx4oaVZm8kzffk9lts8AN/cQbMhgQ1jb1XZrU1SkSz0iEwmRNgFvCs8z8DhmlKWyuiS OFVAZ4PlAkq9+C04fYyLkJOIT/YdO4rsy0+6Wpop7+LR+aGcxz0AazAnFhohrVteDiF5 t5T8H7ufbKpEyWWhAqN1Swojys2qVJ7H/3NkUUvzUBP1E7HCZ42H9oTV9olj3TCAzjDQ i8GN4w34i1pjPSNPgMNa2w4S5QEX1+AqI4PvMmcev2yXGiV+BxJr0W0XBxE6ouRwvLud EudA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9SEbukrbA/HS3Yv+8R7Y5N1FpordbRB0wYABigTmuEE=; fh=g3Rr4Au5chWCIlZGOxuxly969VQqHHxllh9FJ0fxSLQ=; b=r2JLskwbrDZ63Ql5u+GwBo+CSaJWaeVkbeK8OZnpQtiTCUJq59KFNIO7eL6yLlUCmL rELwd0bemNjMYKwHOtooTMizWj0ZMb6T7GtKiaSxfH2TLBVenrkSkLn+V74w7ZzdOpKG dz3yoFv3FwMO5S3i++2cyX9AueThxuBNwyO78LGIHGyrCnXEViR3YqNQkKUjpm6jokxU oq/NF3cJSMsW0OArJX0OmjhZOOGGWtDP9X9p+snBbNDntdtpbqfGI6+0Z3XIsxGcdBl3 2lqyB8ar1elHVMqyayQkECwSm18IK/XVyULC6nE91TEqwBD4MCz1To7brjHuOU650tSK 8JdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nnufl34i; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63064-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63064-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCVsbcOfKLR8I9yJnIBmWrNL6ugNGHYe7bF4Ob+5XwXIZtb7ybeQFvf0Xm0xxGBEz90/pyovR2GsKt95UtXrEPG5ZvwzUA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g26-20020a170906199a00b00a3cf4e76e06si575158ejd.446.2024.02.12.23.54.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 23:54:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63064-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nnufl34i; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63064-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63064-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 81FBC1F22957 for ; Tue, 13 Feb 2024 07:54:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9E5D224D6; Tue, 13 Feb 2024 07:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nnufl34i" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4427618C1A; Tue, 13 Feb 2024 07:52:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707810779; cv=none; b=KD5FNiac0OF0mScWSFCXr8pU8yLyGmsoD1vDJaOwUz/4LaDv0EGviS+O5vJpMbnngvQOULG7d9kha9YfzL6/oVjDnt48nlDbz/+UKuQbXK8SHetnK9sBRVl6sWaWUly3uT+Ymc3nYaxumvqAPW2lgt0pdDzanx4dqlKzkhifaVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707810779; c=relaxed/simple; bh=/cAFvtSoMi2WFvvFOaWCdmF3lcgANJyG3cErhVuBZ3Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G8ul/i2vhAcX4hpxsQuAnRBTsa8VipPNyHguDrC3noTZB5ppejSJ+0Sm/jVOvtCUL4ZY4Xyx9aRwg55vhGU1P+R0LjHtlZonhz+3LBNZOkZz+1lJRuwSYg9xFhubBahXL+RbYfP2m0cfxTGIOjnj4MM+CjbuIh5qtyMU0QCgO8w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nnufl34i; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67A32C433C7; Tue, 13 Feb 2024 07:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707810778; bh=/cAFvtSoMi2WFvvFOaWCdmF3lcgANJyG3cErhVuBZ3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nnufl34iNC3PJN5Ds6rRUdfaW5U9p2ah3WGrMWoIOVvx6meTPJyvRYbKJ2VaWyEpW JwENBqr0ykiQo0dWSIrefm/0Q3hCBelXViKWu6WnXs1/D+eQxTjCDrspxoXrf5EhhM hkT0uEhvSSnwieywqmxuphXVUYOrios9WcUb1q/hxbZx5KmVcJf1FVVuBL7NihNQp6 fYsmE51MaZ5UWNh3X63jbf74uJzpBmpXClyoZPS6grNXRnBwGCjhjqkr5zPfys4DoT ns/e68RUr2CY0OTxJ/F0Ospavzi4qyYapfM7i+OnslVuD/yU1rBP9yPRbnI3Oreubc snyzjTj+UcECQ== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 3/4] perf hist: Do not use event index in hpp__fmt() Date: Mon, 12 Feb 2024 23:52:55 -0800 Message-ID: <20240213075256.1983638-4-namhyung@kernel.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240213075256.1983638-1-namhyung@kernel.org> References: <20240213075256.1983638-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790769487809479703 X-GMAIL-MSGID: 1790769487809479703 The __hpp__fmt() is to print period values in a hist entry. It handles event groups using linked pair entries. Until now, it used event index to print values of group members. But we want to make it more robust and support groups even if some members in the group were removed. Let's use an index table from evsel to value array so that we can skip dummy events in the output later. Signed-off-by: Namhyung Kim --- tools/perf/ui/hist.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 5f4c110d840f..9c4c738edde1 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -48,15 +48,30 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, if (evsel__is_group_event(evsel)) { int idx; struct hist_entry *pair; - int nr_members = evsel->core.nr_members; + int nr_members = evsel->core.nr_members - 1; union { u64 period; double percent; } *val; + struct evsel *member; + struct evsel **idx_table; val = calloc(nr_members, sizeof(*val)); if (val == NULL) - return 0; + goto out; + + idx_table = calloc(nr_members, sizeof(*idx_table)); + if (idx_table == NULL) + goto out; + + /* + * Build an index table for each evsel to the val array. + * It cannot use evsel->core.idx because removed events might + * create a hole so the index is not consecutive anymore. + */ + idx = 0; + for_each_group_member(member, evsel) + idx_table[idx++] = member; /* collect values in the group members */ list_for_each_entry(pair, &he->pairs.head, pairs.node) { @@ -66,8 +81,15 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, if (!total) continue; - evsel = hists_to_evsel(pair->hists); - idx = evsel__group_idx(evsel); + member = hists_to_evsel(pair->hists); + for (idx = 0; idx < nr_members; idx++) { + if (idx_table[idx] == member) + break; + } + + /* this should not happen */ + if (idx == nr_members) + continue; if (fmt_percent) val[idx].percent = 100.0 * period / total; @@ -75,8 +97,7 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, val[idx].period = period; } - /* idx starts from 1 to skip the leader event */ - for (idx = 1; idx < nr_members; idx++) { + for (idx = 0; idx < nr_members; idx++) { if (fmt_percent) { ret += hpp__call_print_fn(hpp, print_fn, fmt, len, val[idx].percent); @@ -89,6 +110,7 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, free(val); } +out: /* * Restore original buf and size as it's where caller expects * the result will be saved. From patchwork Tue Feb 13 07:52:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 200254 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp383904dyb; Mon, 12 Feb 2024 23:54:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWhZlTQRtAeT2DucmiQQiiD1ybfEpyGH5pvKKCiUMmMlVMkJgOWhCE0NCUxjmVNkvI75BG5LCJXfnU2dQBRLz7Z3mOcKg== X-Google-Smtp-Source: AGHT+IFbR5j8LBYxfZpeo7tgipqyl/944JJxvOW8MRrke7bq65LGVu4hRmeeeLAu6XtPv3DufTiK X-Received: by 2002:a05:6214:3005:b0:68c:ba50:a719 with SMTP id ke5-20020a056214300500b0068cba50a719mr11062555qvb.34.1707810867405; Mon, 12 Feb 2024 23:54:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707810867; cv=pass; d=google.com; s=arc-20160816; b=I9sgcxiEcThdWHGWROEEP8rlnGDMOjpZAIKuvgF1HPLCyUi3YgZDwCV8yE9QKZSIMN NMqUMI92GGc2oJ3xvXuT29O/hVyriAi1ROL3NdLU4j6IWngDYe12GhhyXNCw63XMU1ts MrU8jxKuvVczy2S3wbe0sLihoYlaupUm3pe4iTuHlRcslvd94G7roFp/EXdCwSXasz7P vxCjfMR0Iachqu4L5d68Ia4OOFLObzlXwaj2RYc+sUHHsJP8b0n1idO/Pe8isco4+mrb cny4wokZW8LLbIL2p+vVI/EHck40q+OrEosQEG4gOAKOCrtJeprZ/71SvvwrRq67KRUC neow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=EV93rb0Q6R5n+TCg8zZEJg77C3+xBCFflkxQJoaHV7Q=; fh=6t7+iFxv1CADOrz35YbwWJNcWbjyut3mVg7QBJt1QsQ=; b=LHiF/4uz/EYjGnogjQUpmx9qXrAX9hzdaR/qHVPdQyNW9SuG2QFZ+lK7UMjWlMlcI1 eMASSAFoH9S2PHKahOZ3Nc8jBj3JvjodhVUoEfIgpDZZUmRYu41n/+kSr8Rmz0tOYoZS YklLARGuDzqXhBJ5A+pYCpGDP1vRpi+MFIzuf5vQCxarQaXpVNgeJYsIpE33nGfqi0BI sDS+Dq4qOqe/XoWusMXcGGVVsFrC3l9FikYUGoTIogm298mCM75ME4L7dDNbaPKtjK9G zf3gloDTAk5cuyzpnHV1Lh6dT7cxecS9dVeNTUPWRNTxgSStRNbnU2vGNpPGzZYz2D4s nESA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oaBzEzXX; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63065-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63065-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWRsaKg8DlmiUmbeSjkCF7h2kTKtt+NWa41ivi/xec/QxvkGA/EbG+9mvUS5KwUOe3kpmsL/sG9Trt415tlnIBV5TXOLA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ke17-20020a056214301100b0068c4ee6bb81si2199535qvb.61.2024.02.12.23.54.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 23:54:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63065-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oaBzEzXX; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63065-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63065-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 351181C2120D for ; Tue, 13 Feb 2024 07:54:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 11DA3224DE; Tue, 13 Feb 2024 07:53:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oaBzEzXX" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50D6518E37; Tue, 13 Feb 2024 07:52:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707810779; cv=none; b=I2S4KfD89XVSxFw+fRhb1Pdvk7j77qNDQW93hnBqmgOAU7Vb1kYIuXMX/33RK2A1RRf1Rq3LagodtddqO+VJP1UW0xXRMb8qP7vntf5YI3vORJyzcmwWq1PkZBaNf7Wh9u17+bNyh1prrMana1Gsxv/72WYJhCKMf+pVCVev06Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707810779; c=relaxed/simple; bh=iBUiWDW8Ai4qSjFVJLHHIZ87HU0SArsopllQZXXyTrI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UIGdF0XCjwCMLbNdm648pA7qfvCohzEyD1IjeUfexrZcwBeoHaUx9/DDRbrOekXFmk3B3SdPGhhBaQ8+owpERmQegmYCca1amtXHmkq8lAaPN8GKIxedOu87vsT8uwsbxy/V2xDHbx7NI2dRqRFzuOy+XqHI3ci/V+uPA/A0PfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oaBzEzXX; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCD86C43330; Tue, 13 Feb 2024 07:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707810779; bh=iBUiWDW8Ai4qSjFVJLHHIZ87HU0SArsopllQZXXyTrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oaBzEzXXW7jZhGtjT0gxCZeIIIhE6Lwb6H4dPRwJ6q1eZjb9RexYg508HRr2GfPDq KvulJxx3AsqX6RyjTuELeZtDIGeO0MK2DGQ9pmgPMMu7shYprG6px+fV9Hnhw6JY3c FDBuLrkBNjvZVXNU7FMgOUVp/TLq9H3GU1mwbhNREJIioP+cdWDGmkHbfctd7vF1J/ aLVp3mLYszLHvdmvQipSnmDNzsLy+EFAfayIYeLnKZhNchsVJ06EjPjoycPU4ICmEi Us9s4LccIjtvHGzehkoBi+gApsL1Vj8BV+9z0kP3TaDpUoFfESwrpBwv417w7kjbgJ L3zlI4I7AVDlw== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 4/4] perf report: Do not show dummy events with --skip-empty Date: Mon, 12 Feb 2024 23:52:56 -0800 Message-ID: <20240213075256.1983638-5-namhyung@kernel.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240213075256.1983638-1-namhyung@kernel.org> References: <20240213075256.1983638-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790769488127320599 X-GMAIL-MSGID: 1790769488127320599 In system-wide mode, a dummy event was added during the perf record to save various side-band events like FORK, MMAP and so on. But this dummy event doesn't have samples for itself so it just wastes the output with all zero values. When --skip-empty option is on (by default), it can skip those (dummy) events without any samples by removing them from the evlist. Users can disable it using --no-skip-empty command line option or setting the report.skip-empty config option to false. Signed-off-by: Namhyung Kim --- tools/perf/Documentation/perf-report.txt | 3 ++- tools/perf/builtin-report.c | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index d8b863e01fe0..546af27d209c 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -609,7 +609,8 @@ include::itrace.txt[] 'Avg Cycles' - block average sampled cycles --skip-empty:: - Do not print 0 results in the --stat output. + Do not print 0 results in the output. This means skipping dummy events + in the event list and the --stat output. include::callchain-overhead-calculation.txt[] diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 8e16fa261e6f..60e30f13c8f8 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -752,10 +752,22 @@ static int hists__resort_cb(struct hist_entry *he, void *arg) static void report__output_resort(struct report *rep) { struct ui_progress prog; - struct evsel *pos; + struct evsel *pos, *tmp; ui_progress__init(&prog, rep->nr_entries, "Sorting events for output..."); + if (rep->skip_empty) { + evlist__for_each_entry_safe(rep->session->evlist, tmp, pos) { + struct hists *hists = evsel__hists(pos); + + if (hists->nr_entries != 0) + continue; + + evlist__remove(rep->session->evlist, pos); + evsel__delete(pos); + } + } + evlist__for_each_entry(rep->session->evlist, pos) { evsel__output_resort_cb(pos, &prog, hists__resort_cb, rep); }