mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
perf metricgroups: Add NO_THRESHOLD_AND_NMI constraint
Thresholds can increase the number of counters a metric needs. The NMI watchdog can take away a counter (hopefully the buddy watchdog will become the default and this will no longer be true). Add a new constraint for the case that a metric and its thresholds would fit in counters but only if the NMI watchdog isn't enabled. Either the threshold or the NMI watchdog should be disabled to make the metric fit. Wire this up into the metric__group_events logic. Signed-off-by: Ian Rogers <irogers@google.com> Link: https://lore.kernel.org/r/20250719030517.1990983-16-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
parent
8dcd27b1b8
commit
fcc7cc3123
|
|
@ -235,6 +235,7 @@ class JsonEvent:
|
|||
'NO_GROUP_EVENTS_NMI': '2',
|
||||
'NO_NMI_WATCHDOG': '2',
|
||||
'NO_GROUP_EVENTS_SMT': '3',
|
||||
'NO_THRESHOLD_AND_NMI': '4',
|
||||
}
|
||||
return metric_constraint_to_enum[metric_constraint]
|
||||
|
||||
|
|
|
|||
|
|
@ -25,15 +25,21 @@ enum metric_event_groups {
|
|||
*/
|
||||
MetricNoGroupEvents = 1,
|
||||
/**
|
||||
* @MetricNoGroupEventsNmi: Don't group events for the metric if the NMI
|
||||
* watchdog is enabled.
|
||||
* @MetricNoGroupEventsNmi:
|
||||
* Don't group events for the metric if the NMI watchdog is enabled.
|
||||
*/
|
||||
MetricNoGroupEventsNmi = 2,
|
||||
/**
|
||||
* @MetricNoGroupEventsSmt: Don't group events for the metric if SMT is
|
||||
* enabled.
|
||||
* @MetricNoGroupEventsSmt:
|
||||
* Don't group events for the metric if SMT is enabled.
|
||||
*/
|
||||
MetricNoGroupEventsSmt = 3,
|
||||
/**
|
||||
* @MetricNoGroupEventsThresholdAndNmi:
|
||||
* Don't group events for the metric thresholds and if the NMI watchdog
|
||||
* is enabled.
|
||||
*/
|
||||
MetricNoGroupEventsThresholdAndNmi = 4,
|
||||
};
|
||||
/*
|
||||
* Describe each PMU event. Each CPU has a table of PMU events.
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ static void metric__watchdog_constraint_hint(const char *name, bool foot)
|
|||
" echo 1 > /proc/sys/kernel/nmi_watchdog\n");
|
||||
}
|
||||
|
||||
static bool metric__group_events(const struct pmu_metric *pm)
|
||||
static bool metric__group_events(const struct pmu_metric *pm, bool metric_no_threshold)
|
||||
{
|
||||
switch (pm->event_grouping) {
|
||||
case MetricNoGroupEvents:
|
||||
|
|
@ -191,6 +191,13 @@ static bool metric__group_events(const struct pmu_metric *pm)
|
|||
return false;
|
||||
case MetricNoGroupEventsSmt:
|
||||
return !smt_on();
|
||||
case MetricNoGroupEventsThresholdAndNmi:
|
||||
if (metric_no_threshold)
|
||||
return true;
|
||||
if (!sysctl__nmi_watchdog_enabled())
|
||||
return true;
|
||||
metric__watchdog_constraint_hint(pm->metric_name, /*foot=*/false);
|
||||
return false;
|
||||
case MetricGroupEvents:
|
||||
default:
|
||||
return true;
|
||||
|
|
@ -212,6 +219,7 @@ static void metric__free(struct metric *m)
|
|||
static struct metric *metric__new(const struct pmu_metric *pm,
|
||||
const char *modifier,
|
||||
bool metric_no_group,
|
||||
bool metric_no_threshold,
|
||||
int runtime,
|
||||
const char *user_requested_cpu_list,
|
||||
bool system_wide)
|
||||
|
|
@ -246,7 +254,7 @@ static struct metric *metric__new(const struct pmu_metric *pm,
|
|||
}
|
||||
m->pctx->sctx.runtime = runtime;
|
||||
m->pctx->sctx.system_wide = system_wide;
|
||||
m->group_events = !metric_no_group && metric__group_events(pm);
|
||||
m->group_events = !metric_no_group && metric__group_events(pm, metric_no_threshold);
|
||||
m->metric_refs = NULL;
|
||||
m->evlist = NULL;
|
||||
|
||||
|
|
@ -831,8 +839,8 @@ static int __add_metric(struct list_head *metric_list,
|
|||
* This metric is the root of a tree and may reference other
|
||||
* metrics that are added recursively.
|
||||
*/
|
||||
root_metric = metric__new(pm, modifier, metric_no_group, runtime,
|
||||
user_requested_cpu_list, system_wide);
|
||||
root_metric = metric__new(pm, modifier, metric_no_group, metric_no_threshold,
|
||||
runtime, user_requested_cpu_list, system_wide);
|
||||
if (!root_metric)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user