Re: The issue with page allocation 5.3 rc1-rc2 (seems drm culprit here)

From: Alex Deucher
Date: Thu Aug 08 2019 - 01:32:06 EST


On Wed, Aug 7, 2019 at 11:49 PM Mikhail Gavrilov
<mikhail.v.gavrilov@xxxxxxxxx> wrote:
>
> On Tue, 6 Aug 2019 at 06:48, Hillf Danton <hdanton@xxxxxxxx> wrote:
> >
> > My bad, respin with one header file added.
> >
> > Hillf
> > -----8<---
> >
> > --- a/drivers/gpu/drm/amd/display/dc/core/dc.c
> > +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
> > @@ -23,6 +23,7 @@
> > */
> >
> > #include <linux/slab.h>
> > +#include <linux/mm.h>
> >
> > #include "dm_services.h"
> >
> > @@ -1174,8 +1175,12 @@ struct dc_state *dc_create_state(struct
> > struct dc_state *context = kzalloc(sizeof(struct dc_state),
> > GFP_KERNEL);
> >
> > - if (!context)
> > - return NULL;
> > + if (!context) {
> > + context = kvzalloc(sizeof(struct dc_state),
> > + GFP_KERNEL);
> > + if (!context)
> > + return NULL;
> > + }
> > /* Each context must have their own instance of VBA and in order to
> > * initialize and obtain IP and SOC the base DML instance from DC is
> > * initially copied into every context
> > @@ -1195,8 +1200,13 @@ struct dc_state *dc_copy_state(struct dc
> > struct dc_state *new_ctx = kmemdup(src_ctx,
> > sizeof(struct dc_state), GFP_KERNEL);
> >
> > - if (!new_ctx)
> > - return NULL;
> > + if (!new_ctx) {
> > + new_ctx = kvmalloc(sizeof(*new_ctx), GFP_KERNEL);
> > + if (new_ctx)
> > + *new_ctx = *src_ctx;
> > + else
> > + return NULL;
> > + }
> >
> > for (i = 0; i < MAX_PIPES; i++) {
> > struct pipe_ctx *cur_pipe = &new_ctx->res_ctx.pipe_ctx[i];
> > @@ -1230,7 +1240,7 @@ static void dc_state_free(struct kref *k
> > {
> > struct dc_state *context = container_of(kref, struct dc_state, refcount);
> > dc_resource_state_destruct(context);
> > - kfree(context);
> > + kvfree(context);
> > }
> >
> > void dc_release_state(struct dc_state *context)
> > --
> >
>
> Unfortunately error "gnome-shell: page allocation failure: order:4,
> mode:0x40cc0(GFP_KERNEL|__GFP_COMP),
> nodemask=(null),cpuset=/,mems_allowed=0" still happens even with
> applying this patch.

I think we can just drop the kmalloc altogether. How about this patch?

Alex

>
> Thanks.
>
>
> --
> Best Regards,
> Mike Gavrilov.
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
From c3ba6f05ca3e0371254fbfb1a8c06274e3cdb96e Mon Sep 17 00:00:00 2001
From: Alex Deucher <alexander.deucher@xxxxxxx>
Date: Thu, 8 Aug 2019 00:29:23 -0500
Subject: [PATCH] drm/amd/display: use kvmalloc for dc_state

It's large and doesn't need contiguous memory.

Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx>
---
drivers/gpu/drm/amd/display/dc/core/dc.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 252b621d93a9..ef780a4e484a 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -23,6 +23,7 @@
*/

#include <linux/slab.h>
+#include <linux/mm.h>

#include "dm_services.h"

@@ -1183,8 +1184,8 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc)

struct dc_state *dc_create_state(struct dc *dc)
{
- struct dc_state *context = kzalloc(sizeof(struct dc_state),
- GFP_KERNEL);
+ struct dc_state *context = kvzalloc(sizeof(struct dc_state),
+ GFP_KERNEL);

if (!context)
return NULL;
@@ -1204,11 +1205,11 @@ struct dc_state *dc_create_state(struct dc *dc)
struct dc_state *dc_copy_state(struct dc_state *src_ctx)
{
int i, j;
- struct dc_state *new_ctx = kmemdup(src_ctx,
- sizeof(struct dc_state), GFP_KERNEL);
+ struct dc_state *new_ctx = kvmalloc(sizeof(struct dc_state), GFP_KERNEL);

if (!new_ctx)
return NULL;
+ memcpy(new_ctx, src_ctx, sizeof(struct dc_state));

for (i = 0; i < MAX_PIPES; i++) {
struct pipe_ctx *cur_pipe = &new_ctx->res_ctx.pipe_ctx[i];
--
2.20.1