intel/perf: repurpose INTEL_DEBUG=no-oaconfig
We initially used this debug option to mean "don't bother registering the OA configuration into the kernel". This change makes this option suppress any interaction with the i915/perf interface. This is useful when debugging self modifying batches with performance queries while running on the intel_mi_runner. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2775>
This commit is contained in:
@@ -80,6 +80,9 @@ get_sysfs_dev_dir(struct gen_perf_config *perf, int fd)
|
|||||||
|
|
||||||
perf->sysfs_dev_dir[0] = '\0';
|
perf->sysfs_dev_dir[0] = '\0';
|
||||||
|
|
||||||
|
if (unlikely(INTEL_DEBUG & DEBUG_NO_OACONFIG))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (fstat(fd, &sb)) {
|
if (fstat(fd, &sb)) {
|
||||||
DBG("Failed to stat DRM fd\n");
|
DBG("Failed to stat DRM fd\n");
|
||||||
return false;
|
return false;
|
||||||
@@ -232,6 +235,16 @@ enumerate_sysfs_metrics(struct gen_perf_config *perf,
|
|||||||
closedir(metricsdir);
|
closedir(metricsdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_all_metrics(struct gen_perf_config *perf,
|
||||||
|
const struct gen_device_info *devinfo)
|
||||||
|
{
|
||||||
|
hash_table_foreach(perf->oa_metrics_table, entry) {
|
||||||
|
const struct gen_perf_query_info *query = entry->data;
|
||||||
|
register_oa_config(perf, devinfo, query, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
kernel_has_dynamic_config_support(struct gen_perf_config *perf, int fd)
|
kernel_has_dynamic_config_support(struct gen_perf_config *perf, int fd)
|
||||||
{
|
{
|
||||||
@@ -394,11 +407,16 @@ init_oa_sys_vars(struct gen_perf_config *perf, const struct gen_device_info *dev
|
|||||||
{
|
{
|
||||||
uint64_t min_freq_mhz = 0, max_freq_mhz = 0;
|
uint64_t min_freq_mhz = 0, max_freq_mhz = 0;
|
||||||
|
|
||||||
if (!read_sysfs_drm_device_file_uint64(perf, "gt_min_freq_mhz", &min_freq_mhz))
|
if (likely(!(INTEL_DEBUG & DEBUG_NO_OACONFIG))) {
|
||||||
return false;
|
if (!read_sysfs_drm_device_file_uint64(perf, "gt_min_freq_mhz", &min_freq_mhz))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!read_sysfs_drm_device_file_uint64(perf, "gt_max_freq_mhz", &max_freq_mhz))
|
if (!read_sysfs_drm_device_file_uint64(perf, "gt_max_freq_mhz", &max_freq_mhz))
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
min_freq_mhz = 300;
|
||||||
|
max_freq_mhz = 1000;
|
||||||
|
}
|
||||||
|
|
||||||
memset(&perf->sys_vars, 0, sizeof(perf->sys_vars));
|
memset(&perf->sys_vars, 0, sizeof(perf->sys_vars));
|
||||||
perf->sys_vars.gt_min_freq = min_freq_mhz * 1000000;
|
perf->sys_vars.gt_min_freq = min_freq_mhz * 1000000;
|
||||||
@@ -679,11 +697,14 @@ load_oa_metrics(struct gen_perf_config *perf, int fd,
|
|||||||
*/
|
*/
|
||||||
oa_register(perf);
|
oa_register(perf);
|
||||||
|
|
||||||
if (likely((INTEL_DEBUG & DEBUG_NO_OACONFIG) == 0) &&
|
if (likely(!(INTEL_DEBUG & DEBUG_NO_OACONFIG))) {
|
||||||
kernel_has_dynamic_config_support(perf, fd))
|
if (kernel_has_dynamic_config_support(perf, fd))
|
||||||
init_oa_configs(perf, fd, devinfo);
|
init_oa_configs(perf, fd, devinfo);
|
||||||
else
|
else
|
||||||
enumerate_sysfs_metrics(perf, devinfo);
|
enumerate_sysfs_metrics(perf, devinfo);
|
||||||
|
} else {
|
||||||
|
add_all_metrics(perf, devinfo);
|
||||||
|
}
|
||||||
|
|
||||||
build_unique_counter_list(perf);
|
build_unique_counter_list(perf);
|
||||||
|
|
||||||
|
@@ -1774,8 +1774,9 @@ anv_queue_execbuf_locked(struct anv_queue *queue,
|
|||||||
/* Some performance queries just the pipeline statistic HW, no need for
|
/* Some performance queries just the pipeline statistic HW, no need for
|
||||||
* OA in that case, so no need to reconfigure.
|
* OA in that case, so no need to reconfigure.
|
||||||
*/
|
*/
|
||||||
if (query_info->kind == GEN_PERF_QUERY_TYPE_OA ||
|
if (likely((INTEL_DEBUG & DEBUG_NO_OACONFIG) == 0) &&
|
||||||
query_info->kind == GEN_PERF_QUERY_TYPE_RAW) {
|
(query_info->kind == GEN_PERF_QUERY_TYPE_OA ||
|
||||||
|
query_info->kind == GEN_PERF_QUERY_TYPE_RAW)) {
|
||||||
int ret = gen_ioctl(device->perf_fd, I915_PERF_IOCTL_CONFIG,
|
int ret = gen_ioctl(device->perf_fd, I915_PERF_IOCTL_CONFIG,
|
||||||
(void *)(uintptr_t) query_info->oa_metrics_set_id);
|
(void *)(uintptr_t) query_info->oa_metrics_set_id);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@@ -180,18 +180,21 @@ VkResult anv_AcquirePerformanceConfigurationINTEL(
|
|||||||
VkPerformanceConfigurationINTEL* pConfiguration)
|
VkPerformanceConfigurationINTEL* pConfiguration)
|
||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
struct gen_perf_registers *perf_config =
|
if (likely(!(INTEL_DEBUG & DEBUG_NO_OACONFIG))) {
|
||||||
gen_perf_load_configuration(device->physical->perf, device->fd,
|
struct gen_perf_registers *perf_config =
|
||||||
GEN_PERF_QUERY_GUID_MDAPI);
|
gen_perf_load_configuration(device->physical->perf, device->fd,
|
||||||
if (!perf_config)
|
GEN_PERF_QUERY_GUID_MDAPI);
|
||||||
return VK_INCOMPLETE;
|
if (!perf_config)
|
||||||
|
return VK_INCOMPLETE;
|
||||||
|
|
||||||
int ret = gen_perf_store_configuration(device->physical->perf, device->fd,
|
ret = gen_perf_store_configuration(device->physical->perf, device->fd,
|
||||||
perf_config, NULL /* guid */);
|
perf_config, NULL /* guid */);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ralloc_free(perf_config);
|
ralloc_free(perf_config);
|
||||||
return VK_INCOMPLETE;
|
return VK_INCOMPLETE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*pConfiguration = (VkPerformanceConfigurationINTEL) (uint64_t) ret;
|
*pConfiguration = (VkPerformanceConfigurationINTEL) (uint64_t) ret;
|
||||||
@@ -206,7 +209,8 @@ VkResult anv_ReleasePerformanceConfigurationINTEL(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
uint64_t config = (uint64_t) _configuration;
|
uint64_t config = (uint64_t) _configuration;
|
||||||
|
|
||||||
gen_ioctl(device->fd, DRM_IOCTL_I915_PERF_REMOVE_CONFIG, &config);
|
if (likely(!(INTEL_DEBUG & DEBUG_NO_OACONFIG)))
|
||||||
|
gen_ioctl(device->fd, DRM_IOCTL_I915_PERF_REMOVE_CONFIG, &config);
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -219,15 +223,17 @@ VkResult anv_QueueSetPerformanceConfigurationINTEL(
|
|||||||
struct anv_device *device = queue->device;
|
struct anv_device *device = queue->device;
|
||||||
uint64_t configuration = (uint64_t) _configuration;
|
uint64_t configuration = (uint64_t) _configuration;
|
||||||
|
|
||||||
if (device->perf_fd < 0) {
|
if (likely(!(INTEL_DEBUG & DEBUG_NO_OACONFIG))) {
|
||||||
device->perf_fd = anv_device_perf_open(device, configuration);
|
if (device->perf_fd < 0) {
|
||||||
if (device->perf_fd < 0)
|
device->perf_fd = anv_device_perf_open(device, configuration);
|
||||||
return VK_ERROR_INITIALIZATION_FAILED;
|
if (device->perf_fd < 0)
|
||||||
} else {
|
return VK_ERROR_INITIALIZATION_FAILED;
|
||||||
int ret = gen_ioctl(device->perf_fd, I915_PERF_IOCTL_CONFIG,
|
} else {
|
||||||
|
int ret = gen_ioctl(device->perf_fd, I915_PERF_IOCTL_CONFIG,
|
||||||
(void *)(uintptr_t) _configuration);
|
(void *)(uintptr_t) _configuration);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return anv_device_set_lost(device, "i915-perf config failed: %m");
|
return anv_device_set_lost(device, "i915-perf config failed: %m");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
@@ -342,12 +348,15 @@ VkResult anv_AcquireProfilingLockKHR(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
struct gen_perf_config *perf = device->physical->perf;
|
struct gen_perf_config *perf = device->physical->perf;
|
||||||
struct gen_perf_query_info *first_metric_set = &perf->queries[0];
|
struct gen_perf_query_info *first_metric_set = &perf->queries[0];
|
||||||
|
int fd = -1;
|
||||||
|
|
||||||
assert(device->perf_fd == -1);
|
assert(device->perf_fd == -1);
|
||||||
|
|
||||||
int fd = anv_device_perf_open(device, first_metric_set->oa_metrics_set_id);
|
if (likely(!(INTEL_DEBUG & DEBUG_NO_OACONFIG))) {
|
||||||
if (fd < 0)
|
fd = anv_device_perf_open(device, first_metric_set->oa_metrics_set_id);
|
||||||
return VK_TIMEOUT;
|
if (fd < 0)
|
||||||
|
return VK_TIMEOUT;
|
||||||
|
}
|
||||||
|
|
||||||
device->perf_fd = fd;
|
device->perf_fd = fd;
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
@@ -358,8 +367,10 @@ void anv_ReleaseProfilingLockKHR(
|
|||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
|
|
||||||
assert(device->perf_fd >= 0);
|
if (likely(!(INTEL_DEBUG & DEBUG_NO_OACONFIG))) {
|
||||||
close(device->perf_fd);
|
assert(device->perf_fd >= 0);
|
||||||
|
close(device->perf_fd);
|
||||||
|
}
|
||||||
device->perf_fd = -1;
|
device->perf_fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user