perf/core: Disallow uncore-cgroup events
authorPeter Zijlstra <peterz@infradead.org>
Wed, 6 Nov 2019 11:51:04 +0000 (12:51 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 13 Nov 2019 07:16:39 +0000 (08:16 +0100)
While discussing uncore event scheduling, I noticed we do not in fact
seem to dis-allow making uncore-cgroup events. Such events make no
sense what so ever because the cgroup is a CPU local state where
uncore counts across a number of CPUs.

Disallow them.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/events/core.c

index aec8dba..022a34b 100644 (file)
@@ -10535,6 +10535,15 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
                goto err_ns;
        }
 
+       /*
+        * Disallow uncore-cgroup events, they don't make sense as the cgroup will
+        * be different on other CPUs in the uncore mask.
+        */
+       if (pmu->task_ctx_nr == perf_invalid_context && cgroup_fd != -1) {
+               err = -EINVAL;
+               goto err_pmu;
+       }
+
        if (event->attr.aux_output &&
            !(pmu->capabilities & PERF_PMU_CAP_AUX_OUTPUT)) {
                err = -EOPNOTSUPP;