Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4919762ybv; Tue, 11 Feb 2020 05:57:08 -0800 (PST) X-Google-Smtp-Source: APXvYqz/lxfidge/punvitdU8OIVq5NK+fODCsR5zrwj9RDIMlYJ+18qWp9TE/VkRNI/9F4N8mua X-Received: by 2002:a9d:7304:: with SMTP id e4mr4898736otk.99.1581429428671; Tue, 11 Feb 2020 05:57:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581429428; cv=none; d=google.com; s=arc-20160816; b=uorpPcdgt/CKA9w+mfeES6PB/UIrJXdMZbOc6VoodVoH7aVCzQaqkACLoIP592yau5 ZKShdSCVAafmB82zvVSF9a8Nnkuhfe+QOgGC2bmfIQo/ointmogO8aIc4C++tKKWY723 olME2V/c2Hde5IJlmSF1RbzvtOnl+vRYcPudHXz6bizu/olGK9GiGgba4vAvZAB/vTNg miluUG7295JiYipz+zwqaDRQJWK06f78Tl85ymApXjKENugYtO0diE+RT/A+8DuWgYV9 ZmNlD6sr5ZCrRBVG6CIErYjAido/aFLt0f3oO/y+0VRh9O0+dnb6u8u5xUMG7oEwT/xh v41Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=MmX2QxmJTgqsJ7E84KMlupoW9uqlsOY7ScXnAyaxj68=; b=TN0/MLMgnEIczsOgYYXVCZyYCr6mFszT9WTrIxZPiU+RfXW1VhIkAH43NHwGp9CukB EbtLLhiGBfXjdzNmTe3lnMwMIxm6kR8VlclcHF7AxiUAHWP1tK132Egpdb1I1P7WKkC0 GjROi23TqapU19s2it7yTdZ2AsKMgCPWBkuJfUImoFFHNFAT7cOPHFEPmFXRgilRBvLU l556vy4BxAlropihk1gIDyPGnDn34r0enA6qd9XCyO2IJtcC39B0WPNMpebihEQiCdAO 29Xo74aDXjgR0Vx673bupsx8lFZqpvT7cFJEqG7IKS/ZDqwRfAAru2uEbrKMPZ2hmvrt 4EkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OG3isFzY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v21si1807752otj.282.2020.02.11.05.56.56; Tue, 11 Feb 2020 05:57:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OG3isFzY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728519AbgBKNmB (ORCPT + 99 others); Tue, 11 Feb 2020 08:42:01 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:38521 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727653AbgBKNmA (ORCPT ); Tue, 11 Feb 2020 08:42:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581428520; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MmX2QxmJTgqsJ7E84KMlupoW9uqlsOY7ScXnAyaxj68=; b=OG3isFzYu6jgKns9FbkE0RaeZOwytekk9mFOg6b5BG8Xud4y3EQx+/AEb3yKKRYdt3/OUx 6T77pNma2Iv/RNXlg9jmQMl8QuC1mz240dqkx+uNbCyW+0RvvhDWKqJa8ws91TJ92OP35r jS9OgSMSbidk5kg4Dyb0l5g0twKRKqI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-335-j2ABBXtlP6qzTAgIyTaP7Q-1; Tue, 11 Feb 2020 08:41:54 -0500 X-MC-Unique: j2ABBXtlP6qzTAgIyTaP7Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 63B2A1B18BFB; Tue, 11 Feb 2020 13:41:52 +0000 (UTC) Received: from krava (ovpn-204-250.brq.redhat.com [10.40.204.250]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 062D65D9CA; Tue, 11 Feb 2020 13:41:48 +0000 (UTC) Date: Tue, 11 Feb 2020 14:41:45 +0100 From: Jiri Olsa To: kajoljain Cc: Joe Perches , acme@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Jiri Olsa , Alexander Shishkin , Andi Kleen , Kan Liang , Peter Zijlstra , Jin Yao , Madhavan Srinivasan , Anju T Sudhakar , Ravi Bangoria Subject: Re: [PATCH v3] tools/perf/metricgroup: Fix printing event names of metric group with multiple events incase of overlapping events Message-ID: <20200211134145.GA93194@krava> References: <20200131052522.7267-1-kjain@linux.ibm.com> <20200206184510.GA1669706@krava> <51a4b570eb47e80801a460c89acf20d13a269600.camel@perches.com> <20200210121135.GI1907700@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 11, 2020 at 04:50:41PM +0530, kajoljain wrote: > > > On 2/10/20 5:41 PM, Jiri Olsa wrote: > > On Thu, Feb 06, 2020 at 10:58:12AM -0800, Joe Perches wrote: > >> On Thu, 2020-02-06 at 19:45 +0100, Jiri Olsa wrote: > >>> On Fri, Jan 31, 2020 at 10:55:22AM +0530, Kajol Jain wrote: > >>> > >>> SNIP > >>> > >>>> ev->metric_leader = metric_events[i]; > >>>> } > >>>> + j++; > >>>> } > >>>> + ev = metric_events[i]; > >>>> + evlist_used[ev->idx] = true; > >>>> } > >>>> > >>>> return metric_events[0]; > >>>> @@ -160,6 +161,9 @@ static int metricgroup__setup_events(struct list_head *groups, > >>>> int ret = 0; > >>>> struct egroup *eg; > >>>> struct evsel *evsel; > >>>> + bool evlist_used[perf_evlist->core.nr_entries]; > >>>> + > >>>> + memset(evlist_used, 0, perf_evlist->core.nr_entries); > >>> > >>> I know I posted this in the previous email, but are we sure bool > >>> is always 1 byte? would sizeod(evlist_used) be safer? > > > Hi jiri, > Yes you are right. We should use 'evlist_used' size itself. > > >>> > >>> other than that it looks ok > >>> > >>> Andi, you're ok with this? > >> > >> stack declarations of variable length arrays are not > >> a good thing. > >> > >> https://lwn.net/Articles/749089/ > >> > >> and > >> > >> bool evlist_used[perf_evlist->core.nr_entries] = {}; > > > I am planning to use calloc and free that memory later in function 'metricgroup__setup_events'. > Something like this. > > > + bool *evlist_used; > + > + evlist_used = (bool *)calloc(perf_evlist->core.nr_entries, > + sizeof(bool)); > + if (!evlist_used) { > + ret = -ENOMEM; > + break; > + } > > Please let me know if its looking fine. I'm also ok with the array on the stack, but I don't mind this change as well thanks, jirka