Re: [PATCH] drm/amd/display: use vmalloc for struct dc_state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/26/2024 16:45, Alex Deucher wrote:
This is a big structure so use vmalloc as malloc can
fail when there is memory pressure.

vmalloc can be a bit slower, but I think it's fine for this context and better to handle memory pressure more nicely.

Reviewed-by: Mario Limonciello <mario.limonciello@xxxxxxx>


Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3454
Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx>
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
index 5d4f831b1e55..080c1d5f7412 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
@@ -1491,9 +1491,10 @@ int pre_validate_dsc(struct drm_atomic_state *state,
  	 * from dm_state->context.
  	 */
- local_dc_state = kmemdup(dm_state->context, sizeof(struct dc_state), GFP_KERNEL);
+	local_dc_state = vmalloc(sizeof(struct dc_state));
  	if (!local_dc_state)
  		return -ENOMEM;
+	memcpy(local_dc_state, dm_state->context, sizeof(struct dc_state));
for (i = 0; i < local_dc_state->stream_count; i++) {
  		struct dc_stream_state *stream = dm_state->context->streams[i];
@@ -1563,7 +1564,7 @@ int pre_validate_dsc(struct drm_atomic_state *state,
  			dc_stream_release(local_dc_state->streams[i]);
  	}
- kfree(local_dc_state);
+	vfree(local_dc_state);
return ret;
  }




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux