----- Original Message ----- > From: "Gerd Hoffmann" <kra...@redhat.com> > To: qemu-devel@nongnu.org > Cc: "Gerd Hoffmann" <kra...@redhat.com>, "Marc-André Lureau" > <marcandre.lur...@redhat.com>, "Dave Airlie" > <airl...@redhat.com>, "李强" <liqiang...@360.cn>, "Michael S. Tsirkin" > <m...@redhat.com> > Sent: Tuesday, 29 November, 2016 10:42:36 PM > Subject: [PATCH] virtio-gpu: track and limit host memory allocations > > This patch makes virtio-gpu track host memory allocations for ressources > and applies a limit (configurable 256M by default). When exceeding the > limit virtio-gpu throws VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY errors (like > it already does today when pixman image allocations fail). > > This patch covers 2d mode only. For 3d mode we have to figure how we > are going to handle this best. qemu doesn't track resources in case > virglrenderer is used, so I guess we should extend virglrenderer to > allow setting a limit, then let qemu set the limit and catch > virgl_renderer_resource_create failures.
The problem being we have no idea how much memory a GL allocation takes on the host, it is totally dependant on the GL drivers installed, and there is no way to find out. Space on host memory could be anywhere from a few bytes of metadata to the whole size of the allocation + a bunch of meta data overhead. Dave.