* [PATCH] drm/virtio: use kvmalloc for large allocations
@ 2020-11-05 1:47 ` Sergey Senozhatsky
0 siblings, 0 replies; 12+ messages in thread
From: Sergey Senozhatsky @ 2020-11-05 1:47 UTC (permalink / raw)
To: Gerd Hoffmann, David Airlie, Daniel Vetter
Cc: Suleiman Souhlal, Sergey Senozhatsky, linux-kernel, dri-devel,
virtualization
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>
---
drivers/gpu/drm/virtio/virtgpu_object.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
index 2d3aa7baffe4..d9ad27e00905 100644
--- a/drivers/gpu/drm/virtio/virtgpu_object.c
+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
@@ -184,8 +184,9 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,
*nents = shmem->pages->orig_nents;
}
- *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;
--
2.29.1.341.ge80a0c044ae-goog
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH] drm/virtio: use kvmalloc for large allocations
@ 2020-11-05 1:47 ` Sergey Senozhatsky
0 siblings, 0 replies; 12+ messages in thread
From: Sergey Senozhatsky @ 2020-11-05 1:47 UTC (permalink / raw)
To: Gerd Hoffmann, David Airlie, Daniel Vetter
Cc: Suleiman Souhlal, dri-devel, virtualization, linux-kernel,
Sergey Senozhatsky
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>
---
drivers/gpu/drm/virtio/virtgpu_object.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
index 2d3aa7baffe4..d9ad27e00905 100644
--- a/drivers/gpu/drm/virtio/virtgpu_object.c
+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
@@ -184,8 +184,9 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,
*nents = shmem->pages->orig_nents;
}
- *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;
--
2.29.1.341.ge80a0c044ae-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH] drm/virtio: use kvmalloc for large allocations
2020-11-05 1:47 ` Sergey Senozhatsky
(?)
@ 2020-11-05 6:52 ` Gerd Hoffmann
-1 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2020-11-05 6:52 UTC (permalink / raw)
To: Sergey Senozhatsky
Cc: David Airlie, linux-kernel, dri-devel, virtualization,
Daniel Vetter, Suleiman Souhlal
Hi,
> - *ents = kmalloc_array(*nents, sizeof(struct virtio_gpu_mem_entry),
> - GFP_KERNEL);
> + *ents = kvmalloc_array(*nents,
> + sizeof(struct virtio_gpu_mem_entry),
> + GFP_KERNEL);
Shouldn't that be balanced with a kvfree() elsewhere?
take care,
Gerd
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] drm/virtio: use kvmalloc for large allocations
@ 2020-11-05 6:52 ` Gerd Hoffmann
0 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2020-11-05 6:52 UTC (permalink / raw)
To: Sergey Senozhatsky
Cc: David Airlie, Daniel Vetter, Suleiman Souhlal, dri-devel,
virtualization, linux-kernel
Hi,
> - *ents = kmalloc_array(*nents, sizeof(struct virtio_gpu_mem_entry),
> - GFP_KERNEL);
> + *ents = kvmalloc_array(*nents,
> + sizeof(struct virtio_gpu_mem_entry),
> + GFP_KERNEL);
Shouldn't that be balanced with a kvfree() elsewhere?
take care,
Gerd
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] drm/virtio: use kvmalloc for large allocations
@ 2020-11-05 6:52 ` Gerd Hoffmann
0 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2020-11-05 6:52 UTC (permalink / raw)
To: Sergey Senozhatsky
Cc: David Airlie, linux-kernel, dri-devel, virtualization,
Suleiman Souhlal
Hi,
> - *ents = kmalloc_array(*nents, sizeof(struct virtio_gpu_mem_entry),
> - GFP_KERNEL);
> + *ents = kvmalloc_array(*nents,
> + sizeof(struct virtio_gpu_mem_entry),
> + GFP_KERNEL);
Shouldn't that be balanced with a kvfree() elsewhere?
take care,
Gerd
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] drm/virtio: use kvmalloc for large allocations
2020-11-05 6:52 ` Gerd Hoffmann
(?)
@ 2020-11-05 7:00 ` Sergey Senozhatsky
-1 siblings, 0 replies; 12+ messages in thread
From: Sergey Senozhatsky @ 2020-11-05 7:00 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: David Airlie, linux-kernel, dri-devel, virtualization,
Sergey Senozhatsky, Daniel Vetter, Suleiman Souhlal
Hi,
On (20/11/05 07:52), Gerd Hoffmann wrote:
> > - *ents = kmalloc_array(*nents, sizeof(struct virtio_gpu_mem_entry),
> > - GFP_KERNEL);
> > + *ents = kvmalloc_array(*nents,
> > + sizeof(struct virtio_gpu_mem_entry),
> > + GFP_KERNEL);
>
> Shouldn't that be balanced with a kvfree() elsewhere?
I think it already is. ents pointer is assigned to vbuf->data_buf,
and free_vbuf() already uses kvfree(vbuf->data_buf) to free it.
-ss
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] drm/virtio: use kvmalloc for large allocations
@ 2020-11-05 7:00 ` Sergey Senozhatsky
0 siblings, 0 replies; 12+ messages in thread
From: Sergey Senozhatsky @ 2020-11-05 7:00 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: Sergey Senozhatsky, David Airlie, Daniel Vetter, Suleiman Souhlal,
dri-devel, virtualization, linux-kernel
Hi,
On (20/11/05 07:52), Gerd Hoffmann wrote:
> > - *ents = kmalloc_array(*nents, sizeof(struct virtio_gpu_mem_entry),
> > - GFP_KERNEL);
> > + *ents = kvmalloc_array(*nents,
> > + sizeof(struct virtio_gpu_mem_entry),
> > + GFP_KERNEL);
>
> Shouldn't that be balanced with a kvfree() elsewhere?
I think it already is. ents pointer is assigned to vbuf->data_buf,
and free_vbuf() already uses kvfree(vbuf->data_buf) to free it.
-ss
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] drm/virtio: use kvmalloc for large allocations
@ 2020-11-05 7:00 ` Sergey Senozhatsky
0 siblings, 0 replies; 12+ messages in thread
From: Sergey Senozhatsky @ 2020-11-05 7:00 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: David Airlie, linux-kernel, dri-devel, virtualization,
Sergey Senozhatsky, Suleiman Souhlal
Hi,
On (20/11/05 07:52), Gerd Hoffmann wrote:
> > - *ents = kmalloc_array(*nents, sizeof(struct virtio_gpu_mem_entry),
> > - GFP_KERNEL);
> > + *ents = kvmalloc_array(*nents,
> > + sizeof(struct virtio_gpu_mem_entry),
> > + GFP_KERNEL);
>
> Shouldn't that be balanced with a kvfree() elsewhere?
I think it already is. ents pointer is assigned to vbuf->data_buf,
and free_vbuf() already uses kvfree(vbuf->data_buf) to free it.
-ss
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] drm/virtio: use kvmalloc for large allocations
2020-11-05 7:00 ` Sergey Senozhatsky
(?)
@ 2020-11-05 11:34 ` Gerd Hoffmann
-1 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2020-11-05 11:34 UTC (permalink / raw)
To: Sergey Senozhatsky
Cc: David Airlie, linux-kernel, dri-devel, virtualization,
Sergey Senozhatsky, Daniel Vetter, Suleiman Souhlal
On Thu, Nov 05, 2020 at 04:00:54PM +0900, Sergey Senozhatsky wrote:
> Hi,
>
> On (20/11/05 07:52), Gerd Hoffmann wrote:
> > > - *ents = kmalloc_array(*nents, sizeof(struct virtio_gpu_mem_entry),
> > > - GFP_KERNEL);
> > > + *ents = kvmalloc_array(*nents,
> > > + sizeof(struct virtio_gpu_mem_entry),
> > > + GFP_KERNEL);
> >
> > Shouldn't that be balanced with a kvfree() elsewhere?
>
> I think it already is. ents pointer is assigned to vbuf->data_buf,
> and free_vbuf() already uses kvfree(vbuf->data_buf) to free it.
Ah, right, we needed that before elsewhere.
Ok then, pushed to drm-misc-next.
thanks,
Gerd
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] drm/virtio: use kvmalloc for large allocations
@ 2020-11-05 11:34 ` Gerd Hoffmann
0 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2020-11-05 11:34 UTC (permalink / raw)
To: Sergey Senozhatsky
Cc: Sergey Senozhatsky, David Airlie, Daniel Vetter, Suleiman Souhlal,
dri-devel, virtualization, linux-kernel
On Thu, Nov 05, 2020 at 04:00:54PM +0900, Sergey Senozhatsky wrote:
> Hi,
>
> On (20/11/05 07:52), Gerd Hoffmann wrote:
> > > - *ents = kmalloc_array(*nents, sizeof(struct virtio_gpu_mem_entry),
> > > - GFP_KERNEL);
> > > + *ents = kvmalloc_array(*nents,
> > > + sizeof(struct virtio_gpu_mem_entry),
> > > + GFP_KERNEL);
> >
> > Shouldn't that be balanced with a kvfree() elsewhere?
>
> I think it already is. ents pointer is assigned to vbuf->data_buf,
> and free_vbuf() already uses kvfree(vbuf->data_buf) to free it.
Ah, right, we needed that before elsewhere.
Ok then, pushed to drm-misc-next.
thanks,
Gerd
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] drm/virtio: use kvmalloc for large allocations
@ 2020-11-05 11:34 ` Gerd Hoffmann
0 siblings, 0 replies; 12+ messages in thread
From: Gerd Hoffmann @ 2020-11-05 11:34 UTC (permalink / raw)
To: Sergey Senozhatsky
Cc: David Airlie, linux-kernel, dri-devel, virtualization,
Sergey Senozhatsky, Suleiman Souhlal
On Thu, Nov 05, 2020 at 04:00:54PM +0900, Sergey Senozhatsky wrote:
> Hi,
>
> On (20/11/05 07:52), Gerd Hoffmann wrote:
> > > - *ents = kmalloc_array(*nents, sizeof(struct virtio_gpu_mem_entry),
> > > - GFP_KERNEL);
> > > + *ents = kvmalloc_array(*nents,
> > > + sizeof(struct virtio_gpu_mem_entry),
> > > + GFP_KERNEL);
> >
> > Shouldn't that be balanced with a kvfree() elsewhere?
>
> I think it already is. ents pointer is assigned to vbuf->data_buf,
> and free_vbuf() already uses kvfree(vbuf->data_buf) to free it.
Ah, right, we needed that before elsewhere.
Ok then, pushed to drm-misc-next.
thanks,
Gerd
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/1] drm/virtio: use kvmalloc for large allocations
@ 2021-03-02 22:38 Doug Horn
2021-03-04 15:05 ` [PATCH] " Sergey Senozhatsky
0 siblings, 1 reply; 12+ messages in thread
From: Doug Horn @ 2021-03-02 22:38 UTC (permalink / raw)
Cc: stable, senozhatsky, adelva, kaiyili, Gerd Hoffmann, Doug Horn
From: Sergey Senozhatsky <senozhatsky@chromium.org>
commit ea86f3defd55f141a44146e66cbf8ffb683d60da upstream.
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.
the original patch applied to a different file, this backport moved this
change to the proper place for 4.14/4.19/5.4.
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20201105014744.1662226-1-senozhatsky@chromium.org
Cc: stable@vger.kernel.org [4.14, 4.19, 5.4]
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Doug Horn <doughorn@google.com>
---
drivers/gpu/drm/virtio/virtgpu_vq.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index a956c73ea85e..374279ba1444 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -865,9 +865,9 @@ int virtio_gpu_object_attach(struct virtio_gpu_device *vgdev,
}
/* gets freed when the ring has consumed it */
- ents = kmalloc_array(obj->pages->nents,
- sizeof(struct virtio_gpu_mem_entry),
- GFP_KERNEL);
+ ents = kvmalloc_array(obj->pages->nents,
+ sizeof(struct virtio_gpu_mem_entry),
+ GFP_KERNEL);
if (!ents) {
DRM_ERROR("failed to allocate ent list\n");
return -ENOMEM;
--
2.30.1.766.gb4fecdf3b7-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH] drm/virtio: use kvmalloc for large allocations
2021-03-02 22:38 [PATCH 1/1] " Doug Horn
@ 2021-03-04 15:05 ` Sergey Senozhatsky
0 siblings, 0 replies; 12+ messages in thread
From: Sergey Senozhatsky @ 2021-03-04 15:05 UTC (permalink / raw)
Cc: adelva, kaiyili, Sergey Senozhatsky, stable, Gerd Hoffmann,
Doug Horn
From: Sergey Senozhatsky <senozhatsky@chromium.org>
commit ea86f3defd55f141a44146e66cbf8ffb683d60da upstream.
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>
Link: http://patchwork.freedesktop.org/patch/msgid/20201105014744.1662226-1-senozhatsky@chromium.org
Cc: stable@vger.kernel.org [5.4]
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Doug Horn <doughorn@google.com>
---
drivers/gpu/drm/virtio/virtgpu_vq.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index 92022a83bbd5..bb46e7a0f1b5 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -992,8 +992,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;
--
2.30.1.766.gb4fecdf3b7-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-03-04 15:08 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-05 1:47 [PATCH] drm/virtio: use kvmalloc for large allocations Sergey Senozhatsky
2020-11-05 1:47 ` Sergey Senozhatsky
2020-11-05 6:52 ` Gerd Hoffmann
2020-11-05 6:52 ` Gerd Hoffmann
2020-11-05 6:52 ` Gerd Hoffmann
2020-11-05 7:00 ` Sergey Senozhatsky
2020-11-05 7:00 ` Sergey Senozhatsky
2020-11-05 7:00 ` Sergey Senozhatsky
2020-11-05 11:34 ` Gerd Hoffmann
2020-11-05 11:34 ` Gerd Hoffmann
2020-11-05 11:34 ` Gerd Hoffmann
-- strict thread matches above, loose matches on Subject: below --
2021-03-02 22:38 [PATCH 1/1] " Doug Horn
2021-03-04 15:05 ` [PATCH] " Sergey Senozhatsky
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.