Skip to content

Commit da282bf

Browse files
committed
verification/rvgen: Add support for per-obj monitors
The special per-object monitor type was just introduced in RV, this requires the user to define some functions and type specific to the object. Adapt rvgen to add stub definitions for the monitor_target type and other modifications required to create per-object monitors. Reviewed-by: Nam Cao <namcao@linutronix.de> Link: https://lore.kernel.org/r/20260330111010.153663-10-gmonaco@redhat.com Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
1 parent 4a24127 commit da282bf

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

tools/verification/rvgen/rvgen/dot2k.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def __init__(self, file_path, MonitorType, extra_params={}):
2727
def fill_monitor_type(self) -> str:
2828
buff = [ self.monitor_type.upper() ]
2929
buff += self._fill_timer_type()
30+
if self.monitor_type == "per_obj":
31+
buff.append("typedef /* XXX: define the target type */ *monitor_target;")
3032
return "\n".join(buff)
3133

3234
def fill_tracepoint_handlers_skel(self) -> str:
@@ -45,6 +47,10 @@ def fill_tracepoint_handlers_skel(self) -> str:
4547
if self.monitor_type == "per_task":
4648
buff.append("\tstruct task_struct *p = /* XXX: how do I get p? */;");
4749
buff.append("\tda_%s(p, %s%s);" % (handle, event, self.enum_suffix));
50+
elif self.monitor_type == "per_obj":
51+
buff.append("\tint id = /* XXX: how do I get the id? */;")
52+
buff.append("\tmonitor_target t = /* XXX: how do I get t? */;")
53+
buff.append(f"\tda_{handle}(id, t, {event}{self.enum_suffix});")
4854
else:
4955
buff.append("\tda_%s(%s%s);" % (handle, event, self.enum_suffix));
5056
buff.append("}")
@@ -92,13 +98,16 @@ def fill_model_h(self) -> str:
9298

9399
return '\n'.join(buff)
94100

101+
def _is_id_monitor(self) -> bool:
102+
return self.monitor_type in ("per_task", "per_obj")
103+
95104
def fill_monitor_class_type(self) -> str:
96-
if self.monitor_type == "per_task":
105+
if self._is_id_monitor():
97106
return "DA_MON_EVENTS_ID"
98107
return "DA_MON_EVENTS_IMPLICIT"
99108

100109
def fill_monitor_class(self) -> str:
101-
if self.monitor_type == "per_task":
110+
if self._is_id_monitor():
102111
return "da_monitor_id"
103112
return "da_monitor"
104113

@@ -122,7 +131,7 @@ def fill_tracepoint_args_skel(self, tp_type: str) -> str:
122131
}
123132
tp_args_id = ("int ", "id")
124133
tp_args = tp_args_dict[tp_type]
125-
if self.monitor_type == "per_task":
134+
if self._is_id_monitor():
126135
tp_args.insert(0, tp_args_id)
127136
tp_proto_c = ", ".join([a+b for a,b in tp_args])
128137
tp_args_c = ", ".join([b for a,b in tp_args])
@@ -169,7 +178,7 @@ def __init__(self, *args, **kwargs):
169178
self.__parse_constraints()
170179

171180
def fill_monitor_class_type(self) -> str:
172-
if self.monitor_type == "per_task":
181+
if self._is_id_monitor():
173182
return "HA_MON_EVENTS_ID"
174183
return "HA_MON_EVENTS_IMPLICIT"
175184

tools/verification/rvgen/rvgen/generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def print_files(self):
243243

244244

245245
class Monitor(RVGenerator):
246-
monitor_types = { "global" : 1, "per_cpu" : 2, "per_task" : 3 }
246+
monitor_types = { "global" : 1, "per_cpu" : 2, "per_task" : 3, "per_obj" : 4 }
247247

248248
def __init__(self, extra_params={}):
249249
super().__init__(extra_params)

0 commit comments

Comments
 (0)