[PATCH 01/24] drm/amdkfd/kfd_ioctl: add pc sampling support
James Zhu
jamesz at amd.com
Thu Nov 23 20:33:30 UTC 2023
On 2023-11-22 16:14, Felix Kuehling wrote:
> On 2023-11-03 09:11, James Zhu wrote:
>> From: David Yat Sin <david.yatsin at amd.com>
>>
>> Add pc sampling support in kfd_ioctl.
>>
>> Co-developed-by: James Zhu <James.Zhu at amd.com>
>> Signed-off-by: James Zhu <James.Zhu at amd.com>
>> Signed-off-by: David Yat Sin <david.yatsin at amd.com>
>> ---
>> include/uapi/linux/kfd_ioctl.h | 57 +++++++++++++++++++++++++++++++++-
>> 1 file changed, 56 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/uapi/linux/kfd_ioctl.h
>> b/include/uapi/linux/kfd_ioctl.h
>> index f0ed68974c54..5202e29c9560 100644
>> --- a/include/uapi/linux/kfd_ioctl.h
>> +++ b/include/uapi/linux/kfd_ioctl.h
>> @@ -1446,6 +1446,58 @@ struct kfd_ioctl_dbg_trap_args {
>> };
>> };
>> +/**
>> + * kfd_ioctl_pc_sample_op - PC Sampling ioctl operations
>> + *
>> + * @KFD_IOCTL_PCS_OP_QUERY_CAPABILITIES: Query device PC Sampling
>> capabilities
>> + * @KFD_IOCTL_PCS_OP_CREATE: Register this process with
>> a per-device PC sampler instance
>> + * @KFD_IOCTL_PCS_OP_DESTROY: Unregister from a
>> previously registered PC sampler instance
>> + * @KFD_IOCTL_PCS_OP_START: Process begins taking
>> samples from a previously registered PC sampler instance
>> + * @KFD_IOCTL_PCS_OP_STOP: Process stops taking
>> samples from a previously registered PC sampler instance
>> + */
>> +enum kfd_ioctl_pc_sample_op {
>> + KFD_IOCTL_PCS_OP_QUERY_CAPABILITIES,
>> + KFD_IOCTL_PCS_OP_CREATE,
>> + KFD_IOCTL_PCS_OP_DESTROY,
>> + KFD_IOCTL_PCS_OP_START,
>> + KFD_IOCTL_PCS_OP_STOP,
>> +};
>> +
>> +/* Values have to be a power of 2*/
>> +#define KFD_IOCTL_PCS_FLAG_POWER_OF_2 0x00000001
>> +
>> +enum kfd_ioctl_pc_sample_method {
>> + KFD_IOCTL_PCS_METHOD_HOSTTRAP = 1,
>> + KFD_IOCTL_PCS_METHOD_STOCHASTIC,
>> +};
>> +
>> +enum kfd_ioctl_pc_sample_type {
>> + KFD_IOCTL_PCS_TYPE_TIME_US,
>> + KFD_IOCTL_PCS_TYPE_CLOCK_CYCLES,
>> + KFD_IOCTL_PCS_TYPE_INSTRUCTIONS
>> +};
>> +
>> +struct kfd_pc_sample_info {
>> + __u64 value; /* [IN] if PCS_TYPE_INTERVAL_US: sample
>> interval in us
>> + * if PCS_TYPE_CLOCK_CYCLES: sample
>> interval in graphics core clk cycles
>> + * if PCS_TYPE_INSTRUCTIONS: sample
>> interval in instructions issued by
>> + * graphics compute units
>
> I'd call this "interval". That's still generic enough to be a sampling
> interval in a unit that depends on the PCS type. "value" is
> misleading, because it sounds like it may be an actual sample.
[JZ] I am fine this interface name changes,
>
>
>> + */
>> + __u64 value_min; /* [OUT] */
>> + __u64 value_max; /* [OUT] */
>
> interval_min/max.
>
> Regards,
> Felix
>
>
>> + __u64 flags; /* [OUT] indicate potential restrictions
>> e.g FLAG_POWER_OF_2 */
>> + __u32 method; /* [IN/OUT] kfd_ioctl_pc_sample_method */
>> + __u32 type; /* [IN/OUT] kfd_ioctl_pc_sample_type */
>> +};
>> +
>> +struct kfd_ioctl_pc_sample_args {
>> + __u64 sample_info_ptr; /* array of kfd_pc_sample_info */
>> + __u32 num_sample_info;
>> + __u32 op; /* kfd_ioctl_pc_sample_op */
>> + __u32 gpu_id;
>> + __u32 trace_id;
>> +};
>> +
>> #define AMDKFD_IOCTL_BASE 'K'
>> #define AMDKFD_IO(nr) _IO(AMDKFD_IOCTL_BASE, nr)
>> #define AMDKFD_IOR(nr, type) _IOR(AMDKFD_IOCTL_BASE, nr, type)
>> @@ -1566,7 +1618,10 @@ struct kfd_ioctl_dbg_trap_args {
>> #define AMDKFD_IOC_DBG_TRAP \
>> AMDKFD_IOWR(0x26, struct kfd_ioctl_dbg_trap_args)
>> +#define AMDKFD_IOC_PC_SAMPLE \
>> + AMDKFD_IOWR(0x27, struct kfd_ioctl_pc_sample_args)
>> +
>> #define AMDKFD_COMMAND_START 0x01
>> -#define AMDKFD_COMMAND_END 0x27
>> +#define AMDKFD_COMMAND_END 0x28
>> #endif
More information about the amd-gfx
mailing list