BACKPORT: drm/virtio: use kvmalloc for large allocations

We observed that some of virtio_gpu_object_shmem_init() allocations
can be rather costly - order 6 - which can be difficult to fulfill
under memory pressure conditions. Switch to kvmalloc_array() in
virtio_gpu_object_shmem_init() and let the kernel vmalloc the entries
array.

Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
(cherry picked from commit ea86f3defd55f141a44146e66cbf8ffb683d60da)
Bug: 171450517
Test: run clash of clans game on Kled device
Change-Id: I1b585177c7ebfbd95a494fc4e65150cd522517cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2519343
Reviewed-by: Suleiman Souhlal <suleiman@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Sergey Senozhatsky <senozhatsky@chromium.org>
Tested-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Alistair Delva <adelva@google.com>
This commit is contained in:
Sergey Senozhatsky 2020-11-05 10:47:44 +09:00 committed by Alistair Delva
parent a2e73af4e5
commit d7505557bd

View File

@ -1046,8 +1046,9 @@ int virtio_gpu_object_attach(struct virtio_gpu_device *vgdev,
}
/* gets freed when the ring has consumed it */
ents = kmalloc_array(nents, sizeof(struct virtio_gpu_mem_entry),
GFP_KERNEL);
ents = kvmalloc_array(nents,
sizeof(struct virtio_gpu_mem_entry),
GFP_KERNEL);
if (!ents) {
DRM_ERROR("failed to allocate ent list\n");
return -ENOMEM;