Resend it with singed-off header
commit 1cff5e3c6d177638506ca953d3d757aca6bd51fd
Author: Xu,Anhua <[email protected]>
Date: Wed Feb 8 16:52:33 2012 +0800
performance_counter01: update syscall and fix endless loop
performance counter currently are named performance events. The
original perf data structure were deprecated. Add checking for
returned value from read and complete the reading loop for at
most 100 times if no error occurs
Signed-off-by: Anhua Xu <[email protected]>
diff --git a/testcases/kernel/performance_counters/performance_counter01.c
b/testcases/kernel/performance_counters/performance_counter01.c
index af89f48..b96d22a 100644
--- a/testcases/kernel/performance_counters/performance_counter01.c
+++ b/testcases/kernel/performance_counters/performance_counter01.c
@@ -37,6 +37,8 @@
#include <stdio.h>
#include <fcntl.h>
+#include <linux/perf_event.h>
+
/* Harness Specific Include Files. */
#include "test.h"
#include "usctest.h"
@@ -49,13 +51,13 @@ extern char *TESTDIR; /* temporary dir
created by tst_tmpdir() */
char *TCID = "performance_counter01"; /* test program identifier.
*/
int TST_TOTAL = 1;
-enum hw_event_types {
- PERF_COUNT_CYCLES,
- PERF_COUNT_INSTRUCTIONS,
- PERF_COUNT_CACHE_REFERENCES,
- PERF_COUNT_CACHE_MISSES,
- PERF_COUNT_BRANCH_INSTRUCTIONS,
- PERF_COUNT_BRANCH_MISSES,
+static struct perf_event_attr default_attrs[] = {
+ {.type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CPU_CYCLES
},
+ {.type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_INSTRUCTIONS
},
+ {.type = PERF_TYPE_HARDWARE, .config =
PERF_COUNT_HW_BRANCH_INSTRUCTIONS },
+ {.type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_MISSES
},
+ {.type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CACHE_MISSES
},
+ {.type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CACHE_REFERENCES
},
};
void cleanup(void) { /* Stub function. */ }
@@ -63,17 +65,17 @@ void cleanup(void) { /* Stub function. */ }
int
main(void) {
- unsigned long long count1, count2;
+ unsigned long long count1, count2, loop = 100;
int fd1, fd2, ret;
fd1 = syscall(__NR_perf_event_open,
- PERF_COUNT_INSTRUCTIONS, 0, 0, 0, -1);
+ &default_attrs[1], 0, -1, -1, 0);
if (fd1 < 0) {
tst_brkm(TBROK | TERRNO, cleanup,
"Failed to create PERF_COUNT_INSTRUCTIONS fd");
}
fd2 = syscall(__NR_perf_event_open,
- PERF_COUNT_CACHE_MISSES, 0, 0, 0, -1);
+ &default_attrs[4], 0, -1, -1, 0);
if (fd2 < 0) {
tst_brkm(TBROK | TERRNO, cleanup,
"Failed to create PERF_COUNT_CACHE_MISSES fd");
@@ -83,11 +85,15 @@ main(void) {
ret = read(fd1, &count1, sizeof(count1));
- if (ret == sizeof(count1)) {
+ if (ret < sizeof(count1))
+ break;
+ else {
ret = read(fd2, &count2, sizeof(count2));
+ if (ret < sizeof(count2))
+ break;
+ else {
- if (ret == sizeof(count2)) {
tst_resm(TINFO,
"counter1 value: %Ld instructions",
count1);
@@ -99,7 +105,12 @@ main(void) {
}
- } while (ret == sizeof(unsigned long long));
+ } while (loop --);
+
+ if (ret < sizeof(count1) || ret < sizeof(count2))
+ tst_resm(TFAIL, "perf_counter read error");
+ else
+ tst_resm(TPASS, "test passed");
tst_exit();
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list