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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1385725510-20118-3-git-send-email-jolsa@redhat.com>
Date:	Fri, 29 Nov 2013 12:45:06 +0100
From:	Jiri Olsa <jolsa@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	Jiri Olsa <jolsa@...hat.com>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...e.hu>,
	Namhyung Kim <namhyung@...nel.org>,
	Paul Mackerras <paulus@...ba.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	David Ahern <dsahern@...il.com>,
	Andi Kleen <andi@...stfloor.org>
Subject: [PATCH 2/6] perf tools: Add PERF_EVLIST__ERRNO_MMAP internal error

Adding internal error (PERF_EVLIST__ERRNO_MMAP) for case
when 'mmap' syscall fails.

Signed-off-by: Jiri Olsa <jolsa@...hat.com>
Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: David Ahern <dsahern@...il.com>
Cc: Andi Kleen <andi@...stfloor.org>
---
 tools/perf/util/evlist.c | 28 ++++++++++++++++++++++++++++
 tools/perf/util/evlist.h |  1 +
 2 files changed, 29 insertions(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index dfb72d4..d156f0a 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -605,6 +605,28 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
 	return evlist->mmap != NULL ? 0 : -ENOMEM;
 }
 
+static void strerror_mmap(struct perf_evlist *evlist,
+			  char *buf, size_t size)
+{
+	int err_libc = evlist->err_libc;
+
+	switch (evlist->err_libc) {
+	case EPERM:
+		scnprintf(buf, size,
+			"Permission error mapping pages.\n"
+			"Consider increasing "
+			"/proc/sys/kernel/perf_event_mlock_kb,\n"
+			"or try again with a smaller value of -m/--mmap_pages.\n"
+			"(current size: %dB)\n", evlist->mmap_len);
+		break;
+	default:
+		scnprintf(buf, size,
+			"Failed to mmap events with error %d (%s)\n",
+			err_libc, strerror(err_libc));
+		break;
+	}
+}
+
 static void __perf_evlist__strerror(struct perf_evlist *evlist,
 				    char *buf, size_t size)
 {
@@ -614,6 +636,9 @@ static void __perf_evlist__strerror(struct perf_evlist *evlist,
 	switch (err) {
 	case PERF_EVLIST__ERRNO_SUCCESS:
 		break;
+	case PERF_EVLIST__ERRNO_MMAP:
+		strerror_mmap(evlist, buf, size);
+		return;
 	default:
 		scnprintf(buf, size, "Unknown error\n");
 		return;
@@ -642,6 +667,7 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist,
 				      MAP_SHARED, fd, 0);
 
 	if (evlist->mmap[idx].base == MAP_FAILED) {
+		SET_ERR(MMAP);
 		pr_debug2("failed to mmap perf event ring buffer, error %d\n",
 			  errno);
 		evlist->mmap[idx].base = NULL;
@@ -821,6 +847,8 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
 	const struct thread_map *threads = evlist->threads;
 	int prot = PROT_READ | (overwrite ? 0 : PROT_WRITE), mask;
 
+	SET_ERR(SUCCESS);
+
 	if (evlist->mmap == NULL && perf_evlist__alloc_mmap(evlist) < 0)
 		return -ENOMEM;
 
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 9832fbd..02df99a 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -19,6 +19,7 @@ struct perf_record_opts;
 
 enum {
 	PERF_EVLIST__ERRNO_SUCCESS		= 0,
+	PERF_EVLIST__ERRNO_MMAP			= 1,
 };
 
 struct perf_mmap {
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ