On Thu, Aug 01, 2024 at 04:58:16AM +0000, Mingwei Zhang wrote: > @@ -3299,9 +3309,6 @@ ctx_sched_out(struct perf_event_context *ctx, enum event_type_t event_type) > struct perf_cpu_context *cpuctx = this_cpu_ptr(&perf_cpu_context); > struct perf_event_pmu_context *pmu_ctx; > int is_active = ctx->is_active; > - bool cgroup = event_type & EVENT_CGROUP; > - > - event_type &= ~EVENT_CGROUP; > > lockdep_assert_held(&ctx->lock); > > @@ -3336,7 +3343,7 @@ ctx_sched_out(struct perf_event_context *ctx, enum event_type_t event_type) > barrier(); > } > > - ctx->is_active &= ~event_type; > + ctx->is_active &= ~(event_type & ~EVENT_FLAGS); > if (!(ctx->is_active & EVENT_ALL)) > ctx->is_active = 0; > > @@ -3912,9 +3919,6 @@ ctx_sched_in(struct perf_event_context *ctx, enum event_type_t event_type) > { > struct perf_cpu_context *cpuctx = this_cpu_ptr(&perf_cpu_context); > int is_active = ctx->is_active; > - bool cgroup = event_type & EVENT_CGROUP; > - > - event_type &= ~EVENT_CGROUP; > > lockdep_assert_held(&ctx->lock); > > @@ -3932,7 +3936,7 @@ ctx_sched_in(struct perf_event_context *ctx, enum event_type_t event_type) > barrier(); > } > > - ctx->is_active |= (event_type | EVENT_TIME); > + ctx->is_active |= ((event_type & ~EVENT_FLAGS) | EVENT_TIME); > if (ctx->task) { > if (!is_active) > cpuctx->task_ctx = ctx; Would it make sense to do something like: enum event_type_t active_type = event_type & ~EVENT_FLAGS; ctx->is_active &= ~active_type; and ctx->is_active |= (active_type | EVENT_TIME); Or something along those lines; those expressions become a little unwieldy otherwise.