*/
/******************************************************************
+
+Each field of the interrupt viewer is summarized as follows:
- CPUID: processor ID
- IrqId: IRQ ID
-- Frequency (Hz): the number of interruptions per second (Hz)
+- Frequency (Hz): the number of interrupts per second (Hz).
+ We compute the total number of interrupts. Then
+ we divide it by the time interval.
-- Total Duration (nsec): the sum of each interrupt duration in nsec
+- Total Duration (nsec): the sum of each interrupt duration in nsec.
+ For a given Irq ID, we sum the duration of each interrupt
+ to give us the total duration
- Duration Standard_deviation = sqrt(1/N Sum ((xi -Xa)^2)) where
N: number of interrupts
xi: duration of an interrupt (nsec)
Xa: average duration (nsec)
+ The formula is taken from wikipedia: http://en.wikipedia.org/wiki/Standard_deviation.
+ To calculate the duration standard deviation, we make two EventsRequest passes to the main window.
+ In the first EventsRequest pass, we calculate the total number of interrupts to compute for
+ the average Xa. In the second EventsRequest pass, calculate the standard deviation.
+
- Max IRQ handler duration (nsec) [time interval]: the longest IRQ handler duration in nsec.
--Average period (nsec): 1/Frequency(in HZ)
+- Min IRQ handler duration (nsec) [time interval]: the shortest IRQ handler duration in nsec.
+
+- Average period (nsec): 1/Frequency(in HZ). The frequency is computed above.
-Period Standard_deviation = sqrt(1/N Sum ((xi -Xa)^2)) where
-N: number of interruptions
+N: number of interrupts
xi: duration of an interrupt
-Xa: 1/Frequency (in Hz)
+Xa: Period = 1/Frequency (in Hz)
-Frequency Standard_deviation = sqrt(1/N Sum ((xi -Xa)^2))
-N: number of interruptions
+N: number of interrupts
xi: duration of an interrupt
Xa: Frequency (Hz)
-
-
-The standard deviation calculation is based on:
- http://en.wikipedia.org/wiki/Standard_deviation
-
- Standard_deviation = sqrt(1/N Sum ((xi -Xa)^2))
-
-
-
- To compute the standard deviation, we need to make two EventRequests to LTTV. In
- the first EventRequest, we compute the average duration (Xa) and the Number of interruptions (N) of
- each IrqID. We store the information calculated in the first EventRequest in an array
- called FirstRequestIrqExit. In the second EventRequest, we compute the Sum ((xi -Xa)^2)
- and store this information in a array called SumArray. The function CalculateDurationStandardDeviation() uses
- FirstRequestIrqExit and SumArray arrays to calculate the duration standard deviation.
- *******************************************************************/
+*******************************************************************/
#include <lttv/state.h>
#include <lttv/filter.h>
#include <lttvwindow/lttvwindow.h>
+#include <lttvwindow/lttv_plugin_tab.h>
#include <ltt/time.h>
#include "hInterruptsInsert.xpm"
typedef struct {
guint cpu_id;
guint id;
- guint NumerofInterruptions;
+ guint TotalNumberOfInterrupts;
LttTime total_duration;
guint average_duration;
IrqDuration max_irq_handler;
typedef struct
{
guint irqId;
- guint NumerofInterruptions;//frequency;//
+ guint TotalNumberOfInterrupts;//frequency;//
guint64 sumOfDurations; // to store the Sum ((xi -Xa)^2) of the duration Standard deviation
guint64 sumOfPeriods; // to store the Sum ((xi -Xa)^2) of the period Standard deviation
guint64 sumOfFrequencies;// to store the Sum ((xi -Xa)^2) of the frequency Standard deviation
static GSList *interrupt_data_list = NULL ;
-#define TRACE_NUMBER 0
+//fixed #define TRACE_NUMBER 0
typedef struct _InterruptEventData {
GtkTreeSelection *SelectionTree;
Tab * tab; /* tab that contains this plug-in*/
+ LttvPluginTab *ptab;
LttvHooks * event_hooks;
LttvHooks * hooks_trace_after;
LttvHooks * hooks_trace_before;
/* Function prototypes */
static gboolean interrupt_update_time_window(void * hook_data, void * call_data);
-static GtkWidget *interrupts(Tab *tab);
-static InterruptEventData *system_info(Tab *tab);
+static GtkWidget *interrupts(LttvPlugin *plugin);
+static InterruptEventData *system_info(LttvPluginTab *ptab);
void interrupt_destructor(InterruptEventData *event_viewer_data);
static void FirstRequest(InterruptEventData *event_data );
static guint64 get_interrupt_id(LttEvent *e);
static void SumItems(gint irq_id, LttTime Xi, InterruptEventData *event_data);
static int CalculateDurationStandardDeviation(gint id, InterruptEventData *event_data);
static int CalculatePeriodStandardDeviation(gint id, InterruptEventData *event_data);
-static int FrequencyInHZ(gint NumerofInterruptions, TimeWindow time_window);
+static int FrequencyInHZ(gint NumberOfInterruptions, TimeWindow time_window);
static guint64 CalculatePeriodInnerPart(guint Xi, guint FrequencyHZ);
static guint64 CalculateFrequencyInnerPart(guint Xi_in_ns, guint FrequencyHZ);
static void InterruptFree(InterruptEventData *event_viewer_data);
* Constructor hook
*
*/
-static GtkWidget *interrupts(Tab * tab)
+static GtkWidget *interrupts(LttvPlugin *plugin)
{
-
- InterruptEventData* event_data = system_info(tab) ;
+ LttvPluginTab *ptab = LTTV_PLUGIN_TAB(plugin);
+ InterruptEventData* event_data = system_info(ptab) ;
if(event_data)
return event_data->Hbox;
else
* This function initializes the Event Viewer functionnality through the
* GTK API.
*/
-InterruptEventData *system_info(Tab *tab)
+InterruptEventData *system_info(LttvPluginTab *ptab)
{
LttTime end;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
InterruptEventData* event_viewer_data = g_new(InterruptEventData,1) ;
-
+ Tab *tab = ptab->tab;
+ event_viewer_data->ptab = ptab;
event_viewer_data->tab = tab;
/*Get the current time frame from the main window */
nb_trace = lttv_traceset_number(traceset);
/* There are many traces in a traceset. Iteration for each trace. */
- for(i = 0; i<MIN(TRACE_NUMBER+1, nb_trace);i++)
- {
+ //for(i = 0; i<MIN(TRACE_NUMBER+1, nb_trace);i++) {
+ for(i = 0 ; i < nb_trace ; i++) {
events_request = g_new(EventsRequest, 1);
hooks = g_array_new(FALSE, FALSE, sizeof(LttvTraceHook));
{
irq.cpu_id = e->cpu_id;
irq.id = e->id;
- irq.NumerofInterruptions++;
+ irq.TotalNumberOfInterrupts++;
irq.total_duration = ltt_time_sub(time_exit, e->event_time);
irq.max_irq_handler.start_time = e->event_time;
notFound = TRUE;
duration = ltt_time_sub(time_exit, e->event_time);
element->total_duration = ltt_time_add(element->total_duration, duration);
- element->NumerofInterruptions++;
+ element->TotalNumberOfInterrupts++;
// Max irq handler
if(ltt_time_compare(duration,element->max_irq_handler.duration) > 0)
{
{
irq.cpu_id = e->cpu_id;
irq.id = e->id;
- irq.NumerofInterruptions++;
+ irq.TotalNumberOfInterrupts++;
irq.total_duration = ltt_time_sub(time_exit, e->event_time);
// Max irq handler
irq.max_irq_handler.start_time = e->event_time;
nb_trace = lttv_traceset_number(traceset);
/* There are many traces in a traceset. Iteration for each trace. */
- for(i = 0; i<MIN(TRACE_NUMBER+1, nb_trace);i++)
- {
+ for(i = 0 ; i < nb_trace ; i++) {
+ // fixed for(i = 0; i<MIN(TRACE_NUMBER+1, nb_trace);i++) {
events_request = g_new(EventsRequest, 1);
hooks = g_array_new(FALSE, FALSE, sizeof(LttvTraceHook));
real_data = element->total_duration.tv_sec;
real_data *= NANOSECONDS_PER_SECOND;
real_data += element->total_duration.tv_nsec;
- if(element->NumerofInterruptions != 0)
- element->average_duration = real_data / element->NumerofInterruptions;
+ if(element->TotalNumberOfInterrupts != 0)
+ element->average_duration = real_data / element->TotalNumberOfInterrupts;
else
element->average_duration = 0;
}
if(irq_id == average->id)
{
duration_inner_part = Xi_in_ns - average->average_duration;
- FrequencyHZ = FrequencyInHZ(average->NumerofInterruptions, event_data->time_window);
+ FrequencyHZ = FrequencyInHZ(average->TotalNumberOfInterrupts, event_data->time_window);
sum.irqId = irq_id;
// compute (xi -Xa)^2 of the duration Standard deviation
- sum.NumerofInterruptions = average->NumerofInterruptions;
+ sum.TotalNumberOfInterrupts = average->TotalNumberOfInterrupts;
sum.sumOfDurations = pow (duration_inner_part , 2);
// compute (xi -Xa)^2 of the period Standard deviation
element.min_irq_handler.end_time.tv_nsec) ;
- FrequencyHZ = FrequencyInHZ(element.NumerofInterruptions,event_data->time_window);
+ FrequencyHZ = FrequencyInHZ(element.TotalNumberOfInterrupts,event_data->time_window);
if(FrequencyHZ != 0)
{
AVERAGE_PERIOD , periodInNsec,
PERIOD_STANDARD_DEV_COLUMN, CalculatePeriodStandardDeviation(element.id, event_data),
FREQUENCY_STANDARD_DEV_COLUMN, CalculateFrequencyStandardDeviation(element.id, event_data),
- -1);
-
-
+ -1);
}
sumId = g_array_index(event_data->SumArray, SumId, i);
if(id == sumId.irqId)
{
- if(sumId.NumerofInterruptions != 0)
- inner_component = sumId.sumOfDurations/ sumId.NumerofInterruptions;
+ if(sumId.TotalNumberOfInterrupts != 0)
+ inner_component = sumId.sumOfDurations/ sumId.TotalNumberOfInterrupts;
else
inner_component = 0.0;
deviation = sqrt(inner_component);
sumId = g_array_index(event_data->SumArray, SumId, i);
if(id == sumId.irqId)
{
- if(sumId.NumerofInterruptions != 0)
- inner_component = sumId.sumOfPeriods / sumId.NumerofInterruptions;
+ if(sumId.TotalNumberOfInterrupts != 0)
+ inner_component = sumId.sumOfPeriods / sumId.TotalNumberOfInterrupts;
else
inner_component = 0;
sumId = g_array_index(event_data->SumArray, SumId, i);
if(id == sumId.irqId)
{
- if(sumId.NumerofInterruptions != 0)
- inner_component = sumId.sumOfFrequencies / sumId.NumerofInterruptions;
+ if(sumId.TotalNumberOfInterrupts != 0)
+ inner_component = sumId.sumOfFrequencies / sumId.TotalNumberOfInterrupts;
else
inner_component = 0;