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]
Date:	Sun,  7 Feb 2010 12:30:58 +0100
From:	highguy@...il.com
To:	mingo@...e.hu, linux-kernel@...r.kernel.org
Cc:	torvalds@...ux-foundation.org, efault@....de,
	a.p.zijlstra@...llo.nl, andrea@...e.de, tglx@...utronix.de,
	akpm@...ux-foundation.org, peterz@...radead.org,
	Stijn Devriendt <HIGHGuY@...il.com>
Subject: [PATCH 5/6] Allow decrementing counters

From: Stijn Devriendt <HIGHGuY@...il.com>

---
 include/linux/perf_event.h |    6 +++---
 kernel/perf_event.c        |   16 ++++++++--------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 4f7d318..084f322 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -515,7 +515,7 @@ struct pmu {
 	void (*disable)			(struct perf_event *event);
 	void (*update)			(struct perf_event *event);
 	void (*unthrottle)		(struct perf_event *event);
-	u64 (*add)                      (struct perf_event *event, u64 count);
+	u64 (*add)                      (struct perf_event *event, s64 count);
 	int (*reset)                    (struct perf_event *event);
 	void (*wakeup)                  (struct perf_event *event);
 	u64 (*read)                     (struct perf_event *event);
@@ -826,10 +826,10 @@ static inline int is_software_event(struct perf_event *event)
 
 extern atomic_t perf_swevent_enabled[PERF_COUNT_SW_MAX];
 
-extern void __perf_sw_event(u32, u64, int, struct pt_regs *, u64);
+extern void __perf_sw_event(u32, s64, int, struct pt_regs *, u64);
 
 static inline void
-perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
+perf_sw_event(u32 event_id, s64 nr, int nmi, struct pt_regs *regs, u64 addr)
 {
 	if (atomic_read(&perf_swevent_enabled[event_id]))
 		__perf_sw_event(event_id, nr, nmi, regs, addr);
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 724aafd..08885d0 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -3770,12 +3770,12 @@ static void perf_event_wakeup_one(struct perf_event *event)
 	wake_up(&event->waitq);
 }
 
-static u64 __perf_event_add(struct perf_event *event, u64 count)
+static u64 __perf_event_add(struct perf_event *event, s64 count)
 {
 	return atomic64_add_return(count, &event->count);
 }
 
-static u64 perf_event_add(struct perf_event *event, u64 count)
+static u64 perf_event_add(struct perf_event *event, s64 count)
 {
 	if (event->pmu->add)
 		return event->pmu->add(event, count);
@@ -3856,7 +3856,7 @@ static void perf_swevent_unthrottle(struct perf_event *event)
 	 */
 }
 
-static void perf_swevent_add(struct perf_event *event, u64 nr,
+static void perf_swevent_add(struct perf_event *event, s64 nr,
 			       int nmi, struct perf_sample_data *data,
 			       struct pt_regs *regs)
 {
@@ -3870,10 +3870,10 @@ static void perf_swevent_add(struct perf_event *event, u64 nr,
 	if (!hwc->sample_period)
 		return;
 
-	if (nr == 1 && hwc->sample_period == 1 && !event->attr.freq)
+	if (abs(nr) == 1 && hwc->sample_period == 1 && !event->attr.freq)
 		return perf_swevent_overflow(event, 1, nmi, data, regs);
 
-	if (atomic64_add_negative(nr, &hwc->period_left))
+	if (atomic64_add_negative(abs(nr), &hwc->period_left))
 		return;
 
 	perf_swevent_overflow(event, 0, nmi, data, regs);
@@ -3956,7 +3956,7 @@ static int perf_swevent_match(struct perf_event *event,
 
 static void perf_swevent_ctx_event(struct perf_event_context *ctx,
 				     enum perf_type_id type,
-				     u32 event_id, u64 nr, int nmi,
+				     u32 event_id, s64 nr, int nmi,
 				     struct perf_sample_data *data,
 				     struct pt_regs *regs)
 {
@@ -4004,7 +4004,7 @@ void perf_swevent_put_recursion_context(int rctx)
 EXPORT_SYMBOL_GPL(perf_swevent_put_recursion_context);
 
 static void do_perf_sw_event(enum perf_type_id type, u32 event_id,
-				    u64 nr, int nmi,
+				    s64 nr, int nmi,
 				    struct perf_sample_data *data,
 				    struct pt_regs *regs)
 {
@@ -4025,7 +4025,7 @@ static void do_perf_sw_event(enum perf_type_id type, u32 event_id,
 	rcu_read_unlock();
 }
 
-void __perf_sw_event(u32 event_id, u64 nr, int nmi,
+void __perf_sw_event(u32 event_id, s64 nr, int nmi,
 			    struct pt_regs *regs, u64 addr)
 {
 	struct perf_sample_data data;
-- 
1.6.6

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