Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5475458ybp; Mon, 14 Oct 2019 23:30:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqw38CMJLK3SBJz6jpj1dF5blAOjMiDvEU+bD2YX8bPcsMTUA31Ez3Zgh88HUrlWFrQhde+j X-Received: by 2002:aa7:d04a:: with SMTP id n10mr32533717edo.14.1571121044898; Mon, 14 Oct 2019 23:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571121044; cv=none; d=google.com; s=arc-20160816; b=wkr+1zannj3ktANBdmvgJyc4K5Gq9cq4Z6KVg5lV8LRNEeGe+7adSt8ghzq+kZqOoV BrWn9n1/oAf9DDUv6c5TM6wGTVXa6WbWJ1cIFpH/KT0AuIOlrI+ZANIRmFc/1JiVLV6v G4493G4QZmAH9tE+Cf/lPlwhcFXWQEGISF2BGPkE7drIT54bz1T6aEapEfPeB+sBxuxR juQkw3FxcScyao+WuWtV26IVG/CffUvtDEXdNtSzT+jSPxsnZKBL7FfPGcXBbAeUeZHq XdvwqQmDBX68mzLKrYSJ534OVPRFDP3f2KghPEF4goy4Z4KA+kNJXoyduDzLcN4mvUOc zHoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=iR2EsoBl34zJXB2271nqp80UDDHuYULMYJBbDJgl+BA=; b=m3L8u+XAIxyG2VU2BH3lGNTMvFgD+ABK3qQEaqR4G2QTy4DLRBxZaAVLhrRCQvL9sd ws8/01KBUhhKkH/V6goSm37EZmDR8Dublxdk/cC2jsOcJwnxk546gjCC0B3d913Tzlrf yjiSOh2xBJ8bEsGU4R5ZtLXzC+/tmZsZw3aZ3/xct5oSM2oPNzq5zwm9r+XVcvxom9oZ Kl98O3zdL6cD6/BMioX+A2rQw/CF7jdvSRLIjTcgpk+HmEJaBXlIt03BdxLF7ZxEO1dH mK3ze8yWfAlfPA8Sg8QckyOWHSa/VFv9NOskoXJRoFn//oH/azKkyTso1I97RyfYh3Da NobA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i33si14325581eda.205.2019.10.14.23.30.21; Mon, 14 Oct 2019 23:30:44 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727462AbfJOFfk (ORCPT + 99 others); Tue, 15 Oct 2019 01:35:40 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:42035 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728464AbfJOFcC (ORCPT ); Tue, 15 Oct 2019 01:32:02 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iKFR1-0000BS-Og; Tue, 15 Oct 2019 07:31:51 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id CEEB01C04D6; Tue, 15 Oct 2019 07:31:41 +0200 (CEST) Date: Tue, 15 Oct 2019 05:31:41 -0000 From: "tip-bot2 for Jiri Olsa" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] libperf: Add perf_mmap__init() function Cc: Jiri Olsa , Alexander Shishkin , Michael Petlan , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <20191007125344.14268-2-jolsa@kernel.org> References: <20191007125344.14268-2-jolsa@kernel.org> MIME-Version: 1.0 Message-ID: <157111750177.12254.3319665333964310792.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: 353120b48d4f61288e4745b0c8a191784b11c0f4 Gitweb: https://git.kernel.org/tip/353120b48d4f61288e4745b0c8a191784b11c0f4 Author: Jiri Olsa AuthorDate: Mon, 07 Oct 2019 14:53:09 +02:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Thu, 10 Oct 2019 09:37:25 -03:00 libperf: Add perf_mmap__init() function Add perf_mmap__init() function to initialize 'struct perf_mmap' objects. Add it to a new mmap.c source file, that will carry all the mmap related functions. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20191007125344.14268-2-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/Build | 1 + tools/perf/lib/include/internal/mmap.h | 2 ++ tools/perf/lib/mmap.c | 9 +++++++++ tools/perf/util/evlist.c | 5 ++--- 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 tools/perf/lib/mmap.c diff --git a/tools/perf/lib/Build b/tools/perf/lib/Build index c31f1c1..2ef9a4e 100644 --- a/tools/perf/lib/Build +++ b/tools/perf/lib/Build @@ -3,6 +3,7 @@ libperf-y += cpumap.o libperf-y += threadmap.o libperf-y += evsel.o libperf-y += evlist.o +libperf-y += mmap.o libperf-y += zalloc.o libperf-y += xyarray.o libperf-y += lib.o diff --git a/tools/perf/lib/include/internal/mmap.h b/tools/perf/lib/include/internal/mmap.h index ba1e519..e25890d 100644 --- a/tools/perf/lib/include/internal/mmap.h +++ b/tools/perf/lib/include/internal/mmap.h @@ -29,4 +29,6 @@ struct perf_mmap { char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8); }; +void perf_mmap__init(struct perf_mmap *map, bool overwrite); + #endif /* __LIBPERF_INTERNAL_MMAP_H */ diff --git a/tools/perf/lib/mmap.c b/tools/perf/lib/mmap.c new file mode 100644 index 0000000..3da6177 --- /dev/null +++ b/tools/perf/lib/mmap.c @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 +#include + +void perf_mmap__init(struct perf_mmap *map, bool overwrite) +{ + map->fd = -1; + map->overwrite = overwrite; + refcount_set(&map->refcnt, 0); +} diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index e33b46a..6c8de08 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -629,8 +629,6 @@ static struct mmap *evlist__alloc_mmap(struct evlist *evlist, return NULL; for (i = 0; i < evlist->core.nr_mmaps; i++) { - map[i].core.fd = -1; - map[i].core.overwrite = overwrite; /* * When the perf_mmap() call is made we grab one refcount, plus * one extra to let perf_mmap__consume() get the last @@ -640,8 +638,9 @@ static struct mmap *evlist__alloc_mmap(struct evlist *evlist, * Each PERF_EVENT_IOC_SET_OUTPUT points to this mmap and * thus does perf_mmap__get() on it. */ - refcount_set(&map[i].core.refcnt, 0); + perf_mmap__init(&map[i].core, overwrite); } + return map; }