sna: Refuse to create larger than max temporary upload bo
The maximum size is determined by available RAM, if we exceed it we greatly increase the risk of swap thrashing. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
7a26479277
commit
cbd8f16ea0
|
|
@ -2959,10 +2959,13 @@ search_linear_cache(struct kgem *kgem, unsigned int num_pages, unsigned flags)
|
|||
bool use_active = (flags & CREATE_INACTIVE) == 0;
|
||||
struct list *cache;
|
||||
|
||||
DBG(("%s: num_pages=%d, flags=%x, use_active? %d\n",
|
||||
__FUNCTION__, num_pages, flags, use_active));
|
||||
DBG(("%s: num_pages=%d, flags=%x, use_active? %d, use_large=%d [max=%d]\n",
|
||||
__FUNCTION__, num_pages, flags, use_active,
|
||||
num_pages >= MAX_CACHE_SIZE / PAGE_SIZE,
|
||||
MAX_CACHE_SIZE / PAGE_SIZE));
|
||||
|
||||
if (num_pages >= MAX_CACHE_SIZE / PAGE_SIZE) {
|
||||
DBG(("%s: searching large buffers\n", __FUNCTION__));
|
||||
retry_large:
|
||||
cache = use_active ? &kgem->large : &kgem->large_inactive;
|
||||
list_for_each_entry_safe(bo, first, cache, list) {
|
||||
|
|
@ -2986,7 +2989,7 @@ retry_large:
|
|||
}
|
||||
|
||||
if (bo->purged && !kgem_bo_clear_purgeable(kgem, bo))
|
||||
continue;
|
||||
goto discard;
|
||||
|
||||
list_del(&bo->list);
|
||||
if (bo->rq == (void *)kgem)
|
||||
|
|
@ -2996,7 +2999,8 @@ retry_large:
|
|||
return bo;
|
||||
|
||||
discard:
|
||||
kgem_bo_free(kgem, bo);
|
||||
if (!use_active)
|
||||
kgem_bo_free(kgem, bo);
|
||||
}
|
||||
|
||||
if (use_active) {
|
||||
|
|
@ -5470,6 +5474,9 @@ struct kgem_bo *kgem_upload_source_image(struct kgem *kgem,
|
|||
struct kgem_bo *bo;
|
||||
void *dst;
|
||||
|
||||
if (!kgem_can_create_2d(kgem, width, height, bpp))
|
||||
return NULL;
|
||||
|
||||
DBG(("%s : (%d, %d), (%d, %d), stride=%d, bpp=%d\n",
|
||||
__FUNCTION__, box->x1, box->y1, box->x2, box->y2, stride, bpp));
|
||||
|
||||
|
|
|
|||
|
|
@ -1008,11 +1008,14 @@ sna_render_picture_partial(struct sna *sna,
|
|||
if (use_cpu_bo(sna, pixmap, &box, false)) {
|
||||
bo = sna_pixmap(pixmap)->cpu_bo;
|
||||
} else {
|
||||
if (!sna_pixmap_force_to_gpu(pixmap,
|
||||
MOVE_READ | MOVE_SOURCE_HINT))
|
||||
struct sna_pixmap *priv;
|
||||
|
||||
priv = sna_pixmap_force_to_gpu(pixmap,
|
||||
MOVE_READ | MOVE_SOURCE_HINT);
|
||||
if (priv == NULL)
|
||||
return 0;
|
||||
|
||||
bo = sna_pixmap(pixmap)->gpu_bo;
|
||||
bo = priv->gpu_bo;
|
||||
}
|
||||
|
||||
if (bo->pitch > sna->render.max_3d_pitch)
|
||||
|
|
@ -1188,7 +1191,6 @@ sna_render_picture_extract(struct sna *sna,
|
|||
pixmap->devKind,
|
||||
pixmap->drawable.bitsPerPixel);
|
||||
if (bo != NULL &&
|
||||
pixmap->usage_hint == 0 &&
|
||||
box.x2 - box.x1 == pixmap->drawable.width &&
|
||||
box.y2 - box.y1 == pixmap->drawable.height) {
|
||||
struct sna_pixmap *priv = sna_pixmap(pixmap);
|
||||
|
|
|
|||
Loading…
Reference in New Issue