intel: Track whether a buffer is idle to avoid trips to the kernel.
I've seen a number of apps spending unreasonable amounts of time in drm_intel_bo_busy during the buffer mapping process. We can't track idleness in general, in the case of buffers shared across processes. But this should significantly reduce our overhead for checking for busy on things like VBOs. Improves (unoptimized) glamor x11perf -f8text by 0.243334% +/- 0.161498% (n=1549), which has formerly been spending about .5% of its time hitting the kernel for drm_intel_gem_bo_busy(). Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>main
parent
734de7093d
commit
02f93c21e6
|
@ -211,6 +211,15 @@ struct _drm_intel_bo_gem {
|
|||
*/
|
||||
bool reusable;
|
||||
|
||||
/**
|
||||
* Boolean of whether the GPU is definitely not accessing the buffer.
|
||||
*
|
||||
* This is only valid when reusable, since non-reusable
|
||||
* buffers are those that have been shared wth other
|
||||
* processes, so we don't know their state.
|
||||
*/
|
||||
bool idle;
|
||||
|
||||
/**
|
||||
* Size in bytes of this buffer and its relocation descendents.
|
||||
*
|
||||
|
@ -567,11 +576,19 @@ drm_intel_gem_bo_busy(drm_intel_bo *bo)
|
|||
struct drm_i915_gem_busy busy;
|
||||
int ret;
|
||||
|
||||
if (bo_gem->reusable && bo_gem->idle)
|
||||
return false;
|
||||
|
||||
VG_CLEAR(busy);
|
||||
busy.handle = bo_gem->gem_handle;
|
||||
|
||||
ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_BUSY, &busy);
|
||||
|
||||
if (ret == 0) {
|
||||
bo_gem->idle = !busy.busy;
|
||||
return busy.busy;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return (ret == 0 && busy.busy);
|
||||
}
|
||||
|
||||
|
@ -2219,6 +2236,8 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used,
|
|||
drm_intel_bo *bo = bufmgr_gem->exec_bos[i];
|
||||
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
|
||||
|
||||
bo_gem->idle = false;
|
||||
|
||||
/* Disconnect the buffer from the validate list */
|
||||
bo_gem->validate_index = -1;
|
||||
bufmgr_gem->exec_bos[i] = NULL;
|
||||
|
@ -2314,6 +2333,8 @@ skip_execution:
|
|||
drm_intel_bo *bo = bufmgr_gem->exec_bos[i];
|
||||
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
|
||||
|
||||
bo_gem->idle = false;
|
||||
|
||||
/* Disconnect the buffer from the validate list */
|
||||
bo_gem->validate_index = -1;
|
||||
bufmgr_gem->exec_bos[i] = NULL;
|
||||
|
|
Loading…
Reference in New Issue