Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3608363pxt; Tue, 10 Aug 2021 07:23:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzFhkZGoAvuigC9b/j0/zMKfofd12LNAnGSdtHxdYYLJ8FV7IB6vGA+sTbhFmM34ah5BZf X-Received: by 2002:a17:906:3e59:: with SMTP id t25mr7488614eji.24.1628605428158; Tue, 10 Aug 2021 07:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628605428; cv=none; d=google.com; s=arc-20160816; b=e1/oKD3ZH5GAaRLuk09bHfFSg67YGACoIU+QaVLNeLl5AbGlRJ2buQMo6EMCEJZaAg k3HPD18xkYcTXUmf8ogaLS5pV0pItpr/BZPm27A2wASaYunKJzoOFNpnrqqZuojMp4x5 DG8btGpa8fV+IGuDh95AJeJl5ZjY75qi8GEP3i5SK8UyUtvG+/WvOpXNUqP3fZ77wsvJ 94pIC8NUIwMhKxBalr6d78h59joRDMTcaQWFlUdmEV5oNrE6Df8Y1GHRQnPGx4nXkjLZ Qytnz3yH08C+YAi0ZXdsBCyc0D7iSQhbkUJn4thPW3O7CRk3W99vhV1ny5T3k+suQ2of VpoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=oPe5UQTWLtkwzykwhhYObFrH6WYEYoxkokJyHLSvAEs=; b=ergmXuiqTlM0yOPLO2SNXq9fPGhXP+kt06Y+/Tjg2ckYWhWBhHtbR09XQ1ugeQPQx0 XyaY754uQote+ANY9WNzSJH7aSX0mTZVfkuUp3VdnzYBrfEw5GCieLZ+/mv35+5/SY5B GQtIB9KmRQ/G80q4pCjDS3ONH6PHKEUQEkqaesDD+KQ6FYgQXPR7t3ZPxKp4D+eUHqDi CHeXlM4Dc2AyZzcPpm2EmAvhQMGh297rGGk8Q0EnwyJK8Poy3O1vELK0UzGicDpdSKPM 7FezpjylV2NMOa1s6uyq1nI7x4rwb1JJF0BZoSi/IdkKMcQgevAn3IvYhacuiUP+DBXB m8nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WnPHh11o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si20851995ede.496.2021.08.10.07.23.24; Tue, 10 Aug 2021 07:23:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WnPHh11o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240495AbhHJODs (ORCPT + 99 others); Tue, 10 Aug 2021 10:03:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:40370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236686AbhHJODr (ORCPT ); Tue, 10 Aug 2021 10:03:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F371960E52; Tue, 10 Aug 2021 14:03:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628604205; bh=Td8E4SnrU0EwYxqbg86EgADaAZSpTbgyuIW0jEf6cek=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WnPHh11oY7YFlpTdsCAQ+09LermdZbMkyjzjjyr8yoJ09r80n5nE1bMblfcW9dSfw 599+S1R1XP5jQQj9v9ad4/S/ML13MNGvIae/qztxO2dU3eWHmsJQ2RN19Bf+EEMSNQ 2JSrTCBOnh5l1Za9wWMI09xdHXKEohmeX8ly+5bzfV+XgCAw3qmAqS4qTFDloePGGu u/uUIeb73MiqOobayU/ipgqc7D5bl4m3uoA49xfE9foxqCd8HF1jqIfcN42dVdjO3A hBJPhL5I5FlFtCeZrrsNA8E7jDikFCdBrN5FXpZ9oHXxnfwmfjLjGBXf5BzK2ZSqMX PTkkviwJCIkUA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 6FFC8403F2; Tue, 10 Aug 2021 11:03:22 -0300 (-03) Date: Tue, 10 Aug 2021 11:03:22 -0300 From: Arnaldo Carvalho de Melo To: Riccardo Mancini Cc: Arnaldo Carvalho de Melo , Ian Rogers , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH] perf bench: add benchmark for evlist open/close operations Message-ID: References: <20210809201101.277594-1-rickyman7@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Aug 10, 2021 at 12:31:55PM +0200, Riccardo Mancini escreveu: > Hi Arnaldo, > > On Mon, 2021-08-09 at 17:28 -0300, Arnaldo Carvalho de Melo wrote: > > Em Mon, Aug 09, 2021 at 05:23:31PM -0300, Arnaldo Carvalho de Melo escreveu: > > > Em Mon, Aug 09, 2021 at 10:11:02PM +0200, Riccardo Mancini escreveu: > > > > +static struct evlist *bench__create_evlist(char *evstr) > > > > +{ > > > > +???????struct evlist *evlist; > > > > +???????struct parse_events_error err; > > > > +???????int ret; > > > > > > +???????evlist = evlist__new(); > > > > +???????if (!evlist) { > > > > +???????????????pr_err("Not enough memory to create evlist\n"); > > > > +???????????????return NULL; > > > > +???????} > > > > > > +???????bzero(&err, sizeof(err)); > > > > > man bzero > > > > > > ?????? The bzero() function is deprecated (marked as LEGACY in POSIX.1-2001); > > > use memset(3) in new programs.? POSIX.1-2008 removes the specification of > > > bzero().? The bzero() function first appeared in 4.3BSD. > > Oops, I didn't know, but I saw it is being used in some parts in perf, maybe we > should get rid of them: > $ rg -c bzero > builtin-lock.c:1 > arch/powerpc/util/kvm-stat.c:1 > builtin-stat.c:1 > builtin-trace.c:2 > bench/evlist-open-close.c:1 > bench/numa.c:5 > tests/parse-events.c:1 > tests/backward-ring-buffer.c:1 > tests/bpf.c:2 > util/metricgroup.c:1 > util/parse-events.c:1 Yeah, patches are welcome, but at least lets not add new ones :-) > > > I'm replacing it with a memset(). > > > > This one is also equivalent: > > > > tools/perf/tests/pmu-events.c:??struct parse_events_error error = { .idx = 0, }; > > > > https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html > > > > That text is a bit roundabout, as it says that the members that are not > > explicitely initialized will be initialized as variables with static > > storage duration, i.e. zeroed. > > Would it be the same doing the shorter {0}. It would be a general solution for > these init-to-zero cases. I'd have to do some extra research to remember why that is also not optimal, IIRC the '= { .a = 0, };' is the optimal one. > Unrelated to this small issue, I noticed I forgot to check the return of > bench__create_evlist. Would you like me to send a v2 fixing both issues or are > you able to apply this other small change yourself? Nah, as this is the HEAD right now in my local branch, I'll apply it myself, thanks! - Arnaldo > diff --git a/tools/perf/bench/evlist-open-close.c b/tools/perf/bench/evlist-open-close.c > index 40bce06f5ca7bef3..f0b9c330f34f2984 100644 > --- a/tools/perf/bench/evlist-open-close.c > +++ b/tools/perf/bench/evlist-open-close.c > @@ -168,7 +168,11 @@ static int bench_evlist_open_close__run(char *evstr) > > for (i = 0; i < iterations; i++) { > pr_debug("Started iteration %d\n", i); > + > evlist = bench__create_evlist(evstr); > + if (!evlist) > + return -ENOMEM; > + > gettimeofday(&start, NULL); > err = bench__do_evlist_open_close(evlist); > if (err) { > > Thanks, > Riccardo > > > > > - Arnaldo > > -- - Arnaldo