67 lines
1.4 KiB
C
67 lines
1.4 KiB
C
#pragma once
|
|
|
|
#include "thread_mon/thread_mon.h"
|
|
#include "data_structure/list_entry.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <stdint.h>
|
|
#include <signal.h>
|
|
#include <linux/perf_event.h>
|
|
#include <asm/unistd.h>
|
|
#include <sys/ioctl.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include <pthread.h>
|
|
#include <time.h>
|
|
|
|
#define MAX_CONTAINER_ID 128
|
|
#define PERF_TOTAL 0
|
|
#define PERF_SCALAR 1
|
|
#define PERF_SCALAR_MAC 2
|
|
#define PERF_PACK_128 3
|
|
#define PERF_PACK_256 4
|
|
#define PERF_PACK_512 5
|
|
#define PERF_VECTOR_MAC 6
|
|
#define PERF_INT_ALL 7
|
|
#define PERF_INT_128 8
|
|
#define PERF_INT_256 9
|
|
#define PERF_EX_RET_BRN 10
|
|
#define PERF_EX_RET_BRN_MISP 11
|
|
#define THREAD_MMAP_SIZE 12
|
|
#define PERF_COUNT 13
|
|
#define INVALID_COUNT 0xfa1dbabe
|
|
|
|
#define CONTAINER_INFO_REFRESH_INTERVAL 50000
|
|
#define EXIT_DELAY_MICROSECONDS 100000
|
|
|
|
typedef struct _CONTAINER_WORKER
|
|
{
|
|
|
|
LIST_ENTRY ListEntry;
|
|
|
|
char ContainerId[MAX_CONTAINER_ID];
|
|
pid_t ContainerPid;
|
|
|
|
volatile PLIST_ENTRY threads;
|
|
pthread_t MonitorThread;
|
|
volatile int IsRunning;
|
|
volatile uint64_t LibGPUCount;
|
|
volatile uint64_t MMAPSize;
|
|
|
|
|
|
volatile int Exited;
|
|
|
|
|
|
} CONTAINER_WORKER, *PCONTAINER_WORKER;
|
|
|
|
typedef struct _thread_perf_list
|
|
{
|
|
pid_t tid;
|
|
uint64_t fds[PERF_COUNT];
|
|
uint64_t fds_old[PERF_COUNT];
|
|
LIST_ENTRY entry;
|
|
volatile int Exited;
|
|
} thread_perf_list;
|
|
|
|
void *ContainerWorkerEntry(void *worker); |