From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Matthew Brost <matthew.brost@intel.com>, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/xe: Use vmalloc for array of bind allocation in bind IOCTL
Date: Mon, 26 Feb 2024 17:01:16 +0100 [thread overview]
Message-ID: <1e8e5848b26b5a44941ab449afc20476aa35bc55.camel@linux.intel.com> (raw)
In-Reply-To: <20240226155554.103384-1-matthew.brost@intel.com>
On Mon, 2024-02-26 at 07:55 -0800, Matthew Brost wrote:
> Use vmalloc in effort to allow a user pass in a large number of binds
> in
> an IOCTL (mesa use case). Also use array allocations rather open
> coding
> the size calculation.
>
> v2: Use __GFP_ACCOUNT for allocations (Thomas)
>
> Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel
> GPUs")
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---
> drivers/gpu/drm/xe/xe_vm.c | 25 ++++++++++++++-----------
> 1 file changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index db3f049a47dc..4154ef75e369 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -2770,8 +2770,9 @@ static int vm_bind_ioctl_check_args(struct
> xe_device *xe,
> u64 __user *bind_user =
> u64_to_user_ptr(args->vector_of_binds);
>
> - *bind_ops = kmalloc(sizeof(struct drm_xe_vm_bind_op)
> *
> - args->num_binds, GFP_KERNEL);
> + *bind_ops = kvmalloc_array(args->num_binds,
> + sizeof(struct
> drm_xe_vm_bind_op),
> + GFP_KERNEL |
> __GFP_ACCOUNT);
> if (!*bind_ops)
> return -ENOMEM;
>
> @@ -2861,7 +2862,7 @@ static int vm_bind_ioctl_check_args(struct
> xe_device *xe,
>
> free_bind_ops:
> if (args->num_binds > 1)
> - kfree(*bind_ops);
> + kvfree(*bind_ops);
> return err;
> }
>
> @@ -2949,13 +2950,15 @@ int xe_vm_bind_ioctl(struct drm_device *dev,
> void *data, struct drm_file *file)
> }
>
> if (args->num_binds) {
> - bos = kcalloc(args->num_binds, sizeof(*bos),
> GFP_KERNEL);
> + bos = kvcalloc(args->num_binds, sizeof(*bos),
> + GFP_KERNEL | __GFP_ACCOUNT);
> if (!bos) {
> err = -ENOMEM;
> goto release_vm_lock;
> }
>
> - ops = kcalloc(args->num_binds, sizeof(*ops),
> GFP_KERNEL);
> + ops = kvcalloc(args->num_binds, sizeof(*ops),
> + GFP_KERNEL | __GFP_ACCOUNT);
> if (!ops) {
> err = -ENOMEM;
> goto release_vm_lock;
> @@ -3096,10 +3099,10 @@ int xe_vm_bind_ioctl(struct drm_device *dev,
> void *data, struct drm_file *file)
> for (i = 0; bos && i < args->num_binds; ++i)
> xe_bo_put(bos[i]);
>
> - kfree(bos);
> - kfree(ops);
> + kvfree(bos);
> + kvfree(ops);
> if (args->num_binds > 1)
> - kfree(bind_ops);
> + kvfree(bind_ops);
>
> return err;
>
> @@ -3123,10 +3126,10 @@ int xe_vm_bind_ioctl(struct drm_device *dev,
> void *data, struct drm_file *file)
> if (q)
> xe_exec_queue_put(q);
> free_objs:
> - kfree(bos);
> - kfree(ops);
> + kvfree(bos);
> + kvfree(ops);
> if (args->num_binds > 1)
> - kfree(bind_ops);
> + kvfree(bind_ops);
> return err;
> }
>
next prev parent reply other threads:[~2024-02-26 16:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-26 15:55 [PATCH v2] drm/xe: Use vmalloc for array of bind allocation in bind IOCTL Matthew Brost
2024-02-26 16:01 ` Thomas Hellström [this message]
2024-02-26 16:02 ` ✓ CI.Patch_applied: success for drm/xe: Use vmalloc for array of bind allocation in bind IOCTL (rev2) Patchwork
2024-02-26 16:02 ` ✓ CI.checkpatch: " Patchwork
2024-02-26 16:03 ` ✓ CI.KUnit: " Patchwork
2024-02-26 16:13 ` ✓ CI.Build: " Patchwork
2024-02-26 16:14 ` ✓ CI.Hooks: " Patchwork
2024-02-26 16:16 ` ✓ CI.checksparse: " Patchwork
2024-02-26 16:40 ` ✓ CI.BAT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1e8e5848b26b5a44941ab449afc20476aa35bc55.camel@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox