Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2898175rdb; Mon, 12 Feb 2024 23:53:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUBY7Xppq/BCSEk2Xzqar4MYZcu2SH8V/mq8cEN++iV2xIHCxXxy/qZRmhVkZ4NrxCDEU5C48h6rgX0rwIGiZdFF5aH1Ir4GZ1ZAykpCA== X-Google-Smtp-Source: AGHT+IHsoUfJbVT0nCguJoEYhtp0RHHhxt+huzacpPi+gC8DyUad+3MkKp+dKy2NA+Qc1g3TLNpx X-Received: by 2002:aa7:da18:0:b0:561:52ad:fa8c with SMTP id r24-20020aa7da18000000b0056152adfa8cmr6371893eds.7.1707810809448; Mon, 12 Feb 2024 23:53:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707810809; cv=pass; d=google.com; s=arc-20160816; b=0Oeipsi4YzUFr9eR0/BbvYgXQq+Tow90oD3X4VeDsKIk29BTUQQNv1Ugf9IqaEA1Ri 9Ngv77KTmc3yhLKsaI07W1isZTU15fwJV3LOkMZLixf9Pnsenzab+qmtAVFWWIwN3RLE N+wGW1jjLDbcyOK80nDzuWf9c5LBHJ9/Im1A9dactMf7Y2ZDEBB/bt9ry14lbVoVbQzY 7Se6m2pPJ0xbnJLyioWJdBzWCcdVGrztG8a1PkuuFoXH6VSkmPa+HcUlxc0ve4tDJz5S 3GaqdQr3diZA4RP5RAGwaq5W79o4oS6R987TXAc7gTe30FsN0M7hKS2QpG2pjRHo00nh Yxbg== 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=1l7S34hGDPrPSE8vracJG2jHTR6F+NIgDF6cEvQjHd8=; b=zIw6W5YNwaaCSxmomSkKqX+uJVDKNyUUDqCSWin/xiOS7opG/hkfQHJD7I3vnc0+ai HMyAWmtZ4F+MkwF8Mn18WOGYZU7+F9j+q5lj1dZQe1XMD89hABmAozOvUJrSsP6cTPRy zBwCB3+r8S6b7JW5hh9GkTFWx5r1WFJ0vnArSgbVV3l2xEVQau0jAvAGCzaKvdhoNrU9 +RX+85CVXec/Fa0KDGMyPZn9/JZuTkacQyEYJ5+Xs3JWbGndL1JmKJuM1L41nVHf7YdJ 6WoeECZz+kj4AKqyzD096TLCE/Ketaay7PSDQC3Qr78U/PBUBEUbKUi7cWl2SJXT+5aX 2j9g==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63062-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCVQFQAoZcU02nXPgeK5d3/6IUnN4s2aYnZgsrOChLCyYjUv8akyV45r5oL2NKLeVPrDcoGHcLKkifgxXL9VNiCE6VcIFq3h+yK2M2n9uA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id o29-20020a509b1d000000b005607e191a2asi3617434edi.106.2024.02.12.23.53.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 23:53:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63062-linux.lists.archive=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=g3dpFVKv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63062-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63062-linux.lists.archive=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 36FDE1F2257C for ; Tue, 13 Feb 2024 07:53:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4197118C19; Tue, 13 Feb 2024 07:52:59 +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 Content-Transfer-Encoding: 8bit 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) -- 2.43.0.687.g38aa6559b0-goog