test: perf: prevent overflow counter from stopping counter
Fixes: 1a204b6 "perf: overflow test"
Change-Id: I4d8e93b97f7a8d58ef7811f55b5c995b16c5af69
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
/* combination_test.c COPYRIGHT FUJITSU LIMITED 2019 */
|
||||
#include "combination_test.h"
|
||||
#include "perf_common.h"
|
||||
|
||||
//
|
||||
// main
|
||||
@ -32,6 +33,31 @@ static int combination_test(struct command_set *cmd_set)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Set reasonable value to overflow counter so as not to stop
|
||||
* counter on Linux. Reset must precede to prevent
|
||||
* uninitialized value is accumulated on McKernel for the case
|
||||
* REFRESH includes ENABLE
|
||||
*/
|
||||
ret = perf_event_ioc_refresh(fd, NULL);
|
||||
if (ret < 0) {
|
||||
perror("perf_event_ioc_refresh");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Stop counter for the case REFRESH includes ENABLE */
|
||||
ret = asm_ioctl3(fd, PERF_EVENT_IOC_DISABLE, 0);
|
||||
if (ret < 0) {
|
||||
errno = -ret;
|
||||
perror("asm_ioctl(PERF_EVENT_IOC_DISABLE)");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = ioctl(fd, PERF_EVENT_IOC_RESET, 0);
|
||||
if (ret < 0) {
|
||||
perror("ioctl(PERF_EVENT_IOC_RESET)");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = asm_ioctl3(fd, PERF_EVENT_IOC_ENABLE, 0);
|
||||
if (ret < 0) {
|
||||
errno = -ret;
|
||||
|
||||
@ -164,9 +164,12 @@ static void build_perf_event_ioc_reset(struct command *cmd)
|
||||
}
|
||||
|
||||
// perf_event_ioc_refresh command
|
||||
static int perf_event_ioc_refresh(int fd, void *_args)
|
||||
int perf_event_ioc_refresh(int fd, void *_args)
|
||||
{
|
||||
int ret = asm_ioctl3(fd, PERF_EVENT_IOC_REFRESH, 0);
|
||||
/* Prevent overflow counter from stopping counter
|
||||
* Note that it starts counter as well
|
||||
*/
|
||||
int ret = asm_ioctl3(fd, PERF_EVENT_IOC_REFRESH, 256);
|
||||
|
||||
if (ret < 0) {
|
||||
errno = -ret;
|
||||
|
||||
@ -25,6 +25,7 @@ void print_usage(void);
|
||||
//system call
|
||||
long perf_event_open(struct perf_event_attr *event_attr, pid_t pid,
|
||||
int cpu, int group_fd, unsigned long flags);
|
||||
int perf_event_ioc_refresh(int fd, void *_args);
|
||||
int init_perf_event_attr(struct perf_event_attr *event_attr);
|
||||
int asm_ioctl3(int fd, unsigned long arg1, unsigned long arg2);
|
||||
int asm_read(int fd, void *buf, size_t size);
|
||||
|
||||
Reference in New Issue
Block a user