The warning introduced in commit: 864c2357ca89 ("perf/core: Do not set cpuctx->cgrp for unscheduled cgroups") assumed that a cgroup switch always precedes list_del_event. This is not the case. Remove warning. Make sure that cpuctx->cgrp is NULL until a cgroup event is sched in or ctx->nr_cgroups == 0.
Unified · Split
| @@ -903,17 +903,14 @@ list_update_cgroup_event(struct perf_event *event, · 902 unmodified lines | ||
| 903 | 903 | */ |
| 904 | 904 | cpuctx = __get_cpu_context(ctx); |
| 905 | 905 | |
| 906 | − /* Only set/clear cpuctx->cgrp if current task uses event->cgrp. */ | |
| 907 | − if (perf_cgroup_from_task(current, ctx) != event->cgrp) { | |
| 908 | − /* | |
| 909 | − * We are removing the last cpu event in this context. | |
| 910 | − * If that event is not active in this cpu, cpuctx->cgrp | |
| 911 | − * should've been cleared by perf_cgroup_switch. | |
| 912 | − */ | |
| 913 | − WARN_ON_ONCE(!add && cpuctx->cgrp); | |
| 914 | − return; | |
| 915 | − } | |
| 916 | − cpuctx->cgrp = add ? event->cgrp : NULL; | |
| 906 | + /* | |
| 907 | + * cpuctx->cgrp is NULL until a cgroup event is sched in or | |
| 908 | + * ctx->nr_cgroup == 0 . | |
| 909 | + */ | |
| 910 | + if (add && perf_cgroup_from_task(current, ctx) == event->cgrp) | |
| 911 | + cpuctx->cgrp = event->cgrp; | |
| 912 | + else if (!add) | |
| 913 | + cpuctx->cgrp = NULL; | |
| 917 | 914 | } |
| 918 | 915 | |
| 919 | 916 | #else /* !CONFIG_CGROUP_PERF */ |