Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1403307ybe; Fri, 13 Sep 2019 16:23:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEG2SDC4ltULw9JXg6rVuZlX55SOMY+f7bF7xYvdTXkCIg2eGjquMyHv6Qs1pEgfgId+Ht X-Received: by 2002:aa7:d40d:: with SMTP id z13mr49110207edq.229.1568416995103; Fri, 13 Sep 2019 16:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568416995; cv=none; d=google.com; s=arc-20160816; b=gord/N1QIqky2qIvVlnTRkm6HKrYJg7ywUVbnuwye12zbmc42IITLjws3etmKaxdjA gQiA3hojew6VjutfrmD5GHyllRtw76+cXWMK2CF9AharFX648RKGFrNVzwyTBLJ6K48A BMld5YkHlz6FKtjUmFkjWSS10tnPrTSCAJfilE3LhkPwMAXMsZjJ0GLdv2gBqeS6F4MM FlV7XlWQPcQGDFK7U02NJ2tUaLAnNY45R8pen7vTe+bz3lJPuyji+l6Z2mtDaEuorgQs FqZtt+LnmaX/y2LpdWpWnBon3olBgj3I6ZToPNvJiSPdOtChFejZHmVEkLMoU51KnBMa C14Q== 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=ZNXhDvbXPIEToc3YqIsLyFrusI3SjyC5IwinbOFzIYc=; b=NxRGl/pigY0Yy1v2jPUfiH+Qt3dbLAkmYNMud0mL9vphVwvgduW7DJFp4W0Wgd6bC2 6QNUQ85vspQ3WyXRUstyzcmOxUZYBB7aTwSd6gtQOp9nqgs5/PoMTzYNnFGoIfmTwArh liywKKUdnzBp1cLSN8sPgxAyE0o2KUpIB62FP63PXdcWGmDIqLQ43JcPEX/seJ046/l9 CbkfrChTL5YYt0eweekNTd6fsTn+8JauVWS2VvQflvDKHAa9LSp074Eg8RA4WnZ4Y0hY j+ZukuB5QBH+f2weUhbP+/bpP8mMrZG7GcIDVOkCsEHvH/RvjHWNyAc57FdlVSb+CMKN n/IA== 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 g3si8127822ejk.387.2019.09.13.16.22.51; Fri, 13 Sep 2019 16:23:15 -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 S2391484AbfIMNZ6 (ORCPT + 99 others); Fri, 13 Sep 2019 09:25:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42600 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391458AbfIMNZx (ORCPT ); Fri, 13 Sep 2019 09:25:53 -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 27E2686679; Fri, 13 Sep 2019 13:25:53 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82EFA5C1D4; Fri, 13 Sep 2019 13:25:51 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 46/73] libperf: Add perf_mmap__new function Date: Fri, 13 Sep 2019 15:23:28 +0200 Message-Id: <20190913132355.21634-47-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.26]); Fri, 13 Sep 2019 13:25:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding perf_mmap__new function to create and initialize new 'struct perf_mmap' object to internal header internal/mmap.h Link: http://lkml.kernel.org/n/tip-e0zucg7w3h6j1hrq0cq2v8kc@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/lib/include/internal/mmap.h | 2 ++ tools/perf/lib/mmap.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/tools/perf/lib/include/internal/mmap.h b/tools/perf/lib/include/internal/mmap.h index cc0a5995cd3c..31946e26368a 100644 --- a/tools/perf/lib/include/internal/mmap.h +++ b/tools/perf/lib/include/internal/mmap.h @@ -41,6 +41,8 @@ struct perf_mmap_param { size_t perf_mmap__mmap_len(struct perf_mmap *map); +struct perf_mmap *perf_mmap__new(bool overwrite, + libperf_unmap_cb_t unmap_cb); void perf_mmap__init(struct perf_mmap *map, bool overwrite, libperf_unmap_cb_t unmap_cb); int perf_mmap__mmap(struct perf_mmap *map, struct perf_mmap_param *mp, diff --git a/tools/perf/lib/mmap.c b/tools/perf/lib/mmap.c index ea46f325fa98..720dda578ed9 100644 --- a/tools/perf/lib/mmap.c +++ b/tools/perf/lib/mmap.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include @@ -12,6 +13,16 @@ void perf_mmap__init(struct perf_mmap *map, bool overwrite, refcount_set(&map->refcnt, 0); } +struct perf_mmap *perf_mmap__new(bool overwrite, libperf_unmap_cb_t unmap_cb) +{ + struct perf_mmap *map = zalloc(sizeof(*map)); + + if (map) + perf_mmap__init(map, overwrite, unmap_cb); + + return map; +} + size_t perf_mmap__mmap_len(struct perf_mmap *map) { return map->mask + 1 + page_size; -- 2.21.0