Re: [RFC PATCH 02/41] perf: Support guest enter/exit interfaces

From: Liang, Kan
Date: Wed Mar 20 2024 - 13:12:46 EST




On 2024-03-20 12:40 p.m., Raghavendra Rao Ananta wrote:
> Hi Kan,
>
>>
>> +static void __perf_force_exclude_guest_pmu(struct perf_event_pmu_context *pmu_ctx,
>> + struct perf_event *event)
>> +{
>> + struct perf_event_context *ctx = pmu_ctx->ctx;
>> + struct perf_event *sibling;
>> + bool include_guest = false;
>> +
>> + event_sched_out(event, ctx);
>> + if (!event->attr.exclude_guest)
>> + include_guest = true;
>> + for_each_sibling_event(sibling, event) {
>> + event_sched_out(sibling, ctx);
>> + if (!sibling->attr.exclude_guest)
>> + include_guest = true;
>> + }
>> + if (include_guest) {
>> + perf_event_set_state(event, PERF_EVENT_STATE_ERROR);
>> + for_each_sibling_event(sibling, event)
>> + perf_event_set_state(event, PERF_EVENT_STATE_ERROR);
>> + }
> Does the perf core revert the PERF_EVENT_STATE_ERROR state somewhere
> from the perf_guest_exit() path, or is it expected to remain in this
> state?
> IIUC, in the perf_guest_exit() path, when we land into
> merge_sched_in(), we never schedule the event back if event->state <=
> PERF_EVENT_STATE_OFF.
>

The perf doesn't revert event with the ERROR STATE. A user asks to
profile both guest and host, but the pass-through mode doesn't allow the
profiling of the guest. So it has to error out and remain the ERROR STATE.

Thanks,
Kan