Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4261316ybp; Mon, 7 Oct 2019 05:57:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiYJZP4z0zCDj8Ft5br0oPkWlAnzaJyGLrxrxe60stUQvgLV42IvfE5fdOEdj0H7tTImB2 X-Received: by 2002:a50:9402:: with SMTP id p2mr28892364eda.111.1570453068385; Mon, 07 Oct 2019 05:57:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570453068; cv=none; d=google.com; s=arc-20160816; b=0UgwBIu5Zqxquyz1lb6LU71kZLbUsdwHbN445wANCiAMtqcfs5eq3/rPS1OfyYb7XC 2ccj/ge8OMxlotOeGA0RhK7sbxic4KMZL2ay4ZniNt11ugouivv7rm59PaI2zVwjkHBw cMKQ9+FxiInkWPe8Gtja+7ogf45psgQcFDZs7XNXSqMGVXmQljIrQ6tXCkp63XS7pMyz Jq+fSdxj8YkWGA5pkj/5K364dG+vM70ECBVR3JgVQ8vBUwpWtB1XveQ4riajjKAgWvys N7ceFugjFSqv/nWlDax2h3UmrimZMMwO4n2CTt5nM3SKfNgedE3iROuSVXRGMFKi+fZm UVcA== 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=pZy94/u7SmBlVdFCWy6+Yh9IxRxTxcVff+dQ0SwtVrM=; b=pDqAgaHNxFs31bEpiZm02YDoX4zl28Hs27tF9vzWLrQWct61D2E+Ax5cq9eM44Spo1 gnt1QJiT0IQDLo7S+VYfILEeuMWl9jnOxz9pKpocQbEonFYp7GA5jZEAhr67xc1nQv3h KQFO31cedoP9vOJ7CIjLEM+vdW2YTqyUbfAcQMu9rUWxCF25kxEniKT4EMJJP+x3EfLq JcQAVa/fIuXkcmwx0PdlhVJyyZBtwXQ5amk/QWLrcsm4+9aQsXT749Td6CCgRAajcwMB lbXXlF2lfmNZBBZJqByt5XX+n/w7CsLtC+YrLcziLa78hQ8rDarR1M/+L1Hlha9LB12s UOUA== 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 a2si8352512edc.321.2019.10.07.05.57.25; Mon, 07 Oct 2019 05:57:48 -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 S1727876AbfJGMxv (ORCPT + 99 others); Mon, 7 Oct 2019 08:53:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52264 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727490AbfJGMxu (ORCPT ); Mon, 7 Oct 2019 08:53:50 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 2CECD18C4272; Mon, 7 Oct 2019 12:53:50 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CF975D9CD; Mon, 7 Oct 2019 12:53:48 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Alexander Shishkin , Michael Petlan , Namhyung Kim , Peter Zijlstra , lkml , Ingo Molnar Subject: [PATCH 01/36] libperf: Add perf_mmap__init() function Date: Mon, 7 Oct 2019 14:53:09 +0200 Message-Id: <20191007125344.14268-2-jolsa@kernel.org> In-Reply-To: <20191007125344.14268-1-jolsa@kernel.org> References: <20191007125344.14268-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Mon, 07 Oct 2019 12:53:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add perf_mmap__init() function to initialize 'struct perf_mmap' object. Add it to a new mmap.c object, 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/20190913132355.21634-40-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 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 ba1e519c15b9..e25890de6a55 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 d277a98e62df..633a407b1294 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -605,8 +605,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 @@ -616,8 +614,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