Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1331563rdb; Fri, 16 Feb 2024 12:09:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXnQQMyfRJw5Oh0DBHDiwcriG1817TX/sPRg84dp5TYPZx89mSVTXN3fZDd/TVT/kvtOTdAE5iLpMTRw/nQtSbGg2Uyqp16UBs3g7ooVg== X-Google-Smtp-Source: AGHT+IGo1lw/09rjwjrwe6emoD3187NDWPP1zF3ok/v/VR2NoF+FD2FhvRokGe2/UU9GtaW1NJPn X-Received: by 2002:a17:902:ec83:b0:1d8:8aba:4b07 with SMTP id x3-20020a170902ec8300b001d88aba4b07mr7130098plg.60.1708114155189; Fri, 16 Feb 2024 12:09:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708114155; cv=pass; d=google.com; s=arc-20160816; b=XOGifQGLDMSzYuYCnyoDh+uFKaof0E+z5y+VxCDHkncy6O9wGyiOxxBIfslVT92jWv mpANgC6D3+PNs/ZwAOd5YDUlyzwK/hLcqeGz2oY/PFWTC/Rmw+gOaodjkOjT4ew0JYKY OyV1ofxJ7SWnL9i1iufc958Ecd+lYygXM+1qtdTnL5MuLeXnSPE7fC6I+SR8tOlJvmMa h9u/3rDChk5OPs5aR2rfE/+G2kzSoWS/MMTdqJxjvvBIFNuxESB7UnPhgv9TvRLCopMg 1B0t+YlEJMLVb1iX8//58fmPwYlxh6sdaiBCBOFoPkaP+COyRq7ro7pNFhgAF1yjjAg/ ktCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=+K2Fgb8X/bk94h+IXdbaE/IqDHPns4xLfRpQ3CzppJ8=; fh=z7mboBNK/fmu1Ph9TvA2ldpElHYpXKmqJ5BrRkJKlRQ=; b=gPjoFS1/SP167ZmuobmhAlMF264FAuP7XBKhK/UGbUIFcgyWaqThoLtzCgx0uXP4dA BNdWg984Sd7WIRqEmvXw4AtWy97T8OgrwNtYurJ0QszQdRp2bgI3uDA5e7CCV9McQKF/ L4xF0D67zBBpwL8WW24FGBQ5jyVg88oubvAm6G/20J36WzBSVZhiVt+wDM2f50fO6a1S S0aCNDVqZjxUEEFV63iuRtIMIOlFqcdHLPYilZ6afKDLFrM1KrtQHCssRhf7GLk42JVI VSYPy7mAJGQYLjZLC3YxLUCaBjAu3Y84y//R0PEq3EPHLg6YlABI+fMWIq6TE27BOGEt BdMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-69275-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69275-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id a2-20020a170902ecc200b001d71eac3499si355635plh.6.2024.02.16.12.09.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:09:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69275-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-69275-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69275-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 08F36B20B71 for ; Fri, 16 Feb 2024 20:09:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE1DF13849C; Fri, 16 Feb 2024 20:09:01 +0000 (UTC) Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9B93135402; Fri, 16 Feb 2024 20:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708114141; cv=none; b=pvSnSPi+D0ZPOQvPxPreZbEW39k+ujnNyAj27AtBPyyljvlmm5b7nLd9XjaDd9vWrA3hobQN2/A4l6aySjbQsjATCIcANPwrEChlKGmEEbhaBKo3YrzZ3BlBylJ9n3tw7o5O8Q6x0mC7DwQVsfeHoE2h3+e1YmyDbtna9UcAs6k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708114141; c=relaxed/simple; bh=zGDptjAq4jLL6sQvLop2+9PNm8IdwyOTG2jsi5pb8YA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=D1ICwKWOdx6lnNpLMxaOigHPbLMwhbXknymvJcSmcGxPhtws1IyW0r69BjB4OaJsxXbSEmcgV9AYpB41Wx9986FnbVR+60qNwa7HnAe7rUUvRZOTdHfOSNcbZZSGYdLCE0wbAvRvROvbeYjUwZFOZ8KzTEPk8nbh2GVIeEC2pf0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d70b0e521eso20760185ad.1; Fri, 16 Feb 2024 12:08:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708114139; x=1708718939; 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=+K2Fgb8X/bk94h+IXdbaE/IqDHPns4xLfRpQ3CzppJ8=; b=ClF1rtKXYi73uF3C/ZAD99JmoQusrMv3cmvLUljQ0lNUVbsQxRZ1XWW7Wub7zZTWd+ bhp6k/U2DmQi8ssy1LrnE+q323+QVXMzTxVYqaBD3S0gROs6VZS8kscEHIAaziTY70mj hWnqkqXM60nuIMsY6qsw8J8xagvB8fjaDNhY67g4aCY/FVkvtqXBjn6K583qgLjXnK6S hpaNDXdOZCeUoe+rgS4lMOG18quH9p4RF2iCdmfgpvqhtnpefEkjq/ClXNd0rHaSbxi0 bBtUk3rHEtOMybIcHHO17/CHPVmQt8MtIYMP4dNT1kIsaC3WQn6qNMqniuT7ZpNBBQWr 92rw== X-Forwarded-Encrypted: i=1; AJvYcCVRMyZK1oU7l10Az9vFfJ/8YX5epNP9P8rjWWKfu+laZARKp1XpE/PEZgDblVVC802NHkdULLUOMeNqtcNMq/b/EdfC5dlaPeF+xkNhWazErSJIZO8sPBpG3DLZLV0oxKb5+5eeDR22POCKsHljug== X-Gm-Message-State: AOJu0YzYR2nRPKHgYUP5ex3Fow23OWHVScx1wYpvhvUu0CBu6Hxzgh6O t9szsdn/Gy5XbpgOfATHaJasIHv8suquOt8XwWGzSisM3x6iAQqcDnZ1nZMgxGZoiRE951leR7m BK29PiNrvSLDmLq8f7knoFbdMzJs= X-Received: by 2002:a17:90a:dc0a:b0:299:3657:494c with SMTP id i10-20020a17090adc0a00b002993657494cmr2054663pjv.24.1708114138871; Fri, 16 Feb 2024 12:08:58 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240213075256.1983638-1-namhyung@kernel.org> <20240213075256.1983638-4-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Fri, 16 Feb 2024 12:08:47 -0800 Message-ID: Subject: Re: [PATCH 3/4] perf hist: Do not use event index in hpp__fmt() To: Ian Rogers 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 On Wed, Feb 14, 2024 at 11:54=E2=80=AFPM Ian Rogers wr= ote: > > On Wed, Feb 14, 2024 at 9:26=E2=80=AFPM Namhyung Kim wrote: > > > > On Wed, Feb 14, 2024 at 4:08=E2=80=AFPM Ian Rogers = wrote: > > > > > > On Mon, Feb 12, 2024 at 11:52=E2=80=AFPM Namhyung Kim wrote: > > > > > > > > The __hpp__fmt() is to print period values in a hist entry. It han= dles > > > > event groups using linked pair entries. Until now, it used event i= ndex > > > > to print values of group members. But we want to make it more robu= st > > > > and support groups even if some members in the group were removed. > > > > > > I'm unclear how it breaks currently. The evsel idx is set the evlist > > > nr_entries on creation and not updated by a remove. A remove may > > > change a groups leader, should the remove also make the next entry's > > > index idx that of the previous group leader? > > > > The evsel__group_idx() returns evsel->idx - leader->idx. > > If it has a group event {A, B, C} then the index would be 0, 1, 2. > > If it removes B, the group would be {A, C} with index 0 and 2. > > The nr_members is 2 now so it cannot use index 2 for C. > > > > Note that we cannot change the index of C because some information > > like annotation histogram relies on the index. > > Ugh, the whole index thing is just messy - perhaps these days we could > have a hashmap with the evsel as a key instead. I remember that I also > forced the idx here: > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/= tree/tools/perf/util/parse-events.c?h=3Dperf-tools-next#n2049 > If it were invariant that the idx were always the position of an event > in the evlist then I think life would be easier, but that won't help > for the arrays of counters that need the index to be constant. I guess > this is why the previous work to do this skipped evsels rather than > removed them. Actually I have a patch series to convert the annotation histogram to a hash map. It'd reduce memory usage as well. Will post. I think removing evsel is not a common operation and should be done with care. In this patchset, it removed (dummy) events after processing all samples. I can make the code to skip those event when printing the result but it'd be much easier if it can remove the unnecessary events. Thanks, Namhyung