From: Christopher Covington <cov@codeaurora.org>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
linux-kernel@vger.kernel.org
Cc: Christopher Covington <cov@codeaurora.org>
Subject: [PATCH] RFC: perf: Make overflow signals inheritable
Date: Wed, 25 Jun 2014 16:12:09 -0400 [thread overview]
Message-ID: <1403727129-20665-1-git-send-email-cov@codeaurora.org> (raw)
In order to get a signal from the perf events framework (use an
"event_limit"), one must not not only call perf_event_open() with the
appropriate sample_period, watermark, and wakeup_watermark values,
but also set the FASYNC flag on the resulting file descriptor with
fcntl(). If the inherit attribute is also set, one would expect child
tasks to cause signals like their parents. They don't, though,
because their FASYNC setting isn't set (and can't be by the user
since only the parent has a file descriptor). To fix this, allow the
parent's FASYNC value to be passed along to child events when the
inherit attribute is set. Overflow counts are still per process and
per CPU.
Signed-off-by: Christopher Covington <cov@codeaurora.org>
---
kernel/events/core.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index a33d9a2b..e6c03c6 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5440,11 +5440,6 @@ static int __perf_event_overflow(struct perf_event *event,
perf_adjust_period(event, delta, hwc->last_period, true);
}
- /*
- * XXX event_limit might not quite work as expected on inherited
- * events
- */
-
event->pending_kill = POLL_IN;
if (events && atomic_dec_and_test(&event->event_limit)) {
ret = 1;
@@ -7688,6 +7683,13 @@ inherit_event(struct perf_event *parent_event,
= parent_event->overflow_handler_context;
/*
+ * To ensure that event_limit works at least a little on inherited
+ * events, have the child inherit the parent's fasync setting. Note
+ * that counts are still per process, per CPU.
+ */
+ child_event->fasync = parent_event->fasync;
+
+ /*
* Precalculate sample_data sizes
*/
perf_event__header_size(child_event);
--
Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by the Linux Foundation.
next reply other threads:[~2014-06-25 20:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-25 20:12 Christopher Covington [this message]
2014-07-07 9:13 ` [PATCH] RFC: perf: Make overflow signals inheritable Peter Zijlstra
2014-07-08 15:54 ` Christopher Covington
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403727129-20665-1-git-send-email-cov@codeaurora.org \
--to=cov@codeaurora.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox