[PATCH 2/2] drm/xe: Don't unnecessarily invoke the OOM killer on multiple binds

Matthew Brost matthew.brost at intel.com
Thu Oct 17 14:52:36 UTC 2024


On Thu, Oct 17, 2024 at 04:44:07PM +0200, Thomas Hellström wrote:
> Multiple single-ioctl binds can be split up into multiple bind
> ioctls, reducing the memory required to hold the bind array.
> 
> So rather than allowing the OOM killer to be invoked, return
> -ENOMEM or -ENOBUFS to user-space to take corrective action.
> 
> Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>

Reviewed-by: Matthew Brost <matthew.brost at intel.com>

> Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2701
> Signed-off-by: Thomas Hellström <thomas.hellstrom at linux.intel.com>
> ---
>  drivers/gpu/drm/xe/xe_vm.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index c99380271de6..0142b4daf714 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -733,7 +733,7 @@ static int xe_vma_ops_alloc(struct xe_vma_ops *vops, bool array_of_binds)
>  		vops->pt_update_ops[i].ops =
>  			kmalloc_array(vops->pt_update_ops[i].num_ops,
>  				      sizeof(*vops->pt_update_ops[i].ops),
> -				      GFP_KERNEL);
> +				      GFP_KERNEL | __GFP_RETRY_MAYFAIL);
>  		if (!vops->pt_update_ops[i].ops)
>  			return array_of_binds ? -ENOBUFS : -ENOMEM;
>  	}
> @@ -2733,7 +2733,7 @@ static int vm_bind_ioctl_check_args(struct xe_device *xe,
>  
>  		*bind_ops = kvmalloc_array(args->num_binds,
>  					   sizeof(struct drm_xe_vm_bind_op),
> -					   GFP_KERNEL | __GFP_ACCOUNT);
> +					   GFP_KERNEL | __GFP_ACCOUNT | __GFP_RETRY_MAYFAIL);
>  		if (!*bind_ops)
>  			return args->num_binds > 1 ? -ENOBUFS : -ENOMEM;
>  
> @@ -2973,14 +2973,14 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
>  
>  	if (args->num_binds) {
>  		bos = kvcalloc(args->num_binds, sizeof(*bos),
> -			       GFP_KERNEL | __GFP_ACCOUNT);
> +			       GFP_KERNEL | __GFP_ACCOUNT | __GFP_RETRY_MAYFAIL);
>  		if (!bos) {
>  			err = -ENOMEM;
>  			goto release_vm_lock;
>  		}
>  
>  		ops = kvcalloc(args->num_binds, sizeof(*ops),
> -			       GFP_KERNEL | __GFP_ACCOUNT);
> +			       GFP_KERNEL | __GFP_ACCOUNT | __GFP_RETRY_MAYFAIL);
>  		if (!ops) {
>  			err = -ENOMEM;
>  			goto release_vm_lock;
> -- 
> 2.46.0
> 


More information about the Intel-xe mailing list