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: <1380113447-17144-10-git-send-email-jolsa@redhat.com>
Date:	Wed, 25 Sep 2013 14:50:35 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	Jiri Olsa <jolsa@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...e.hu>, Paul Mackerras <paulus@...ba.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: [PATCH 09/21] perf: Account toggle masters for toggled event

Keep track of toggle events within the toggled event.
It'll be handy for toggle inherit support.

Signed-off-by: Jiri Olsa <jolsa@...hat.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 include/linux/perf_event.h | 1 +
 kernel/events/core.c       | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 6ede25c..801ff22 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -423,6 +423,7 @@ struct perf_event {
 	struct perf_event		*toggled_event;
 	enum perf_event_toggle_flag	toggle_flag;
 	int				paused;
+	atomic_t			toggled_cnt;
 #endif /* CONFIG_PERF_EVENTS */
 };
 
diff --git a/kernel/events/core.c b/kernel/events/core.c
index f5f00a6..7df7a21 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1372,6 +1372,7 @@ static void __perf_event_toggle_detach(struct perf_event *event)
 	event->overflow_handler = NULL;
 	event->toggled_event    = NULL;
 
+	atomic_dec(&toggled_event->toggled_cnt);
 	put_event(toggled_event);
 }
 
@@ -7064,6 +7065,8 @@ static int perf_event_set_toggle_fd(struct perf_event *event, u64 __user *arg)
 	err = perf_event_set_toggle(event, toggled_event, event->ctx, flag);
 	if (err)
 		put_event(toggled_event);
+	else
+		atomic_inc(&toggled_event->toggled_cnt);
 
 	fdput(toggled_fd);
 	return err;
@@ -7251,6 +7254,8 @@ SYSCALL_DEFINE5(perf_event_open,
 		if (!atomic_long_inc_not_zero(&toggled_event->refcount))
 			goto err_context;
 
+		atomic_inc(&toggled_event->toggled_cnt);
+
 		err = perf_event_set_toggle(event, toggled_event, ctx, flags);
 		if (err)
 			goto err_toggle;
@@ -7328,8 +7333,10 @@ SYSCALL_DEFINE5(perf_event_open,
 	return event_fd;
 
 err_toggle:
-	if (toggled_event)
+	if (toggled_event) {
+		atomic_dec(&toggled_event->toggled_cnt);
 		put_event(toggled_event);
+	}
 err_context:
 	perf_unpin_context(ctx);
 	put_ctx(ctx);
-- 
1.7.11.7

--
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