update system call measurement test program related files. (#49)

Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/49
Co-authored-by: siddhant <siddhant.singh@neominds.in>
Co-committed-by: siddhant <siddhant.singh@neominds.in>
This commit is contained in:
2026-07-30 20:15:19 +05:30
committed by neelimap
parent 11aab43634
commit 298f09c6b7
3 changed files with 63 additions and 86 deletions
@@ -33,7 +33,8 @@ void displayStats();
void clearSysTableData();
void sysCallMeasurementTask();
void CaptureSysCallMetrics();
int measurementFlag;
extern void sysCallMsrSetData (int flag, TASK_ID tID);
extern void sysCallMsrGetData (int* flag, TASK_ID* tID);
TASK_ID sysCallTaskID;
static SEM_ID sysCallSemID;
UINT32 tsFreq;
@@ -14,11 +14,10 @@ void clearSysTableData()
void sysCallMeasurementTask(const char* cmd, const char* arg)
{
measurementFlag = 1;
shellCmdExec (cmd, arg);
measurementFlag=0;
sysCallMsrSetData (1, sysCallTaskID);
shellCmdExec (cmd, arg);
semBGive(sysCallSemID);
measurementFlag = 0;
sysCallMsrSetData (0, 0);
displayStats();
}
@@ -57,10 +56,10 @@ void displayStats()
printf("------------------------------------------------------------------\n");
printf("%-15s %-15s %-15s %-20s\n","crypto cmd","system call","Invocations","Total time (USec)");
printf("------------------------------------------------------------------\n");
printf("%-15s %-15s %-15d %-20lu\n","enc","open",API_STATS[openCall].sysCallCount,API_STATS[openCall].execTimeUsec);
printf("%-15s %-15s %-15d %-20lu\n","enc","close",API_STATS[closeCall].sysCallCount,API_STATS[closeCall].execTimeUsec);
printf("%-15s %-15s %-15d %-20lu\n","enc","read",API_STATS[readCall].sysCallCount,API_STATS[readCall].execTimeUsec );
printf("%-15s %-15s %-15d %-20lu\n","enc","write",API_STATS[writeCall].sysCallCount,API_STATS[writeCall].execTimeUsec);
printf("%-15s %-15s %-15d %-20lu\n","enc","open",API_STATS[openCall].sysCallCount,((API_STATS[openCall].execTimeUsec)*1000000ULL)/tsFreq);
printf("%-15s %-15s %-15d %-20lu\n","enc","close",API_STATS[closeCall].sysCallCount,((API_STATS[closeCall].execTimeUsec)*1000000ULL)/tsFreq);
printf("%-15s %-15s %-15d %-20lu\n","enc","read",API_STATS[readCall].sysCallCount,((API_STATS[readCall].execTimeUsec)*1000000ULL)/tsFreq );
printf("%-15s %-15s %-15d %-20lu\n","enc","write",API_STATS[writeCall].sysCallCount,((API_STATS[writeCall].execTimeUsec)*1000000ULL)/tsFreq);
printf("-------------------------------------------------------------------\n");
}
+54 -77
View File
@@ -324,12 +324,9 @@ the VxWorks programmer guides.
* uncomment the line below to measure open, close, read
* and write system calls for 'enc' command.
*/
/* #define MEASURE_SYS_CALLS */
#define MEASURE_SYS_CALLS
#ifdef MEASURE_SYS_CALLS
extern int measurementFlag;
extern TASK_ID sysCallTaskID;
extern UINT32 tsFreq;
enum kernelAPI
{
@@ -346,6 +343,46 @@ typedef struct
unsigned long int execTimeUsec;
}KRNL_API_STATS;
KRNL_API_STATS API_STATS[sysCallMax];
int measurementFlag;
TASK_ID sysCallTaskID;
void sysCallMsrGetData (int* flag, TASK_ID* tID);
void sysCallMsrSetData (int flag, TASK_ID tID);
void sysCallMsrStart(UINT32* startTick, int sysCallIdx)
{
sysTimestampEnable();
if ((measurementFlag && (sysCallTaskID == taskIdSelf())))
{
*startTick = sysTimestamp();
API_STATS[sysCallIdx].sysCallCount++;
}
}
void sysCallMsrEnd(UINT32* startTick, UINT32* endTick, int sysCallIdx)
{
if ((measurementFlag && (sysCallTaskID == taskIdSelf())))
{
*endTick = sysTimestamp();
UINT32 diffTick = *endTick - *startTick;
API_STATS[sysCallIdx].execTimeUsec += diffTick;
}
}
void sysCallMsrSetData (int flag, TASK_ID tID)
{
measurementFlag = flag;
sysCallTaskID = tID;
}
void sysCallMsrGetData (int* flag, TASK_ID* tID)
{
*flag = measurementFlag;
*tID = sysCallTaskID;
}
#endif
/* this tells core I/O if the system is configured for PSE52 */
@@ -618,30 +655,15 @@ int open
int mode /* mode of file to create (UNIX chmod style) */
)
{
#ifdef MEASURE_SYS_CALLS
sysTimestampEnable();
UINT32 startTick = 0, endTick = 0, diffTick = 0;
UINT64 timeUs = 0;
UINT32 freq = tsFreq;
char toMeasure = (measurementFlag && (sysCallTaskID == taskIdSelf()));
if (toMeasure)
{
startTick = sysTimestamp();
(API_STATS[openCall].sysCallCount)++;
}
#ifdef MEASURE_SYS_CALLS
UINT32 startTick=0, endTick=0;
sysCallMsrStart(&startTick, openCall);
#endif
int result = ioCreateOrOpen(name, flags, mode, FALSE);
#ifdef MEASURE_SYS_CALLS
if (toMeasure)
{
endTick = sysTimestamp();
diffTick = endTick - startTick;
timeUs = ((UINT64)diffTick * 1000000ULL) / freq;
(API_STATS[openCall].execTimeUsec)+=timeUs;
}
sysCallMsrEnd(&startTick, &endTick, openCall);
#endif
return result;
@@ -1066,17 +1088,8 @@ int close
int krnPthreadCnclType; /* temp kernel canceltype saved value */
#ifdef MEASURE_SYS_CALLS
sysTimestampEnable();
UINT32 startTick = 0, endTick = 0, diffTick = 0;
UINT64 timeUs = 0;
UINT32 freq = tsFreq;
char toMeasure = (measurementFlag && (sysCallTaskID == taskIdSelf()));
if (toMeasure)
{
startTick = sysTimestamp();
(API_STATS[closeCall].sysCallCount)++;
}
UINT32 startTick=0, endTick=0;
sysCallMsrStart(&startTick, closeCall);
#endif
if (_func_pthread_testandset_canceltype != NULL)
@@ -1089,13 +1102,7 @@ int close
_func_pthread_testandset_canceltype (krnPthreadCnclType, NULL);
#ifdef MEASURE_SYS_CALLS
if (toMeasure)
{
endTick = sysTimestamp();
diffTick = endTick - startTick;
timeUs = ((UINT64)diffTick * 1000000ULL) / freq;
(API_STATS[closeCall].execTimeUsec)+=timeUs;
}
sysCallMsrEnd(&startTick, &endTick, closeCall);
#endif
return (ret);
}
@@ -1177,29 +1184,14 @@ ssize_t read
ssize_t result;
#ifdef MEASURE_SYS_CALLS
sysTimestampEnable();
UINT32 startTick = 0, endTick = 0, diffTick = 0;
UINT64 timeUs = 0;
UINT32 freq = tsFreq;
char toMeasure = (measurementFlag && (sysCallTaskID == taskIdSelf()));
if (toMeasure)
{
startTick = sysTimestamp();
(API_STATS[readCall].sysCallCount)++;
}
UINT32 startTick=0, endTick=0;
sysCallMsrStart(&startTick, readCall);
#endif
result=(ioReadWrite (iosRead, fd, buffer, maxBytes));
#ifdef MEASURE_SYS_CALLS
if (toMeasure)
{
endTick = sysTimestamp();
diffTick = endTick - startTick;
timeUs = ((UINT64)diffTick * 1000000ULL) / freq;
(API_STATS[readCall].execTimeUsec)+=timeUs;
}
sysCallMsrEnd(&startTick, &endTick, readCall);
#endif
return result;
}
@@ -1241,28 +1233,13 @@ ssize_t write
{
ssize_t result;
#ifdef MEASURE_SYS_CALLS
sysTimestampEnable();
UINT32 startTick = 0, endTick = 0, diffTick = 0;
UINT64 timeUs = 0;
UINT32 freq = tsFreq;
char toMeasure = (measurementFlag && (sysCallTaskID == taskIdSelf()));
if (toMeasure)
{
startTick = sysTimestamp();
(API_STATS[writeCall].sysCallCount)++;
}
UINT32 startTick=0, endTick=0;
sysCallMsrStart(&startTick, writeCall);
#endif
result=(ioReadWrite (iosWrite, fd, buffer, nBytes));
#ifdef MEASURE_SYS_CALLS
if (toMeasure)
{
endTick = sysTimestamp();
diffTick = endTick - startTick;
timeUs = ((UINT64)diffTick * 1000000ULL) / freq;
(API_STATS[writeCall].execTimeUsec)+=timeUs;
}
sysCallMsrEnd(&startTick, &endTick, writeCall);
#endif
return result;
}