[Intel-gfx] [PATCH v2] drm/i915/pmu: Deprecate I915_PMU_LAST and optimize state tracking

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Mon Nov 30 12:31:41 UTC 2020


On 27/11/2020 10:36, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2020-11-27 10:01:09)
>> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
>>
>> Adding any kinds of "last" abi markers is usually a mistake which I
>> repeated when implementing the PMU because it felt convenient at the time.
>>
>> This patch marks I915_PMU_LAST as deprecated and stops the internal
>> implementation using it for sizing the event status bitmask and array.
>>
>> New way of sizing the fields is a bit less elegant, but it omits reserving
>> slots for tracking events we are not interested in, and as such saves some
>> runtime space. Adding sampling events is likely to be a special event and
>> the new plumbing needed will be easily detected in testing. Existing
>> asserts against the bitfield and array sizes are keeping the code safe.
>>
>> First event which gets the new treatment in this new scheme are the
>> interrupts - which neither needs any tracking in i915 pmu nor needs
>> waking up the GPU to read it.
>>
>> v2:
>>   * Streamline helper names. (Chris)
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
>> Cc: Chris Wilson <chris at chris-wilson.co.uk>
>> ---
>>   drivers/gpu/drm/i915/i915_pmu.c | 80 ++++++++++++++++++++++++---------
>>   drivers/gpu/drm/i915/i915_pmu.h | 35 ++++++++++-----
>>   include/uapi/drm/i915_drm.h     |  2 +-
>>   3 files changed, 83 insertions(+), 34 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
>> index cd786ad12be7..06dc63bf84d7 100644
>> --- a/drivers/gpu/drm/i915/i915_pmu.c
>> +++ b/drivers/gpu/drm/i915/i915_pmu.c
>> @@ -27,8 +27,6 @@
>>           BIT(I915_SAMPLE_WAIT) | \
>>           BIT(I915_SAMPLE_SEMA))
>>   
>> -#define ENGINE_SAMPLE_BITS (1 << I915_PMU_SAMPLE_BITS)
>> -
>>   static cpumask_t i915_pmu_cpumask;
>>   static unsigned int i915_pmu_target_cpu = -1;
>>   
>> @@ -57,17 +55,38 @@ static bool is_engine_config(u64 config)
>>          return config < __I915_PMU_OTHER(0);
>>   }
>>   
>> -static unsigned int config_enabled_bit(u64 config)
>> +static unsigned int other_bit(const u64 config)
>> +{
>> +       unsigned int val;
>> +
>> +       switch (config) {
>> +       case I915_PMU_ACTUAL_FREQUENCY:
>> +               val =  __I915_PMU_ACTUAL_FREQUENCY_ENABLED;
>> +               break;
>> +       case I915_PMU_REQUESTED_FREQUENCY:
>> +               val = __I915_PMU_REQUESTED_FREQUENCY_ENABLED;
>> +               break;
>> +       case I915_PMU_RC6_RESIDENCY:
>> +               val = __I915_PMU_RC6_RESIDENCY_ENABLED;
>> +               break;
>> +       default:
> 
> Should we explicitly list the untracked events?
> 
> At least we should put a comment here to remind ourselves what takes
> the default path.
> 
> /* Anything that doesn't require event tracking can be ignored */

Comment is I think enough, I wouldn't want to list all events because 
that partially defeats the purpose of the simplification. If something 
will be forgotten here IGTs would tell us.

>> +               return -1;
>> +       }
>> +
>> +       return I915_ENGINE_SAMPLE_COUNT + val;
>> +}
>> +
>> +static unsigned int config_bit(const u64 config)
>>   {
>>          if (is_engine_config(config))
>>                  return engine_config_sample(config);
>>          else
>> -               return ENGINE_SAMPLE_BITS + (config - __I915_PMU_OTHER(0));
>> +               return other_bit(config);
>>   }
> 
> Thanks, that reads so much more clearly to me, and complements it use
> well.
> 
> Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>

Thanks!

Regards,

Tvrtko



More information about the Intel-gfx mailing list