-
Notifications
You must be signed in to change notification settings - Fork 18
[RFC] ANDROID: GPU frequency tracing support #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: android/celadon
Are you sure you want to change the base?
[RFC] ANDROID: GPU frequency tracing support #28
Conversation
2cfa08a to
faad0cc
Compare
| goto err_free_tracer; | ||
| } | ||
|
|
||
| /* Allocate GT data array - assume max 2 GTs for now */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we read GTs count rather than doing hardcoding? May be we can implement some function to read it.
| return -EOPNOTSUPP; | ||
| } | ||
|
|
||
| if (gt->info.id >= 2) { /* Assume max 2 GTs */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once you have the way to read GTs count, we can remove this hardcoding
| struct xe_gpufreqtracer_data *tracer_data = gt_to_xe(gt)->gpufreqtracer_data; | ||
| struct xe_gpufreqtracer_gt_data *gt_data; | ||
|
|
||
| if (!tracer_data || gt->info.id >= 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment. we can remove the hardcoding once we implement function to read GTs count
|
|
||
| gt_data->monitoring_active = false; | ||
|
|
||
| timer_delete(>_data->timer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets use del_timer_sync()
| * This function is executed in a workqueue context to periodically sample | ||
| * the GPU frequency and perform any necessary tracing or logging operations. | ||
| * It is part of the GPU frequency tracer subsystem. | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to create dedicated work queue? we can use system_highpri_wq a global workqueue provided by the kernel.
upstream people might ask this questions. Lets have a proper reason for the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per the comment code has been modified.
| * | ||
| * location: /d/events/power/gpu_frequency | ||
| * format: {unsigned int state, unsigned int gpu_id} | ||
| * where state holds the frequency(in Khz) and the gpu_id holds the GPU clock domain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracepoint uses state for frequency. Consider using more descriptive field names in the tracepoint like freq_khz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's right, but this is as per the spec shared by google, they require it in such format.
drivers/gpu/drm/xe/xe_module.c
Outdated
| static int xe_validate_module_params(void) | ||
| { | ||
| /* Validate GPU frequency monitoring interval */ | ||
| if (xe_modparam.gpufreq_monitoring_interval_ms < 100 || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we define max and min interval?
faad0cc to
02784f3
Compare
drivers/gpu/drm/xe/xe_device.c
Outdated
|
|
||
| xe_device_remove_display(xe); | ||
|
|
||
| #ifdef CONFIG_DRM_GPUFREQTRACER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#ifdef CONFIG_DRM_GPUFREQTRACER (missing XE). Have a look
| current_freq = xe_guc_pc_get_act_freq(pc) * 1000; /* Convert MHz to KHz */ | ||
|
|
||
| /* Only report if frequency has changed or this is the first sample */ | ||
| if (current_freq != gt_data->last_frequency) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just check if there is concurrency problem. If yes use atomic or protect by some lock. Similarly for last_frequency.
A periodic GPU frequency monitoring and tracing program for the
Xe driver. The implementation provides bothperiodic sampling and
event-driven frequency change notifications through the Linux
ftrace infrastructure.
Key features:
- Periodic GPU frequency sampling with configurable intervals
- Immediate frequency change reporting via tracepoints
- Integration with Linux ftrace subsystem under 'power' events
- Per-GT (Graphics Technology) monitoring support
- Dedicated workqueue for non-blocking frequency sampling
- Configurable via CONFIG_DRM_XE_GPUFREQTRACER kernel option
- The monitoring interval can be configured at runtime via the sysfs
(default 5sec).
The sysfs entry is at:
/sys/module/xe/parameters/gpufreq_monitoring_interval_ms
The tracepoint is exposed at:
/sys/kernel/debug/tracing/events/power/gpu_frequency
Format: {unsigned int state, unsigned int gpu_id}
- state: GPU frequency in KHz
- gpu_id: GPU clock domain identifier
This enables userspace tools and system monitoring applications to track
GPU frequency changes for power management analysis, performance tuning,
and debugging purposes.
Bug: 388282937
Test: CtsGpuProfilingDataTestCases
Change-Id: I7e8025004abd4b3ffdfb4d7214a4b4896be95a64
Signed-off-by: S Sebinraj <[email protected]>
02784f3 to
46e3b29
Compare
A periodic GPU frequency monitoring and tracing program for the Xe driver. The implementation provides bothperiodic sampling and event-driven frequency change notifications through the Linux ftrace infrastructure.
Key features:
The sysfs entry is at:
/sys/module/xe/parameters/gpufreq_monitoring_interval_ms
The tracepoint is exposed at:
/sys/kernel/debug/tracing/events/power/gpu_frequency
Format: {unsigned int state, unsigned int gpu_id}
This enables userspace tools and system monitoring applications to track GPU frequency changes for power management analysis, performance tuning, and debugging purposes.
Bug: 388282937
Change-Id: I7e8025004abd4b3ffdfb4d7214a4b4896be95a64