tools/perf/python/ilist.py
Source file repositories/reference/linux-study-clean/tools/perf/python/ilist.py
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/python/ilist.py- Extension
.py- Size
- 18166 bytes
- Lines
- 516
- 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
#!/usr/bin/env python3
# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
"""Interactive perf list."""
from abc import ABC, abstractmethod
import argparse
from dataclasses import dataclass
import math
from typing import Any, Dict, Optional, Tuple
import perf
from textual import on
from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.containers import Horizontal, HorizontalGroup, Vertical, VerticalScroll
from textual.css.query import NoMatches
from textual.command import SearchIcon
from textual.screen import ModalScreen
from textual.widgets import Button, Footer, Header, Input, Label, Sparkline, Static, Tree
from textual.widgets.tree import TreeNode
def get_info(info: Dict[str, str], key: str):
return (info[key] + "\n") if key in info else ""
class TreeValue(ABC):
"""Abstraction for the data of value in the tree."""
@abstractmethod
def name(self) -> str:
pass
@abstractmethod
def description(self) -> str:
pass
@abstractmethod
def matches(self, query: str) -> bool:
pass
@abstractmethod
def parse(self) -> perf.evlist:
pass
@abstractmethod
def value(self, evlist: perf.evlist, evsel: perf.evsel, cpu: int, thread: int) -> float:
pass
@dataclass
class Metric(TreeValue):
"""A metric in the tree."""
metric_name: str
metric_pmu: str
def name(self) -> str:
return self.metric_name
def description(self) -> str:
"""Find and format metric description."""
for metric in perf.metrics():
if metric["MetricName"] != self.metric_name:
continue
if self.metric_pmu and metric["PMU"] != self.metric_pmu:
continue
desc = get_info(metric, "BriefDescription")
desc += get_info(metric, "PublicDescription")
desc += get_info(metric, "MetricExpr")
desc += get_info(metric, "MetricThreshold")
return desc
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.