mirror of
https://github.com/torvalds/linux.git
synced 2025-04-09 14:45:27 +00:00

RV now supports nested monitors, this functionality requires a container monitor, which has virtually no functionality besides holding other monitors, and nested monitors, that have a container as parent. Add the -p flag to pass a parent to a monitor, this sets it up while registering the monitor and adds necessary includes and configurations. Add the -c flag to create a container, since containers are empty, we don't allow supplying a dot model or a monitor type, the template is also different since functions to enable and disable the monitor are not defined, nor any tracepoint. The generated header file only allows to include the rv_monitor structure in children monitors. Cc: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Juri Lelli <juri.lelli@redhat.com> Link: https://lore.kernel.org/20250305140406.350227-8-gmonaco@redhat.com Signed-off-by: Gabriele Monaco <gmonaco@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
54 lines
2.3 KiB
Python
54 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
#
|
|
# Copyright (C) 2019-2022 Red Hat, Inc. Daniel Bristot de Oliveira <bristot@kernel.org>
|
|
#
|
|
# dot2k: transform dot files into a monitor for the Linux kernel.
|
|
#
|
|
# For further information, see:
|
|
# Documentation/trace/rv/da_monitor_synthesis.rst
|
|
|
|
if __name__ == '__main__':
|
|
from dot2.dot2k import dot2k
|
|
import argparse
|
|
import sys
|
|
|
|
def is_container():
|
|
"""Should work even before parsing the arguments"""
|
|
return "-c" in sys.argv or "--container" in sys.argv
|
|
|
|
parser = argparse.ArgumentParser(description='transform .dot file into kernel rv monitor')
|
|
parser.add_argument('-d', "--dot", dest="dot_file", required=not is_container())
|
|
parser.add_argument('-t', "--monitor_type", dest="monitor_type", required=not is_container(),
|
|
help=f"Available options: {', '.join(dot2k.monitor_types.keys())}")
|
|
parser.add_argument('-n', "--model_name", dest="model_name", required=is_container())
|
|
parser.add_argument("-D", "--description", dest="description", required=False)
|
|
parser.add_argument("-a", "--auto_patch", dest="auto_patch",
|
|
action="store_true", required=False,
|
|
help="Patch the kernel in place")
|
|
parser.add_argument("-p", "--parent", dest="parent",
|
|
required=False, help="Create a monitor nested to parent")
|
|
parser.add_argument("-c", "--container", dest="container",
|
|
action="store_true", required=False,
|
|
help="Create an empty monitor to be used as a container")
|
|
params = parser.parse_args()
|
|
|
|
if not is_container():
|
|
print("Opening and parsing the dot file %s" % params.dot_file)
|
|
try:
|
|
monitor=dot2k(params.dot_file, params.monitor_type, vars(params))
|
|
except Exception as e:
|
|
print('Error: '+ str(e))
|
|
print("Sorry : :-(")
|
|
sys.exit(1)
|
|
|
|
print("Writing the monitor into the directory %s" % monitor.name)
|
|
monitor.print_files()
|
|
print("Almost done, checklist")
|
|
if not is_container():
|
|
print(" - Edit the %s/%s.c to add the instrumentation" % (monitor.name, monitor.name))
|
|
print(monitor.fill_tracepoint_tooltip())
|
|
print(monitor.fill_makefile_tooltip())
|
|
print(monitor.fill_kconfig_tooltip())
|
|
print(monitor.fill_monitor_tooltip())
|