def __init__(self):
        super().__init__()
        self._hooks = [
            ("sched_switch", self.hook_schedSwitch),
            ("irq_handler_entry", self.hook_irq),
            ("irq_handler_exit", self.hook_irqExit),
            ("softirq_entry", self.hook_softIrq),
            ("softirq_exit", self.hook_softIrqExit),
        ]

        # We only need to set up manually the idle thread and the traced
        # application Paraver entries, the other processes entries will be
        # installed in the callback_newProcessName
        binaryName = ParaverTrace.getBinaryName()
        values = {
            self.Status.Idle:
            "Idle",  # The KernelModel always sets up id 0 for Idle threads
            self.Status.ThisProcess:
            binaryName,  # The KernelModel always sets up id 1 for the traced app
            self.Status.Irq: "IRQ",
            self.Status.SoftIrq: "Soft IRQ",
        }
        ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.KERNEL_PREEMPTIONS,
                                          values, "Kernel Preemptions")
        KernelModel.registerNewProcessNameCallback(
            self.callback_newProcessName)
        KernelModel.registerNewThreadCallback(self.callback_newThread)
    def __init__(self):
        super().__init__()
        self._hooks = [
            ("sched_switch", self.hook_schedSwitch),
        ]
        self._syscallMap = {}
        self._sys_enter_prefix = len("sys_enter_")
        self._sys_exit_prefix = len("sys_exit_")

        binaryName = ParaverTrace.getBinaryName()

        values = {
            0: "Idle",
            1: binaryName,
            2: "Other Process",
        }

        # Create hooks based on the available syscalls detected
        syscallsEntry, syscallsExit = KernelModel.getSyscallDefinitions()

        index = 3
        for syscall in syscallsEntry:
            self._hooks.append((syscall, self.hook_syscallEntry))
            # Create and map id for this syscall in Paraver's pcf
            name = syscall[self._sys_enter_prefix:]
            self._syscallMap[name] = index
            values[index] = name
            index += 1

        for syscall in syscallsExit:
            self._hooks.append((syscall, self.hook_syscallExit))

        ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.KERNEL_SYSCALLS,
                                          values, "Kernel System Calls")
        KernelModel.registerNewThreadCallback(self.callback_newThread)
Beispiel #3
0
    def initialize(cls):
        # Load kernel tracepoint definitions file
        try:
            cls.loadKernelDefs("../nanos6_kerneldefs.json")
        except Exception as e:
            return False

        # Initialize hooks
        cls._preHooks = [("sched_switch", cls.hook_schedSwitch)]
        cls._postHooks = []

        # Initialize syscall tracepoitns
        regex = re.compile('^sys\_')
        cls._syscalls = list(filter(regex.match, cls._defs))

        regex = re.compile('^sys\_enter\_')
        cls._syscallEntryPoints = list(filter(regex.match, cls._syscalls))

        regex = re.compile('^sys\_exit\_')
        cls._syscallExitPoints = list(filter(regex.match, cls._syscalls))

        # Initialize CPUs
        maxCPUId = ParaverTrace.getMaxRealCPUId()
        cls._cpus = [CPU(cpuId) for cpuId in range(maxCPUId + 1)]

        # Initialize thread list with a fake Idle thread shared by all Cores
        # (all idle threads in the Linux Kernel have tid 0)
        cls._threads[0] = Thread(0, "Idle", 0)

        # Register the traced application's name to ensure that it always gets
        # the same perProcessExtraeId
        binaryName = ParaverTrace.getBinaryName()
        shortBinaryName = binaryName[:15]
        cls._processNames[shortBinaryName] = 1
        cls._processNameId = 100

        cls._enabled = True

        return cls._enabled