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-next>] [day] [month] [year] [list]
Message-Id: <1268288259-4011-1-git-send-email-eranian@google.com>
Date:	Wed, 10 Mar 2010 22:17:39 -0800
From:	eranian@...gle.com
To:	linux-kernel@...r.kernel.org
Cc:	peterz@...radead.org, mingo@...e.hu, paulus@...ba.org,
	fweisbec@...il.com, robert.richter@....com, davem@...emloft.net,
	perfmon2-devel@...ts.sf.net, eranian@...il.com
Subject: [PATCH] perf_events: fix X86 bogus counts when multiplexing

This patch fixes a bug in 2.6.33 X86 event scheduling whereby
all counts are bogus as soon as events need to be multiplexed
because the PMU is overcommitted.

The code in hw_perf_enable() was causing multiplexed events
to accumulate collected counts twice causing bogus results.

This is demonstrated on AMD Barcelona with the example
below. First run, no conflict, you obtain the actual counts.
Second run, PMU overcommitted, multiplexing, all events are
over-counted. Third run, patch applied, you obtain the correct
count through scaling.

Intel processors would be affected in the same way.

	# perf stat -e instructions,cycles ./noploop 10
	noploop for 10 seconds
	
	 Performance counter stats for './noploop 10':
	
	        10884992991  instructions             #      0.495 IPC  
	        21976457932  cycles                  
	
	       10.000906311  seconds time elapsed
	
	# perf stat -e instructions,instructions,instructions,instructions,cycles ./noploop 10
	noploop for 10 seconds
	
	 Performance counter stats for './noploop 10':
	
	        16342703033  instructions             #      1.000 IPC    (scaled from 80.00%)
	        16337667144  instructions             #      0.999 IPC    (scaled from 80.00%)
	        16342494809  instructions             #      1.000 IPC    (scaled from 80.00%)
	        16344432632  instructions             #      1.000 IPC    (scaled from 80.00%)
	        16346620711  cycles                    (scaled from 80.00%)
	
	       10.015941304  seconds time elapsed
	
	# perf stat -e instructions,instructions,instructions,instructions,cycles ./noploop 10
	noploop for 10 seconds
	
	 Performance counter stats for './noploop 10':
	
	        10865832804  instructions             #      0.495 IPC    (scaled from 80.00%)
	        10866436957  instructions             #      0.495 IPC    (scaled from 80.00%)
	        10866172153  instructions             #      0.495 IPC    (scaled from 80.00%)
	        10866276672  instructions             #      0.495 IPC    (scaled from 80.00%)
	        21944300714  cycles                    (scaled from 80.00%)
	
	       10.000686860  seconds time elapsed
	
	Signed-off-by: Stephane Eranian <eranian@...gle.com>
--
 perf_event.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 97cddbf..ef5d63f 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -818,8 +818,6 @@ void hw_perf_enable(void)
 			    match_prev_assignment(hwc, cpuc, i))
 				continue;
 
-			x86_pmu_stop(event);
-
 			hwc->idx = -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