Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp795333ybe; Fri, 13 Sep 2019 06:30:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtFZ3D4PnUCOJi7LZC6hvqF+aVVhlnAz+FuLSTaKRZgEofR/nKxoPDtttAnAmNt/lkEJ/W X-Received: by 2002:a05:6402:1854:: with SMTP id v20mr47689802edy.43.1568381455544; Fri, 13 Sep 2019 06:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568381455; cv=none; d=google.com; s=arc-20160816; b=qP8P7RvCoXoX4/NMj8Wz0wxPQa0la1Ct8nCu+ydJWmOU7zmZnYazq8f4F9D4Lfu5gK SzHye8t4dRca7Cfb88ykvOcrq8Xwnlksyf3oaQIIDTVM3cls2LlRE+TuDll0p9kyq9LR W7209z12wMXwovYLElKNcsNJBL3DBhluJBXIMOrP9MJsLpE0THTBZ8QBmUddSL+Yu9uq MKi8d8mwzfGOcaBwqbVwbJYY1csRwS2RGlgL1qSlYfON/EpNQ9e86fIMLvwEbyNhgIXl ipJpRhq0miQSi4LKYF/06sOxL5TosEXBdqFeDhd0xKTth+XRlQkyWvMq5Jt8JK3+UA2c Nt9A== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LkG6YxYQPGKjufzB11hNJVk5vnJ6hT2C4cLI4hKQlUI=; b=yHp7dNmIXbc0LsU4MYUYPMP8sndHB3x/nROHoH2NhZL9BRU5OXx2oSgz4ctVsf/KzS KApbHyGPv7Q9QkXSM0mV8ItCZcoj038chDWTN2oWHeo7VGr3bkF9nje1h3uOCcSQ/swm claD5JWzByXvxyfTaVbuH0u3tdRx0aBBuMFkyCH1G8/0nyXDrcj2GGRppc5OUyyQmaU1 ksEcJSABR9gMHdweGKVlmRf/bdXuU1P1hW/xiSDFXORscdwK95iHwkshvsIJflSRxeaj vA5JJV4LXIfRqVwb0JfNIC0tp6TJYBMKzX4Ha+Ptok60MnVHLHbZ8ixWOGZsNP4CTs8S ryMg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3si14743563ejb.95.2019.09.13.06.30.22; Fri, 13 Sep 2019 06:30:55 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391411AbfIMNZk (ORCPT + 99 others); Fri, 13 Sep 2019 09:25:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60932 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391402AbfIMNZh (ORCPT ); Fri, 13 Sep 2019 09:25:37 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 37F5C50F4D; Fri, 13 Sep 2019 13:25:37 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92D145C1D4; Fri, 13 Sep 2019 13:25:35 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 39/73] libperf: Add perf_mmap__init function Date: Fri, 13 Sep 2019 15:23:21 +0200 Message-Id: <20190913132355.21634-40-jolsa@kernel.org> In-Reply-To: <20190913132355.21634-1-jolsa@kernel.org> References: <20190913132355.21634-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 13 Sep 2019 13:25:37 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding perf_mmap__init function to initialize 'struct perf_mmap' object. Adding it to new mmap.c object, that will carry all the mmap related functions. Link: http://lkml.kernel.org/n/tip-hvilw6n69knpyhdndrslgtdu@git.kernel.org Signed-off-by: Jiri Olsa --- 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 c31f1c111f8f..2ef9a4ec6d99 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 a147b25c4b88..e95fc51e5bd0 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 000000000000..3da6177510e6 --- /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 dcc4accd3180..0d1ae00d22f3 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -604,8 +604,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 @@ -615,8 +613,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; } -- 2.21.0