test: Add testcase for #1001
Refs: #1001 Change-Id: I3edd750108bd3f887af1f0afe3f2651f1243062b
This commit is contained in:
committed by
Masamichi Takagi
parent
786649d2a3
commit
d4fa953975
63
test/issues/1001/C1001.sh
Normal file
63
test/issues/1001/C1001.sh
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/bin/sh
|
||||
if [ -f $HOME/mck_test_config ]; then
|
||||
. $HOME/mck_test_config
|
||||
else
|
||||
BIN=
|
||||
SBIN=
|
||||
OSTEST=
|
||||
fi
|
||||
BOOTPARAM="-c 1-7,9-15,17-23,25-31 -m 10G@0,10G@1 -r 1-7:0+9-15:8+17-23:16+25-31:24"
|
||||
|
||||
if [ "x$BINDIR" = x ];then
|
||||
BINDIR="$BIN"
|
||||
fi
|
||||
|
||||
if [ "x$SBINDIR" = x ];then
|
||||
SBINDIR="$SBIN"
|
||||
fi
|
||||
|
||||
if [ "x$OSTESTDIR" = x ]; then
|
||||
OSTESTDIR="$OSTEST"
|
||||
fi
|
||||
|
||||
if [ "x$LTPDIR" = x ]; then
|
||||
LTPDIR="$LTP"
|
||||
fi
|
||||
|
||||
if [ ! -x $SBINDIR/mcstop+release.sh ]; then
|
||||
echo mcstop+release: not found >&2
|
||||
exit 1
|
||||
fi
|
||||
echo -n "mcstop+release.sh ... "
|
||||
sudo $SBINDIR/mcstop+release.sh
|
||||
echo "done"
|
||||
|
||||
if [ ! -x $SBINDIR/mcreboot.sh ]; then
|
||||
echo mcreboot: not found >&2
|
||||
exit 1
|
||||
fi
|
||||
echo -n "mcreboot.sh $BOOTPARAM ... "
|
||||
sudo $SBINDIR/mcreboot.sh $BOOTPARAM
|
||||
echo "done"
|
||||
|
||||
if [ ! -x $BINDIR/mcexec ]; then
|
||||
echo mcexec: not found >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
$BINDIR/mcexec ./CT_001
|
||||
$BINDIR/mcexec ./CT_002
|
||||
./CT_003
|
||||
./CT_004
|
||||
|
||||
tid=001
|
||||
echo "*** LT_$tid start *******************************"
|
||||
$BINDIR/mcexec $LTPDIR/bin/perf_event_open01 2>&1 | tee ./LT_${tid}.txt
|
||||
ok=`grep TPASS LT_${tid}.txt | wc -l`
|
||||
ng=`grep TFAIL LT_${tid}.txt | wc -l`
|
||||
if [ $ng = 0 ]; then
|
||||
echo "*** LT_$tid: PASSED (ok:$ok)"
|
||||
else
|
||||
echo "*** LT_$tid: FAILED (ok:$ok, ng:$ng)"
|
||||
fi
|
||||
echo ""
|
||||
124
test/issues/1001/CT_001.c
Normal file
124
test/issues/1001/CT_001.c
Normal file
@@ -0,0 +1,124 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/perf_event.h>
|
||||
#include "./test_chk.h"
|
||||
|
||||
#include "./perf_tool.h"
|
||||
|
||||
#define TEST_NAME "CT_001"
|
||||
|
||||
#define NUM_CNTR 1
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fds[NUM_CNTR];
|
||||
long long tmp_count;
|
||||
long long counts[NUM_CNTR];
|
||||
__u32 configs[NUM_CNTR] = {
|
||||
PERF_COUNT_HW_INSTRUCTIONS};
|
||||
char *config_names[NUM_CNTR] = {
|
||||
"INSTRUCTIONS"};
|
||||
struct perf_event_attr pe_attr;
|
||||
int group_fd = -1;
|
||||
|
||||
int rc = 0;
|
||||
int i = 0;
|
||||
int chk_fail = 0;
|
||||
|
||||
printf("*** %s start *******************************\n", TEST_NAME);
|
||||
|
||||
// common config
|
||||
memset(&pe_attr, 0, sizeof(struct perf_event_attr));
|
||||
pe_attr.size = sizeof(struct perf_event_attr);
|
||||
pe_attr.disabled = 1;
|
||||
pe_attr.exclude_kernel = 1;
|
||||
pe_attr.exclude_user = 0;
|
||||
pe_attr.type = PERF_TYPE_HARDWARE;
|
||||
|
||||
chk_fail = 0;
|
||||
// perf_event_open
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
pe_attr.config = configs[i];
|
||||
|
||||
fds[i] = perf_event_open(&pe_attr, 0, -1, group_fd, 0);
|
||||
if (fds[i] == -1) {
|
||||
chk_fail = 1;
|
||||
break;
|
||||
}
|
||||
if (group_fd == -1) {
|
||||
group_fd = fds[i];
|
||||
}
|
||||
}
|
||||
OKNG(chk_fail != 0, "perf_event_open for %d counter", NUM_CNTR);
|
||||
|
||||
// reset counters
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
rc = ioctl(fds[i], PERF_EVENT_IOC_RESET, 0);
|
||||
CHKANDJUMP(rc != 0, "ioctl RESET");
|
||||
}
|
||||
|
||||
chk_fail = 0;
|
||||
// read counters at first
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
rc = read(fds[i], &tmp_count, sizeof(long long));
|
||||
CHKANDJUMP(rc == -1, "read counter[%d]", i);
|
||||
printf("%-16s: %ld\n", config_names[i], tmp_count);
|
||||
if (tmp_count != 0) {
|
||||
chk_fail = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
OKNG(chk_fail != 0, "Reset counter to 0");
|
||||
|
||||
// start counters at once
|
||||
rc = ioctl(group_fd, PERF_EVENT_IOC_ENABLE, PERF_IOC_FLAG_GROUP);
|
||||
OKNG(rc != 0, "Start counter at once");
|
||||
|
||||
// monitoring target
|
||||
printf(" do some processing...\n");
|
||||
calc_task();
|
||||
memory_task();
|
||||
|
||||
// stop counters at once
|
||||
rc = ioctl(group_fd, PERF_EVENT_IOC_DISABLE, PERF_IOC_FLAG_GROUP);
|
||||
OKNG(rc != 0, "Stop counter at once");
|
||||
|
||||
printf(" counted value is as belows...\n");
|
||||
// read counters after processing
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
rc = read(fds[i], &tmp_count, sizeof(long long));
|
||||
CHKANDJUMP(rc == -1, "read counter[%d]", i);
|
||||
printf("%-16s: %ld\n", config_names[i], tmp_count);
|
||||
counts[i] = tmp_count;
|
||||
}
|
||||
|
||||
printf(" processing again... (to check if counter is stopped)\n");
|
||||
// processing again (counters are stopped)
|
||||
calc_task();
|
||||
memory_task();
|
||||
|
||||
printf(" current value is bellow\n"
|
||||
" (expected to be same value as last time)\n");
|
||||
|
||||
chk_fail = 0;
|
||||
// read counters again to check if counters were stopped
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
rc = read(fds[i], &tmp_count, sizeof(long long));
|
||||
printf("%-16s: %ld\n", config_names[i], tmp_count);
|
||||
if (counts[i] != tmp_count) {
|
||||
chk_fail = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
OKNG(chk_fail != 0, "Counter is stopped");
|
||||
|
||||
printf("*** %s PASSED\n\n", TEST_NAME);
|
||||
|
||||
return 0;
|
||||
|
||||
fn_fail:
|
||||
printf("*** %s FAILED\n\n", TEST_NAME);
|
||||
|
||||
return -1;
|
||||
}
|
||||
130
test/issues/1001/CT_002.c
Normal file
130
test/issues/1001/CT_002.c
Normal file
@@ -0,0 +1,130 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/perf_event.h>
|
||||
#include "./test_chk.h"
|
||||
|
||||
#include "./perf_tool.h"
|
||||
|
||||
#define TEST_NAME "CT_002"
|
||||
|
||||
#define NUM_CNTR 4
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fds[NUM_CNTR];
|
||||
long long tmp_count;
|
||||
long long counts[NUM_CNTR];
|
||||
__u32 configs[NUM_CNTR] = {
|
||||
PERF_COUNT_HW_INSTRUCTIONS,
|
||||
PERF_COUNT_HW_CACHE_REFERENCES,
|
||||
PERF_COUNT_HW_CACHE_MISSES,
|
||||
PERF_COUNT_HW_BRANCH_MISSES};
|
||||
char *config_names[NUM_CNTR] = {
|
||||
"INSTRUCTIONS",
|
||||
"CACHE_REFERENCES",
|
||||
"CACHE_MISSES",
|
||||
"BRANCH_MISSES"};
|
||||
struct perf_event_attr pe_attr;
|
||||
int group_fd = -1;
|
||||
|
||||
int rc = 0;
|
||||
int i = 0;
|
||||
int chk_fail = 0;
|
||||
|
||||
printf("*** %s start *******************************\n", TEST_NAME);
|
||||
|
||||
// common config
|
||||
memset(&pe_attr, 0, sizeof(struct perf_event_attr));
|
||||
pe_attr.size = sizeof(struct perf_event_attr);
|
||||
pe_attr.disabled = 1;
|
||||
pe_attr.exclude_kernel = 1;
|
||||
pe_attr.exclude_user = 0;
|
||||
pe_attr.type = PERF_TYPE_HARDWARE;
|
||||
|
||||
chk_fail = 0;
|
||||
// perf_event_open
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
pe_attr.config = configs[i];
|
||||
|
||||
fds[i] = perf_event_open(&pe_attr, 0, -1, group_fd, 0);
|
||||
if (fds[i] == -1) {
|
||||
chk_fail = 1;
|
||||
break;
|
||||
}
|
||||
if (group_fd == -1) {
|
||||
group_fd = fds[i];
|
||||
}
|
||||
}
|
||||
OKNG(chk_fail != 0, "perf_event_open for %d counters", NUM_CNTR);
|
||||
|
||||
// reset counters
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
rc = ioctl(fds[i], PERF_EVENT_IOC_RESET, 0);
|
||||
CHKANDJUMP(rc != 0, "ioctl RESET");
|
||||
}
|
||||
|
||||
chk_fail = 0;
|
||||
// read counters at first
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
rc = read(fds[i], &tmp_count, sizeof(long long));
|
||||
CHKANDJUMP(rc == -1, "read counter[%d]", i);
|
||||
printf("%-16s: %ld\n", config_names[i], tmp_count);
|
||||
if (tmp_count != 0) {
|
||||
chk_fail = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
OKNG(chk_fail != 0, "Reset counters to 0");
|
||||
|
||||
// start counters at once
|
||||
rc = ioctl(group_fd, PERF_EVENT_IOC_ENABLE, PERF_IOC_FLAG_GROUP);
|
||||
OKNG(rc != 0, "Start counters at once");
|
||||
|
||||
// monitoring target
|
||||
printf(" do some processing...\n");
|
||||
calc_task();
|
||||
memory_task();
|
||||
|
||||
// stop counters at once
|
||||
rc = ioctl(group_fd, PERF_EVENT_IOC_DISABLE, PERF_IOC_FLAG_GROUP);
|
||||
OKNG(rc != 0, "Stop counters at once");
|
||||
|
||||
printf(" counted values are as belows...\n");
|
||||
// read counters after processing
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
rc = read(fds[i], &tmp_count, sizeof(long long));
|
||||
CHKANDJUMP(rc == -1, "read counter[%d]", i);
|
||||
printf("%-16s: %ld\n", config_names[i], tmp_count);
|
||||
counts[i] = tmp_count;
|
||||
}
|
||||
|
||||
printf(" processing again... (to check if counters are stopped)\n");
|
||||
// processing again (counters are stopped)
|
||||
calc_task();
|
||||
memory_task();
|
||||
|
||||
printf(" current values are as bellow\n"
|
||||
" (expected to be same value as last time)\n");
|
||||
|
||||
chk_fail = 0;
|
||||
// read counters again to check if counters were stopped
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
rc = read(fds[i], &tmp_count, sizeof(long long));
|
||||
printf("%-16s: %ld\n", config_names[i], tmp_count);
|
||||
if (counts[i] != tmp_count) {
|
||||
chk_fail = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
OKNG(chk_fail != 0, "Counters are stopped");
|
||||
|
||||
printf("*** %s PASSED\n\n", TEST_NAME);
|
||||
|
||||
return 0;
|
||||
|
||||
fn_fail:
|
||||
printf("*** %s FAILED\n\n", TEST_NAME);
|
||||
|
||||
return -1;
|
||||
}
|
||||
95
test/issues/1001/CT_003.c
Normal file
95
test/issues/1001/CT_003.c
Normal file
@@ -0,0 +1,95 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "ihklib.h"
|
||||
#include "./test_chk.h"
|
||||
|
||||
#define TEST_NAME "CT_003"
|
||||
|
||||
#define NUM_CNTR 1
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct ihk_perf_event_attr attr[NUM_CNTR];
|
||||
// for x86_64 arch
|
||||
unsigned long configs[NUM_CNTR] = {
|
||||
0x00c0};
|
||||
char *config_names[NUM_CNTR] = {
|
||||
"INSTRUCTIONS"};
|
||||
unsigned long counts[NUM_CNTR];
|
||||
unsigned long tmp_counts[NUM_CNTR];
|
||||
|
||||
int rc = 0;
|
||||
int i = 0;
|
||||
int chk_fail = 0;
|
||||
int event_num;
|
||||
|
||||
printf("*** %s start *******************************\n", TEST_NAME);
|
||||
|
||||
// setup attrs
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
attr[i].config = configs[i];
|
||||
attr[i].exclude_kernel = 1;
|
||||
attr[i].exclude_user = 0;
|
||||
attr[i].disabled = 1;
|
||||
}
|
||||
|
||||
// set perf_event
|
||||
rc = ihk_os_setperfevent(0, attr, NUM_CNTR);
|
||||
OKNG(rc < 0, "setperfevent for %d counter", NUM_CNTR);
|
||||
event_num = rc;
|
||||
|
||||
// start counters at once
|
||||
rc = ihk_os_perfctl(0, PERF_EVENT_ENABLE);
|
||||
OKNG(rc != 0, "Start counter");
|
||||
|
||||
// monitoring target
|
||||
printf(" do some processing...\n");
|
||||
system("bash ./processing.sh > /dev/null");
|
||||
|
||||
// stop counters at once
|
||||
rc = ihk_os_perfctl(0, PERF_EVENT_DISABLE);
|
||||
OKNG(rc != 0, "Stop counter");
|
||||
|
||||
rc = ihk_os_getperfevent(0, tmp_counts, event_num);
|
||||
OKNG(rc != 0, "getperfevent %d counter", event_num);
|
||||
printf(" counted value is as belows...\n");
|
||||
// read counters after processing
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
printf("%-16s: %ld\n", config_names[i], tmp_counts[i]);
|
||||
counts[i] = tmp_counts[i];
|
||||
}
|
||||
|
||||
printf(" processing again... (to check if counter is stopped)\n");
|
||||
// processing again (counters are stopped)
|
||||
system("bash ./processing.sh > /dev/null");
|
||||
|
||||
rc = ihk_os_getperfevent(0, tmp_counts, event_num);
|
||||
OKNG(rc != 0, "getperfevent %d counter", event_num);
|
||||
printf(" current value is as bellow\n"
|
||||
" (expected to be same value as last time)\n");
|
||||
|
||||
// read counters again to check if counters were stopped
|
||||
chk_fail = 0;
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
printf("%-16s: %ld\n", config_names[i], tmp_counts[i]);
|
||||
if (counts[i] != tmp_counts[i]) {
|
||||
chk_fail = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
OKNG(chk_fail != 0, "Counter is stopped");
|
||||
|
||||
printf("*** %s PASSED\n\n", TEST_NAME);
|
||||
|
||||
return 0;
|
||||
|
||||
fn_fail:
|
||||
printf("*** %s FAILED\n\n", TEST_NAME);
|
||||
|
||||
return -1;
|
||||
}
|
||||
101
test/issues/1001/CT_004.c
Normal file
101
test/issues/1001/CT_004.c
Normal file
@@ -0,0 +1,101 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "ihklib.h"
|
||||
#include "./test_chk.h"
|
||||
|
||||
#define TEST_NAME "CT_004"
|
||||
|
||||
#define NUM_CNTR 4
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct ihk_perf_event_attr attr[NUM_CNTR];
|
||||
// for x86_64 arch
|
||||
unsigned long configs[NUM_CNTR] = {
|
||||
0x00c0,
|
||||
0x4f2e,
|
||||
0x412e,
|
||||
0x00c5};
|
||||
char *config_names[NUM_CNTR] = {
|
||||
"INSTRUCTIONS",
|
||||
"CACHE_REFERENCES",
|
||||
"CACHE_MISSES",
|
||||
"BRANCH_MISSES"};
|
||||
unsigned long counts[NUM_CNTR];
|
||||
unsigned long tmp_counts[NUM_CNTR];
|
||||
|
||||
int rc = 0;
|
||||
int i = 0;
|
||||
int chk_fail = 0;
|
||||
int event_num;
|
||||
|
||||
printf("*** %s start *******************************\n", TEST_NAME);
|
||||
|
||||
// setup attrs
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
attr[i].config = configs[i];
|
||||
attr[i].exclude_kernel = 1;
|
||||
attr[i].exclude_user = 0;
|
||||
attr[i].disabled = 1;
|
||||
}
|
||||
|
||||
// set perf_event
|
||||
rc = ihk_os_setperfevent(0, attr, NUM_CNTR);
|
||||
OKNG(rc < 0, "setperfevent for %d counters", NUM_CNTR);
|
||||
event_num = rc;
|
||||
|
||||
// start counters at once
|
||||
rc = ihk_os_perfctl(0, PERF_EVENT_ENABLE);
|
||||
OKNG(rc != 0, "Start counters at once");
|
||||
|
||||
// monitoring target
|
||||
printf(" do some processing...\n");
|
||||
system("bash ./processing.sh > /dev/null");
|
||||
|
||||
// stop counters at once
|
||||
rc = ihk_os_perfctl(0, PERF_EVENT_DISABLE);
|
||||
OKNG(rc != 0, "Stop counters at once");
|
||||
|
||||
rc = ihk_os_getperfevent(0, tmp_counts, event_num);
|
||||
OKNG(rc != 0, "getperfevent %d counters", event_num);
|
||||
printf(" counted values are as belows...\n");
|
||||
// read counters after processing
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
printf("%-16s: %ld\n", config_names[i], tmp_counts[i]);
|
||||
counts[i] = tmp_counts[i];
|
||||
}
|
||||
|
||||
printf(" processing again... (to check if counters are stopped)\n");
|
||||
// processing again (counters are stopped)
|
||||
system("bash ./processing.sh > /dev/null");
|
||||
|
||||
rc = ihk_os_getperfevent(0, tmp_counts, event_num);
|
||||
OKNG(rc != 0, "getperfevent %d counters", event_num);
|
||||
printf(" current values are as bellow\n"
|
||||
" (expected to be same value as last time)\n");
|
||||
|
||||
// read counters again to check if counters were stopped
|
||||
chk_fail = 0;
|
||||
for (i = 0; i < NUM_CNTR; i++) {
|
||||
printf("%-16s: %ld\n", config_names[i], tmp_counts[i]);
|
||||
if (counts[i] != tmp_counts[i]) {
|
||||
chk_fail = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
OKNG(chk_fail != 0, "Counters are stopped");
|
||||
|
||||
printf("*** %s PASSED\n\n", TEST_NAME);
|
||||
|
||||
return 0;
|
||||
|
||||
fn_fail:
|
||||
printf("*** %s FAILED\n\n", TEST_NAME);
|
||||
|
||||
return -1;
|
||||
}
|
||||
35
test/issues/1001/Makefile
Normal file
35
test/issues/1001/Makefile
Normal file
@@ -0,0 +1,35 @@
|
||||
include $(HOME)/mck_test_config
|
||||
MCKDIR=$(BIN)/..
|
||||
CC = gcc
|
||||
TARGET=perf_tool.o processing CT_001 CT_002 CT_003 CT_004
|
||||
|
||||
CPPFLAGS =
|
||||
LDFLAGS =
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
CT_001: CT_001.c perf_tool.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
CT_002: CT_002.c perf_tool.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
CT_003: CT_003.c perf_tool.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS) -I$(MCKDIR)/include -L$(MCKDIR)/lib -l ihk
|
||||
|
||||
CT_004: CT_004.c perf_tool.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS) -I$(MCKDIR)/include -L$(MCKDIR)/lib -l ihk
|
||||
|
||||
perf_tool.o: perf_tool.c perf_tool.h
|
||||
|
||||
processing: processing.c perf_tool.o
|
||||
|
||||
|
||||
test: all
|
||||
@echo "#!/bin/sh" > ./processing.sh
|
||||
@echo "$(BIN)/mcexec ./processing" >> ./processing.sh
|
||||
@sh ./C1001.sh
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) *.o processing.sh
|
||||
|
||||
67
test/issues/1001/README
Normal file
67
test/issues/1001/README
Normal file
@@ -0,0 +1,67 @@
|
||||
【Issue#1001 動作確認】
|
||||
□ テスト内容
|
||||
1. 既存のperf_event_open機能に影響がないことを確認
|
||||
CT_001: 単一イベント種別での計測
|
||||
1. perf_event_open を1回呼び出し、1つのカウンタの設定とfdの取得を行う
|
||||
2. PERF_EVENT_IOC_RESET を取得したfdにioctlで送信し、
|
||||
カウンタの値が0になっていることを確認する
|
||||
3. PERF_EVENT_IOC_ENABLE を取得したfdにioctlで送信し、計測を開始する
|
||||
4. 計測対象プログラム(calc_task(), memory_task())を実行する
|
||||
5. PERF_EVENT_IOC_DISABLE を取得したfdにioctlで送信し、計測を終了する
|
||||
6. 計測終了時のカウンタの値を取得し、表示する
|
||||
7. カウンタが停止していることを確認するため、計測対象プログラムを再び実行する
|
||||
8. カウンタの値が前回取得時から変化していないことを確認する
|
||||
|
||||
CT_002: 複数のイベント種別での計測
|
||||
1. perf_event_open を4回呼び出し、4つのカウンタの設定とfdの取得を行う
|
||||
1つ目のカウンタをリーダーとし、4つのカウンタを1つのグループとして設定する
|
||||
2. PERF_EVENT_IOC_RESET を各fdにioctlで送信し、
|
||||
各カウンタの値が0になっていることを確認する
|
||||
3. PERF_EVENT_IOC_ENABLE をグループリーダーのfdにioctlで送信し、計測を開始する
|
||||
4. 計測対象プログラム(calc_task(), memory_task())を実行する
|
||||
5. PERF_EVENT_IOC_DISABLE をグループリーダーのfdにioctlで送信し、計測を終了する
|
||||
6. 計測終了時の各カウンタの値を取得し、表示する
|
||||
7. 各カウンタが停止していることを確認するため、計測対象プログラムを再び実行する
|
||||
8. カウンタの値が前回取得時から変化していないことを確認する
|
||||
|
||||
2. 既存のpa_info機能に影響がないことを確認
|
||||
CT_003: 単一のイベント種別での計測
|
||||
1. ihk_os_setperfevent を呼び出し、1種類のイベントの設定を行う
|
||||
2. ihk_os_perfctlをPERF_EVENT_ENABLE指定で呼び出し、計測を開始する
|
||||
3. 計測対象プログラム(calc_task(), memory_task())をmckernel上で実行する
|
||||
4. ihk_os_perfctlをPERF_EVENT_DISABLE指定で呼び出し、計測を終了する
|
||||
5. 計測終了時の各カウンタの値を取得し、表示する
|
||||
6. カウンタが停止していることを確認するため、計測対象プログラムを再び実行する
|
||||
7. カウンタの値が前回取得時から変化していないことを確認する
|
||||
|
||||
CT_004: 複数のイベント種別での計測
|
||||
1. ihk_os_setperfevent を呼び出し、4種類のイベントの設定を行う
|
||||
2. ihk_os_perfctlをPERF_EVENT_ENABLE指定で呼び出し、計測を開始する
|
||||
3. 計測対象プログラム(calc_task(), memory_task())をmckernel上で実行する
|
||||
4. ihk_os_perfctlをPERF_EVENT_DISABLE指定で呼び出し、計測を終了する
|
||||
5. 計測終了時の各カウンタの値を取得し、表示する
|
||||
6. カウンタが停止していることを確認するため、計測対象プログラムを再び実行する
|
||||
7. カウンタの値が前回取得時から変化していないことを確認する
|
||||
|
||||
3. LTPによる動作の確認
|
||||
LT_001: perf_event_open01 で、PERF_TYPE_HARDWARE 種別の計測が行えることを確認
|
||||
1. 上記テスト中の 1-5件目のテストがTPASSであることを確認
|
||||
1. 上記テスト中の 6,7件目のテストがTCONFであることを確認
|
||||
(PERF_TYPE_SOFTWARE指定はMcKernelでは未サポートのため)
|
||||
|
||||
□ 実行手順
|
||||
McKernelのインストール先や、OSTEST, LTPの配置場所は、
|
||||
$HOME/mck_test_config を参照している
|
||||
mck_test_config は、McKernelをビルドした際に生成される
|
||||
mck_test_config.sample ファイルを$HOMEにコピーし、適宜編集する
|
||||
|
||||
$ make test
|
||||
|
||||
実行できない場合は、C1001.shの以下の行を適切に書き換えた後に実行。
|
||||
BIN= mcexec が存在するパス
|
||||
SBIN= mcreboot.sh が存在するパス
|
||||
LTP= LTPが存在するパス
|
||||
|
||||
□ 実行結果
|
||||
result.log 参照。
|
||||
すべての項目をPASSしていることを確認。
|
||||
54
test/issues/1001/perf_tool.c
Normal file
54
test/issues/1001/perf_tool.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/perf_event.h>
|
||||
#include <asm/unistd.h>
|
||||
|
||||
#define WORKSIZE (1024 * 1024 * 32)
|
||||
#define LOOPSIZE 1000000
|
||||
#define REP 1000
|
||||
|
||||
int perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
|
||||
int cpu, int group_fd, unsigned long flags)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = syscall(__NR_perf_event_open, hw_event, pid, cpu,
|
||||
group_fd, flags);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void memory_task(void)
|
||||
{
|
||||
char *work = malloc(WORKSIZE);
|
||||
char *fromaddr;
|
||||
char *toaddr;
|
||||
double r;
|
||||
int offset;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < LOOPSIZE; i++) {
|
||||
r = drand48();
|
||||
offset = (int)(r * (double)WORKSIZE);
|
||||
fromaddr = work + offset;
|
||||
r = drand48();
|
||||
offset = (int)(r * (double)WORKSIZE);
|
||||
toaddr = work + offset;
|
||||
*toaddr = *fromaddr;
|
||||
}
|
||||
}
|
||||
|
||||
void calc_task(void)
|
||||
{
|
||||
int i, j;
|
||||
double tmp;
|
||||
|
||||
for (i = 0; i < REP; i++) {
|
||||
for (j = 0; j < REP; j++) {
|
||||
tmp = drand48() * drand48();
|
||||
}
|
||||
}
|
||||
}
|
||||
13
test/issues/1001/perf_tool.h
Normal file
13
test/issues/1001/perf_tool.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef __PERFTOOL_H__
|
||||
#define __PERFTOOL_H__
|
||||
|
||||
#include <linux/perf_event.h>
|
||||
|
||||
int perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
|
||||
int cpu, int group_fd, unsigned long flags);
|
||||
|
||||
long long hw_cache_build(long long id, long long op_id, long long op_result_id);
|
||||
void memory_task(void);
|
||||
void calc_task(void);
|
||||
|
||||
#endif
|
||||
12
test/issues/1001/processing.c
Normal file
12
test/issues/1001/processing.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "./perf_tool.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
calc_task();
|
||||
memory_task();
|
||||
|
||||
return 0;
|
||||
}
|
||||
93
test/issues/1001/result.log
Normal file
93
test/issues/1001/result.log
Normal file
@@ -0,0 +1,93 @@
|
||||
*** CT_001 start *******************************
|
||||
[OK] perf_event_open for 1 counter
|
||||
INSTRUCTIONS : 0
|
||||
[OK] Reset counter to 0
|
||||
[OK] Start counter at once
|
||||
do some processing...
|
||||
[OK] Stop counter at once
|
||||
counted value is as belows...
|
||||
INSTRUCTIONS : 291067667
|
||||
processing again... (to check if counter is stopped)
|
||||
current value is bellow
|
||||
(expected to be same value as last time)
|
||||
INSTRUCTIONS : 291067667
|
||||
[OK] Counter is stopped
|
||||
*** CT_001 PASSED
|
||||
|
||||
*** CT_002 start *******************************
|
||||
[OK] perf_event_open for 4 counters
|
||||
INSTRUCTIONS : 0
|
||||
CACHE_REFERENCES: 0
|
||||
CACHE_MISSES : 0
|
||||
BRANCH_MISSES : 0
|
||||
[OK] Reset counters to 0
|
||||
[OK] Start counters at once
|
||||
do some processing...
|
||||
[OK] Stop counters at once
|
||||
counted values are as belows...
|
||||
INSTRUCTIONS : 291067668
|
||||
CACHE_REFERENCES: 1984930
|
||||
CACHE_MISSES : 781531
|
||||
BRANCH_MISSES : 2784
|
||||
processing again... (to check if counters are stopped)
|
||||
current values are as bellow
|
||||
(expected to be same value as last time)
|
||||
INSTRUCTIONS : 291067668
|
||||
CACHE_REFERENCES: 1984930
|
||||
CACHE_MISSES : 781531
|
||||
BRANCH_MISSES : 2784
|
||||
[OK] Counters are stopped
|
||||
*** CT_002 PASSED
|
||||
|
||||
*** CT_003 start *******************************
|
||||
[OK] setperfevent for 1 counter
|
||||
[OK] Start counter
|
||||
do some processing...
|
||||
[OK] Stop counter
|
||||
[OK] getperfevent 1 counter
|
||||
counted value is as belows...
|
||||
INSTRUCTIONS : 291184821
|
||||
processing again... (to check if counter is stopped)
|
||||
[OK] getperfevent 1 counter
|
||||
current value is as bellow
|
||||
(expected to be same value as last time)
|
||||
INSTRUCTIONS : 291184821
|
||||
[OK] Counter is stopped
|
||||
*** CT_003 PASSED
|
||||
|
||||
*** CT_004 start *******************************
|
||||
[OK] setperfevent for 4 counters
|
||||
[OK] Start counters at once
|
||||
do some processing...
|
||||
[OK] Stop counters at once
|
||||
[OK] getperfevent 4 counters
|
||||
counted values are as belows...
|
||||
INSTRUCTIONS : 291184822
|
||||
CACHE_REFERENCES: 1986528
|
||||
CACHE_MISSES : 780284
|
||||
BRANCH_MISSES : 3657
|
||||
processing again... (to check if counters are stopped)
|
||||
[OK] getperfevent 4 counters
|
||||
current values are as bellow
|
||||
(expected to be same value as last time)
|
||||
INSTRUCTIONS : 291184822
|
||||
CACHE_REFERENCES: 1986528
|
||||
CACHE_MISSES : 780284
|
||||
BRANCH_MISSES : 3657
|
||||
[OK] Counters are stopped
|
||||
*** CT_004 PASSED
|
||||
|
||||
*** LT_001 start *******************************
|
||||
perf_event_open01 0 TINFO : read event counter succeeded, value: 300000015
|
||||
perf_event_open01 1 TPASS : test PERF_TYPE_HARDWARE: PERF_COUNT_HW_INSTRUCTIONS succeeded
|
||||
perf_event_open01 0 TINFO : read event counter succeeded, value: 0
|
||||
perf_event_open01 2 TPASS : test PERF_TYPE_HARDWARE: PERF_COUNT_HW_CACHE_REFERENCES succeeded
|
||||
perf_event_open01 0 TINFO : read event counter succeeded, value: 0
|
||||
perf_event_open01 3 TPASS : test PERF_TYPE_HARDWARE: PERF_COUNT_HW_CACHE_MISSES succeeded
|
||||
perf_event_open01 0 TINFO : read event counter succeeded, value: 100000006
|
||||
perf_event_open01 4 TPASS : test PERF_TYPE_HARDWARE: PERF_COUNT_HW_BRANCH_INSTRUCTIONS succeeded
|
||||
perf_event_open01 0 TINFO : read event counter succeeded, value: 1
|
||||
perf_event_open01 5 TPASS : test PERF_TYPE_HARDWARE: PERF_COUNT_HW_BRANCH_MISSES succeeded
|
||||
perf_event_open01 6 TCONF : perf_event_open01.c:155: perf_event_open for PERF_COUNT_SW_CPU_CLOCK not supported: TEST_ERRNO=ENOENT(2): No such file or directory
|
||||
perf_event_open01 7 TCONF : perf_event_open01.c:155: perf_event_open for PERF_COUNT_SW_TASK_CLOCK not supported: TEST_ERRNO=ENOENT(2): No such file or directory
|
||||
*** LT_001: PASSED (ok:5)
|
||||
23
test/issues/1001/test_chk.h
Normal file
23
test/issues/1001/test_chk.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef HEADER_TEST_CHK_H
|
||||
#define HEADER_TEST_CHK_H
|
||||
|
||||
#define CHKANDJUMP(cond, ...) do {\
|
||||
if (cond) {\
|
||||
fprintf(stderr, " [NG] ");\
|
||||
fprintf(stderr, __VA_ARGS__);\
|
||||
fprintf(stderr, " failed\n");\
|
||||
goto fn_fail;\
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define OKNG(cond, ...) do {\
|
||||
if (cond) {\
|
||||
CHKANDJUMP(cond, __VA_ARGS__);\
|
||||
} else {\
|
||||
fprintf(stdout, " [OK] ");\
|
||||
fprintf(stdout, __VA_ARGS__);\
|
||||
fprintf(stdout, "\n");\
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user