Changeset 920

Show
Ignore:
Timestamp:
03/09/08 08:12:55 (13 years ago)
Author:
ppalmers
Message:

extend listing to include softirqs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/support/tools/listirqinfo.py

    r895 r920  
    11#!/usr/bin/python 
     2# 
     3 
     4# 
     5# Copyright (C) 2008 Pieter Palmers 
     6# 
     7# This program is free software: you can redistribute it and/or modify 
     8# it under the terms of the GNU General Public License as published by 
     9# the Free Software Foundation, version 3 of the License. 
     10# 
     11# This program is distributed in the hope that it will be useful, 
     12# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     14# GNU General Public License for more details. 
     15# 
     16# You should have received a copy of the GNU General Public License 
     17# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
    218# 
    319 
     
    521import commands 
    622import re 
     23 
     24VERSION="0.2" 
    725 
    826class IRQ: 
     
    1533                self.cpu_counts = [] 
    1634        def __str__(self): 
    17                 s = "IRQ %4s: PID %6s, Sched %4s (priority %4s), drivers: %s" % \ 
    18                     (self.number, self.process_id ,self.scheduling_class, self.scheduling_priority, self.drivers) 
     35                s = " IRQ %4s: PID: %5s, count: %18s, Sched %4s (priority %4s), drivers: %s" % \ 
     36                    (self.number, self.process_id, self.cpu_counts, 
     37                     self.scheduling_class, self.scheduling_priority, 
     38                     self.drivers) 
     39                return s 
     40 
     41class SoftIRQ: 
     42        def __init__(self): 
     43                self.name = None 
     44                self.fullname = None 
     45                self.scheduling_class = None 
     46                self.scheduling_priority = None 
     47                self.process_id = None 
     48                self.cpu_counts = [] 
     49        def __str__(self): 
     50                s = " SoftIRQ %10s: PID %6s, Sched %4s (priority %4s), name: %s" % \ 
     51                    (self.name, self.process_id ,self.scheduling_class, self.scheduling_priority, self.fullname) 
    1952                return s 
    2053 
     
    2457    return [value for key, value in items] 
    2558 
    26  
     59print "" 
     60print "Interrupt list utility " + VERSION 
     61print "==========================" 
     62print "(C) 2008 Pieter Palmers" 
     63print "" 
    2764 
    2865# get PID info 
     
    4279                irq.scheduling_priority = int(match_obj.group(4)) 
    4380                IRQs[irq.number] = irq 
     81 
     82(exitstatus, outtext) = commands.getstatusoutput('ps -eLo pid,cmd,class,rtprio | grep softirq') 
     83 
     84rawstr = r"""([0-9]+) +\[softirq-(.*)\] +([A-F]{2}) +([0-9]+)""" 
     85compile_obj = re.compile(rawstr) 
     86 
     87softIRQs = {} 
     88for line in outtext.splitlines(): 
     89        match_obj = compile_obj.search(line) 
     90        if match_obj: 
     91                irq = SoftIRQ() 
     92                irq.process_id = int(match_obj.group(1)) 
     93                irq.name = match_obj.group(2) 
     94                irq.fullname = "softirq-" + irq.name 
     95                irq.scheduling_class = match_obj.group(3) 
     96                irq.scheduling_priority = int(match_obj.group(4)) 
     97                softIRQs[irq.name] = irq 
    4498 
    4599# get PID info 
     
    77131                IRQs[irq.number] = irq 
    78132 
    79 print "Interrupt list: " 
     133print "Hardware Interrupts:" 
     134print "--------------------" 
     135 
    80136for irq in sortedDictValues(IRQs): 
    81137        print irq 
     138 
     139print "" 
     140print "Software Interrupts:" 
     141print "--------------------" 
     142for irq in sortedDictValues(softIRQs): 
     143        print irq 
    82144         
    83  
     145print ""