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: <1516047651-164336-4-git-send-email-kan.liang@intel.com>
Date:   Mon, 15 Jan 2018 12:20:39 -0800
From:   kan.liang@...el.com
To:     acme@...nel.org, peterz@...radead.org, mingo@...hat.com,
        linux-kernel@...r.kernel.org
Cc:     wangnan0@...wei.com, jolsa@...nel.org, namhyung@...nel.org,
        ak@...ux.intel.com, yao.jin@...ux.intel.com,
        Kan Liang <kan.liang@...el.com>
Subject: [PATCH V4 03/15] perf mmap: use perf_mmap__read_init() in perf_mmap__push()

From: Kan Liang <kan.liang@...el.com>

Apply the generic perf_mmap__read_init() to perf_mmap__push().

'size' is needed for both perf_mmap__read_init() and perf_mmap__push().
Have to calculate in each function.

Signed-off-by: Kan Liang <kan.liang@...el.com>
---
 tools/perf/util/mmap.c | 32 ++++++--------------------------
 1 file changed, 6 insertions(+), 26 deletions(-)

diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index 414089f..7c5cbdc 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -313,38 +313,18 @@ int perf_mmap__read_init(struct perf_mmap *map, bool overwrite,
 int perf_mmap__push(struct perf_mmap *md, bool overwrite,
 		    void *to, int push(void *to, void *buf, size_t size))
 {
-	u64 head = perf_mmap__read_head(md);
-	u64 old = md->prev;
-	u64 end = head, start = old;
 	unsigned char *data = md->base + page_size;
+	u64 head = perf_mmap__read_head(md);
 	unsigned long size;
+	u64 end, start;
 	void *buf;
-	int rc = 0;
+	int rc;
 
-	start = overwrite ? head : old;
-	end = overwrite ? old : head;
-
-	if (start == end)
-		return 0;
+	rc = perf_mmap__read_init(md, overwrite, &start, &end);
+	if (rc < 0)
+		return (rc == -EAGAIN) ? 0 : -1;
 
 	size = end - start;
-	if (size > (unsigned long)(md->mask) + 1) {
-		if (!overwrite) {
-			WARN_ONCE(1, "failed to keep up with mmap data. (warn only once)\n");
-
-			md->prev = head;
-			perf_mmap__consume(md, overwrite);
-			return 0;
-		}
-
-		/*
-		 * Backward ring buffer is full. We still have a chance to read
-		 * most of data from it.
-		 */
-		if (overwrite_rb_find_range(data, md->mask, head, &start, &end))
-			return -1;
-	}
-
 	if ((start & md->mask) + size != (end & md->mask)) {
 		buf = &data[start & md->mask];
 		size = md->mask + 1 - (start & md->mask);
-- 
2.5.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ