tools/perf/scripts/python/task-analyzer.py
Source file repositories/reference/linux-study-clean/tools/perf/scripts/python/task-analyzer.py
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/scripts/python/task-analyzer.py- Extension
.py- Size
- 34014 bytes
- Lines
- 935
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
# task-analyzer.py - comprehensive perf tasks analysis
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2022, Hagen Paul Pfeifer <hagen@jauu.net>
# Licensed under the terms of the GNU GPL License version 2
#
# Usage:
#
# perf record -e sched:sched_switch -a -- sleep 10
# perf script report task-analyzer
#
from __future__ import print_function
import sys
import os
import string
import argparse
import decimal
sys.path.append(
os.environ["PERF_EXEC_PATH"] + "/scripts/python/Perf-Trace-Util/lib/Perf/Trace"
)
from perf_trace_context import *
from Core import *
# Definition of possible ASCII color codes
_COLORS = {
"grey": "\033[90m",
"red": "\033[91m",
"green": "\033[92m",
"yellow": "\033[93m",
"blue": "\033[94m",
"violet": "\033[95m",
"reset": "\033[0m",
}
# Columns will have a static size to align everything properly
# Support of 116 days of active update with nano precision
LEN_SWITCHED_IN = len("9999999.999999999") # 17
LEN_SWITCHED_OUT = len("9999999.999999999") # 17
LEN_CPU = len("000")
LEN_PID = len("maxvalue") # 8
LEN_TID = len("maxvalue") # 8
LEN_COMM = len("max-comms-length") # 16
LEN_RUNTIME = len("999999.999") # 10
# Support of 3.45 hours of timespans
LEN_OUT_IN = len("99999999999.999") # 15
LEN_OUT_OUT = len("99999999999.999") # 15
LEN_IN_IN = len("99999999999.999") # 15
LEN_IN_OUT = len("99999999999.999") # 15
# py2/py3 compatibility layer, see PEP469
try:
dict.iteritems
except AttributeError:
# py3
def itervalues(d):
return iter(d.values())
def iteritems(d):
return iter(d.items())
else:
# py2
def itervalues(d):
return d.itervalues()
def iteritems(d):
return d.iteritems()
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.