lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190913132355.21634-47-jolsa@kernel.org>
Date:   Fri, 13 Sep 2019 15:23:28 +0200
From:   Jiri Olsa <jolsa@...nel.org>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     lkml <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Michael Petlan <mpetlan@...hat.com>
Subject: [PATCH 46/73] libperf: Add perf_mmap__new function

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 <jolsa@...nel.org>
---
 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 <sys/mman.h>
+#include <linux/zalloc.h>
 #include <internal/mmap.h>
 #include <internal/lib.h>
 
@@ -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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ