From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5480C433EF for ; Mon, 14 Feb 2022 21:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231252AbiBNV0s (ORCPT ); Mon, 14 Feb 2022 16:26:48 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:36616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231235AbiBNV0q (ORCPT ); Mon, 14 Feb 2022 16:26:46 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5763BB9D73; Mon, 14 Feb 2022 13:26:37 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E7EB9B81678; Mon, 14 Feb 2022 19:48:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F834C340E9; Mon, 14 Feb 2022 19:48:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644868118; bh=6CPzKa/jy62UCHjGbLUgVBG8XhojQHJmyDzVBz+gPz8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=R3kB8oqgBk6EVg5CIPE0hIH6DYKuQyhbj41LI2Zu1KV/lsB5zeVnY3wIAQ+SDoTwW xpjIolDQcScuZ0DVqop4kK0Ntv+27D3129QOtCKxuBvI+BF4KO3bmOhocVf9KG+NWQ G62Ri5tP+T0awA6b7PBpSvbg2nRMOvYaMl0qnHZRuLSYOyR172/owARg9IwMy+gEqM kPrWx4eE8WBS8N6MWE17ENgnwYfpBmLBTSvnucgDiBlnYmORrczNRmTnyCWStEurCu 4Jkkua/Q4WNOOmIn6AU2zWYIhOAVlA4TkOmW6hS2s+baxbYHCaKnUgTCZi4CbhhEma zpAvUMHD6Y5cQ== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id EE6F7400FE; Mon, 14 Feb 2022 16:48:35 -0300 (-03) Date: Mon, 14 Feb 2022 16:48:35 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Darren Hart , Davidlohr Bueso , =?iso-8859-1?Q?Andr=E9?= Almeida , James Clark , John Garry , Riccardo Mancini , Yury Norov , Andy Shevchenko , Andrew Morton , Jin Yao , Adrian Hunter , Leo Yan , Andi Kleen , Thomas Richter , Kan Liang , Madhavan Srinivasan , Shunsuke Nakamura , Song Liu , Masami Hiramatsu , Steven Rostedt , Miaoqian Lin , Stephen Brennan , Kajol Jain , Alexey Bayduraev , German Gomez , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Dumazet , Dmitry Vyukov , Hao Luo , eranian@google.com Subject: Re: [PATCH v3 06/22] perf test: Use pointer for maps Message-ID: References: <20220211103415.2737789-1-irogers@google.com> <20220211103415.2737789-7-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220211103415.2737789-7-irogers@google.com> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, Feb 11, 2022 at 02:33:59AM -0800, Ian Rogers escreveu: > struct maps is reference counted, using a pointer is more idiomatic. > > Signed-off-by: Ian Rogers > --- > tools/perf/tests/maps.c | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/tools/perf/tests/maps.c b/tools/perf/tests/maps.c > index e308a3296cef..6f53f17f788e 100644 > --- a/tools/perf/tests/maps.c > +++ b/tools/perf/tests/maps.c > @@ -35,7 +35,7 @@ static int check_maps(struct map_def *merged, unsigned int size, struct maps *ma > > static int test__maps__merge_in(struct test_suite *t __maybe_unused, int subtest __maybe_unused) > { > - struct maps maps; > + struct maps *maps; > unsigned int i; > struct map_def bpf_progs[] = { > { "bpf_prog_1", 200, 300 }, > @@ -64,7 +64,7 @@ static int test__maps__merge_in(struct test_suite *t __maybe_unused, int subtest > struct map *map_kcore1, *map_kcore2, *map_kcore3; > int ret; > > - maps__init(&maps, NULL); > + maps = maps__new(NULL); Now that is dynamicly allocated we need to check for the constructor result, I'm fixing this up. - Arnaldo > for (i = 0; i < ARRAY_SIZE(bpf_progs); i++) { > struct map *map; > @@ -74,7 +74,7 @@ static int test__maps__merge_in(struct test_suite *t __maybe_unused, int subtest > > map->start = bpf_progs[i].start; > map->end = bpf_progs[i].end; > - maps__insert(&maps, map); > + maps__insert(maps, map); > map__put(map); > } > > @@ -99,25 +99,25 @@ static int test__maps__merge_in(struct test_suite *t __maybe_unused, int subtest > map_kcore3->start = 880; > map_kcore3->end = 1100; > > - ret = maps__merge_in(&maps, map_kcore1); > + ret = maps__merge_in(maps, map_kcore1); > TEST_ASSERT_VAL("failed to merge map", !ret); > > - ret = check_maps(merged12, ARRAY_SIZE(merged12), &maps); > + ret = check_maps(merged12, ARRAY_SIZE(merged12), maps); > TEST_ASSERT_VAL("merge check failed", !ret); > > - ret = maps__merge_in(&maps, map_kcore2); > + ret = maps__merge_in(maps, map_kcore2); > TEST_ASSERT_VAL("failed to merge map", !ret); > > - ret = check_maps(merged12, ARRAY_SIZE(merged12), &maps); > + ret = check_maps(merged12, ARRAY_SIZE(merged12), maps); > TEST_ASSERT_VAL("merge check failed", !ret); > > - ret = maps__merge_in(&maps, map_kcore3); > + ret = maps__merge_in(maps, map_kcore3); > TEST_ASSERT_VAL("failed to merge map", !ret); > > - ret = check_maps(merged3, ARRAY_SIZE(merged3), &maps); > + ret = check_maps(merged3, ARRAY_SIZE(merged3), maps); > TEST_ASSERT_VAL("merge check failed", !ret); > > - maps__exit(&maps); > + maps__delete(maps); > return TEST_OK; > } > > -- > 2.35.1.265.g69c8d7142f-goog -- - Arnaldo