enhance cpu measurment implementation
This commit is contained in:
@@ -682,7 +682,6 @@ void run_telnetclt(void) {
|
|||||||
pthread_setname_np(pthread_self(), "telnetclt");
|
pthread_setname_np(pthread_self(), "telnetclt");
|
||||||
set_sched(pthread_self(),0,telnetparams.priority);
|
set_sched(pthread_self(),0,telnetparams.priority);
|
||||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
// FIELD *field[4];
|
|
||||||
if (sock < 0)
|
if (sock < 0)
|
||||||
fprintf(stderr,"[TELNETSRV] Error %s on socket call\n",strerror(errno));
|
fprintf(stderr,"[TELNETSRV] Error %s on socket call\n",strerror(errno));
|
||||||
char prompt[sizeof(TELNET_PROMPT_PREFIX)+10];
|
char prompt[sizeof(TELNET_PROMPT_PREFIX)+10];
|
||||||
@@ -694,50 +693,17 @@ void run_telnetclt(void) {
|
|||||||
name.sin_port = htons((unsigned short)(telnetparams.listenport));
|
name.sin_port = htons((unsigned short)(telnetparams.listenport));
|
||||||
if(connect(sock, (void *) &name, sizeof(name)))
|
if(connect(sock, (void *) &name, sizeof(name)))
|
||||||
fprintf(stderr,"[TELNETSRV] Error %s on connect call\n",strerror(errno));
|
fprintf(stderr,"[TELNETSRV] Error %s on connect call\n",strerror(errno));
|
||||||
|
|
||||||
|
|
||||||
// (void) initscr(); /* initialize the curses library */
|
|
||||||
// keypad(stdscr, TRUE); /* enable keyboard mapping */
|
|
||||||
// (void) nonl(); /* tell curses not to do NL->CR/NL on output */
|
|
||||||
// (void) cbreak(); /* take input chars one at a time, no wait for \n */
|
|
||||||
// (void) echo(); /* echo input - in color */
|
|
||||||
// WINDOW *inputw = newwin(10, 132, 0, 0);
|
|
||||||
// int row,col;
|
|
||||||
// getmaxyx(stdscr,row,col);
|
|
||||||
// field[0] = new_field((row-2)/2, col, 0, 0, 0, 0);
|
|
||||||
// field[1] = new_field((row-2)/2, col, (row-2)/2, 0, 0, 0);
|
|
||||||
// field[2] = new_field(1, col, row-2, 0, 0, 0);
|
|
||||||
// field[3] = NULL;
|
|
||||||
|
|
||||||
/* Set field options */
|
|
||||||
// field_opts_off(field[0], O_ACTIVE);
|
|
||||||
// field_opts_off(field[1], O_ACTIVE);
|
|
||||||
// set_field_back(field[0], A_UNDERLINE); /* Print a line for the option */
|
|
||||||
// field_opts_off(field[0], O_AUTOSKIP); /* Don't go to next field when this */
|
|
||||||
/* Field is filled up */
|
|
||||||
// set_field_back(field[1], A_UNDERLINE);
|
|
||||||
// field_opts_off(field[1], O_AUTOSKIP);
|
|
||||||
|
|
||||||
/* Create the form and post it */
|
|
||||||
// FORM *my_form = new_form(field);
|
|
||||||
// post_form(my_form);
|
|
||||||
// refresh();
|
|
||||||
|
|
||||||
|
|
||||||
// echo();
|
|
||||||
|
|
||||||
struct timeval ts;
|
struct timeval ts;
|
||||||
ts.tv_sec = 1; // 1 second
|
ts.tv_sec = 1; // 1 second
|
||||||
ts.tv_usec = 0;
|
ts.tv_usec = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
// select setup
|
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(sock, &fds);
|
FD_SET(sock, &fds);
|
||||||
FD_SET(STDIN_FILENO , &fds);
|
FD_SET(STDIN_FILENO , &fds);
|
||||||
// wait for data
|
// wait for data
|
||||||
int nready = select(sock + 1, &fds, (fd_set *) 0, (fd_set *) 0, &ts);
|
int nready = select(sock + 1, &fds, (fd_set *) 0, (fd_set *) 0, &ts);
|
||||||
// mvprintw(row-2,0,"select: %i \n",nready);
|
|
||||||
if (nready < 0) {
|
if (nready < 0) {
|
||||||
perror("select. Error");
|
perror("select. Error");
|
||||||
break;
|
break;
|
||||||
@@ -767,22 +733,13 @@ void run_telnetclt(void) {
|
|||||||
char *inbuf=NULL;
|
char *inbuf=NULL;
|
||||||
size_t inlen=0;
|
size_t inlen=0;
|
||||||
inlen = getline( &inbuf,&inlen, stdin);
|
inlen = getline( &inbuf,&inlen, stdin);
|
||||||
// mvprintw(row-1,0,inbuf);
|
|
||||||
if ( inlen > 0 ) {
|
if ( inlen > 0 ) {
|
||||||
if ( send(sock, inbuf,inlen, 0) < 0)
|
if ( send(sock, inbuf,inlen, 0) < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
free(inbuf);
|
free(inbuf);
|
||||||
// refresh();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* nocbreak();
|
|
||||||
unpost_form(my_form);
|
|
||||||
free_form(my_form);
|
|
||||||
free_field(field[0]);
|
|
||||||
free_field(field[1]);
|
|
||||||
free_field(field[2]);
|
|
||||||
endwin();*/
|
|
||||||
close(sock);
|
close(sock);
|
||||||
return;
|
return;
|
||||||
} /* run_telnetclt */
|
} /* run_telnetclt */
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||||
* contact@openairinterface.org
|
* contact@openairinterface.org
|
||||||
*/
|
*/
|
||||||
|
#define _GNU_SOURCE
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "time_meas.h"
|
#include "time_meas.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "assertions.h"
|
#include "assertions.h"
|
||||||
#ifndef PHYSIM
|
#ifndef PHYSIM
|
||||||
|
#include <pthread.h>
|
||||||
#include "common/config/config_userapi.h"
|
#include "common/config/config_userapi.h"
|
||||||
#endif
|
#endif
|
||||||
// global var for openair performance profiler
|
// global var for openair performance profiler
|
||||||
@@ -35,7 +36,8 @@ double cpu_freq_GHz __attribute__ ((aligned(32)));
|
|||||||
double cpu_freq_GHz __attribute__ ((aligned(32)))=0.0;
|
double cpu_freq_GHz __attribute__ ((aligned(32)))=0.0;
|
||||||
#ifndef PHYSIM
|
#ifndef PHYSIM
|
||||||
static uint32_t max_cpumeasur;
|
static uint32_t max_cpumeasur;
|
||||||
time_stats_t **measur_table;
|
static time_stats_t **measur_table;
|
||||||
|
notifiedFIFO_t measur_fifo;
|
||||||
#endif
|
#endif
|
||||||
double get_cpu_freq_GHz(void)
|
double get_cpu_freq_GHz(void)
|
||||||
{
|
{
|
||||||
@@ -146,27 +148,59 @@ double get_time_meas_us(time_stats_t *ts)
|
|||||||
|
|
||||||
|
|
||||||
int register_meas(char *name, time_stats_t *dst_ts)
|
int register_meas(char *name, time_stats_t *dst_ts)
|
||||||
{
|
{
|
||||||
for (int i=0; i<max_cpumeasur; i++) {
|
for (int i=0; i<max_cpumeasur; i++) {
|
||||||
if (measur_table[i] == NULL) {
|
if (measur_table[i] == NULL) {
|
||||||
measur_table[i] = (time_stats_t *)malloc(sizeof(time_stats_t));
|
measur_table[i] = (time_stats_t *)malloc(sizeof(time_stats_t));
|
||||||
memset(measur_table[i] ,0,sizeof(time_stats_t));
|
memset(measur_table[i] ,0,sizeof(time_stats_t));
|
||||||
measur_table[i]->meas_name = strdup(name);
|
measur_table[i]->meas_name = strdup(name);
|
||||||
measur_table[i]->meas_index = i;
|
measur_table[i]->meas_index = i;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void run_cpumeasur(void) {
|
||||||
|
struct sched_param schedp;
|
||||||
|
pthread_setname_np(pthread_self(), "measur");
|
||||||
|
schedp.sched_priority=0;
|
||||||
|
int rt=pthread_setschedparam(pthread_self(), SCHED_IDLE, &schedp);
|
||||||
|
AssertFatal(rt==0, "couldn't set measur thread priority: %s\n",strerror(errno));
|
||||||
|
initNotifiedFIFO(&measur_fifo);
|
||||||
|
while(1) {
|
||||||
|
notifiedFIFO_elt_t *msg = pullNotifiedFIFO(&measur_fifo);
|
||||||
|
time_stats_msg_t *tsm = (time_stats_msg_t *)NotifiedFifoData(msg);
|
||||||
|
switch(tsm->msgid) {
|
||||||
|
case TIMESTAT_MSGID_START:
|
||||||
|
measur_table[tsm->timestat_id]->in=tsm->ts;
|
||||||
|
(measur_table[tsm->timestat_id]->trials)++;
|
||||||
|
break;
|
||||||
|
case TIMESTAT_MSGID_STOP:
|
||||||
|
/// process duration is the difference between two clock points
|
||||||
|
measur_table[tsm->timestat_id]->p_time = (tsm->ts - measur_table[tsm->timestat_id]->in);
|
||||||
|
measur_table[tsm->timestat_id]->diff += measur_table[tsm->timestat_id]->p_time;
|
||||||
|
if ( measur_table[tsm->timestat_id]->p_time > measur_table[tsm->timestat_id]->max )
|
||||||
|
measur_table[tsm->timestat_id]->max = measur_table[tsm->timestat_id]->p_time;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
delNotifiedFIFO_elt(msg);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_meas(void)
|
void init_meas(void)
|
||||||
{
|
{
|
||||||
|
pthread_t thid;
|
||||||
paramdef_t cpumeasur_params[] = CPUMEASUR_PARAMS_DESC;
|
paramdef_t cpumeasur_params[] = CPUMEASUR_PARAMS_DESC;
|
||||||
int numparams=sizeof(cpumeasur_params)/sizeof(paramdef_t);
|
int numparams=sizeof(cpumeasur_params)/sizeof(paramdef_t);
|
||||||
int ret = config_get( cpumeasur_params,numparams,CPUMEASUR_SECTION);
|
int rt = config_get( cpumeasur_params,numparams,CPUMEASUR_SECTION);
|
||||||
AssertFatal(ret >= 0, "cpumeasur configuration couldn't be performed");
|
AssertFatal(rt >= 0, "cpumeasur configuration couldn't be performed");
|
||||||
measur_table=calloc(max_cpumeasur,sizeof( time_stats_t *));
|
measur_table=calloc(max_cpumeasur,sizeof( time_stats_t *));
|
||||||
AssertFatal(measur_table!=NULL, "couldn't allocate %u cpu measurements entries\n",max_cpumeasur);
|
AssertFatal(measur_table!=NULL, "couldn't allocate %u cpu measurements entries\n",max_cpumeasur);
|
||||||
|
rt=pthread_create(&thid,NULL, (void *(*)(void *))run_cpumeasur, NULL);
|
||||||
|
AssertFatal(rt==0, "couldn't create cpu measurment thread: %s\n",strerror(errno));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -31,6 +31,9 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
#ifndef PHYSIM
|
||||||
|
#include "common/utils/threadPool/thread-pool.h"
|
||||||
|
#endif
|
||||||
// global var to enable openair performance profiler
|
// global var to enable openair performance profiler
|
||||||
extern int opp_enabled;
|
extern int opp_enabled;
|
||||||
extern double cpu_freq_GHz __attribute__ ((aligned(32)));;
|
extern double cpu_freq_GHz __attribute__ ((aligned(32)));;
|
||||||
@@ -58,6 +61,13 @@ typedef struct {
|
|||||||
} time_stats_t;
|
} time_stats_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TIMESTAT_MSGID_START 0
|
||||||
|
#define TIMESTAT_MSGID_STOP 1
|
||||||
|
typedef struct {
|
||||||
|
int msgid; /*!< \brief message id, as defined by TIMESTAT_MSGID_X macros */
|
||||||
|
int timestat_id; /*!< \brief points to the time_stats_t entry in cpumeas table */
|
||||||
|
OAI_CPUTIME_TYPE ts; /*!< \brief time stamp */
|
||||||
|
} time_stats_msg_t;
|
||||||
static inline void start_meas(time_stats_t *ts) __attribute__((always_inline));
|
static inline void start_meas(time_stats_t *ts) __attribute__((always_inline));
|
||||||
static inline void stop_meas(time_stats_t *ts) __attribute__((always_inline));
|
static inline void stop_meas(time_stats_t *ts) __attribute__((always_inline));
|
||||||
|
|
||||||
@@ -122,6 +132,20 @@ static inline void stop_meas(time_stats_t *ts) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void send_meas(int measur_idx) {
|
||||||
|
if (opp_enabled) {
|
||||||
|
extern notifiedFIFO_t measur_fifo;
|
||||||
|
|
||||||
|
notifiedFIFO_elt_t *msg =newNotifiedFIFO_elt(sizeof(time_stats_msg_t),0,NULL,NULL);
|
||||||
|
time_stats_msg_t *tsm = (time_stats_msg_t *)NotifiedFifoData(msg);
|
||||||
|
tsm->ts = rdtsc_oai();
|
||||||
|
pushNotifiedFIFO(&measur_fifo, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static inline void reset_meas(time_stats_t *ts) {
|
static inline void reset_meas(time_stats_t *ts) {
|
||||||
ts->in=0;
|
ts->in=0;
|
||||||
ts->diff=0;
|
ts->diff=0;
|
||||||
|
|||||||
Reference in New Issue
Block a user