Implement filtering by duration for IrqAnalysis
authorAntoine Busque <antoinebusque@gmail.com>
Wed, 4 Mar 2015 20:14:28 +0000 (15:14 -0500)
committerAntoine Busque <antoinebusque@gmail.com>
Wed, 4 Mar 2015 20:14:28 +0000 (15:14 -0500)
lttnganalyses/lttnganalyses/irq.py
lttnganalysescli/lttnganalysescli/irq.py

index 5dcbeaa5453009cf2ed5218b4607146a8a1970bb..fd6bbc59408be27195e811198938ce0c71f08850 100644 (file)
@@ -26,7 +26,7 @@ from .analysis import Analysis
 
 
 class IrqAnalysis(Analysis):
-    def __init__(self, state):
+    def __init__(self, state, min_duration, max_duration):
         notification_cbs = {
             'irq_handler_entry': self._process_irq_handler_entry,
             'irq_handler_exit': self._process_irq_handler_exit,
@@ -35,6 +35,13 @@ class IrqAnalysis(Analysis):
 
         self._state = state
         self._state._register_notification_cbs(notification_cbs)
+        self._min_duration = min_duration
+        self._max_duration = max_duration
+        # µs to ns
+        if self._min_duration is not None:
+            self._min_duration *= 1000
+        if self._max_duration is not None:
+            self._max_duration *= 1000
 
         # Indexed by irq 'id' (irq or vec)
         self.hard_irq_stats = {}
@@ -55,6 +62,13 @@ class IrqAnalysis(Analysis):
 
     def _process_irq_handler_exit(self, **kwargs):
         irq = kwargs['hard_irq']
+
+        duration = irq.stop_ts - irq.start_ts
+        if self._min_duration is not None and duration < self._min_duration:
+            return
+        if self._max_duration is not None and duration > self._max_duration:
+            return
+
         self.irq_list.append(irq)
         if irq.id not in self.hard_irq_stats:
             self.hard_irq_stats[irq.id] = HardIrqStats()
@@ -63,6 +77,13 @@ class IrqAnalysis(Analysis):
 
     def _process_softirq_exit(self, **kwargs):
         irq = kwargs['softirq']
+
+        duration = irq.stop_ts - irq.start_ts
+        if self._min_duration is not None and duration < self._min_duration:
+            return
+        if self._max_duration is not None and duration > self._max_duration:
+            return
+
         self.irq_list.append(irq)
         if irq.id not in self.softirq_stats:
             name = SoftIrqStats.names[irq.id]
index b4441133ee3aaa09a0911964bed17d1365c37b01..a5312d39722f9558db022aecd17feb81e06e8745 100644 (file)
@@ -3,6 +3,7 @@
 # The MIT License (MIT)
 #
 # Copyright (C) 2015 - Julien Desfossez <jdesfossez@efficios.com>
+#               2015 - Antoine Busque <abusque@efficios.com>
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -41,11 +42,6 @@ class IrqAnalysis(Command):
                          enable_stats_arg=True)
 
     def _validate_transform_args(self):
-        # We need the min/max in the automaton to filter
-        # at the source.
-        self.state.max = self._arg_max
-        self.state.min = self._arg_min
-
         self._arg_irq_filter_list = None
         self._arg_softirq_filter_list = None
         if self._args.irq:
@@ -95,7 +91,9 @@ class IrqAnalysis(Command):
         self.run(freq=True)
 
     def _create_analysis(self):
-        self._analysis = lttnganalyses.irq.IrqAnalysis(self.state)
+        self._analysis = lttnganalyses.irq.IrqAnalysis(self.state,
+                                                       self._arg_min,
+                                                       self._arg_max)
 
     def compute_stdev(self, irq):
         values = []
This page took 0.026054 seconds and 5 git commands to generate.