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>] [day] [month] [year] [list]
Message-Id: <20210129075757.1720900-1-namhyung@kernel.org>
Date:   Fri, 29 Jan 2021 16:57:57 +0900
From:   Namhyung Kim <namhyung@...nel.org>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>
Cc:     Jiri Olsa <jolsa@...hat.com>, Ingo Molnar <mingo@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        LKML <linux-kernel@...r.kernel.org>,
        Stephane Eranian <eranian@...gle.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Ian Rogers <irogers@...gle.com>
Subject: [PATCH v2] perf/core: Wake up tasks for failing pinned events

As of now we don't get any notice for pinned events when it's failed
to be scheduled and make it in an error state not try to schedule it
again.  That means we won't get any samples for the event.

It's possible we can detect it by reading the file, but usually we
only monitor it via mmap-ed ring buffers.  Let's poke the tasks
waiting for poll(2) so that they can respond to the event.

Signed-off-by: Namhyung Kim <namhyung@...nel.org>
---
 include/linux/perf_event.h |  1 +
 kernel/events/core.c       | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 9a38f579bc76..0b3b3e97243b 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -733,6 +733,7 @@ struct perf_event {
 	int				pending_wakeup;
 	int				pending_kill;
 	int				pending_disable;
+	int				pending_pin_error;
 	struct irq_work			pending;
 
 	atomic_t			event_limit;
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 55d18791a72d..f8e9db30a573 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3675,6 +3675,8 @@ static int merge_sched_in(struct perf_event *event, void *data)
 		if (event->attr.pinned) {
 			perf_cgroup_event_disable(event, ctx);
 			perf_event_set_state(event, PERF_EVENT_STATE_ERROR);
+			event->pending_pin_error = 1;
+			irq_work_queue(&event->pending);
 		}
 
 		*can_add_hw = 0;
@@ -5288,6 +5290,9 @@ static __poll_t perf_poll(struct file *file, poll_table *wait)
 	if (is_event_hup(event))
 		return events;
 
+	if (event->attr.pinned && event->state == PERF_EVENT_STATE_ERROR)
+		return EPOLLERR;
+
 	/*
 	 * Pin the event->rb by taking event->mmap_mutex; otherwise
 	 * perf_event_set_output() can swizzle our rb and make us miss wakeups.
@@ -6333,6 +6338,11 @@ static void perf_pending_event(struct irq_work *entry)
 		perf_event_wakeup(event);
 	}
 
+	if (event->pending_pin_error) {
+		event->pending_pin_error = 0;
+		wake_up_all(&event->waitq);
+	}
+
 	if (rctx >= 0)
 		perf_swevent_put_recursion_context(rctx);
 }
-- 
2.30.0.365.g02bc693789-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ