summaryrefslogtreecommitdiff
path: root/drivers/xen
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2021-03-10 13:46:13 +0300
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>2021-03-11 01:39:29 +0300
commitf1d20d8643e54dcde242fd2c8748063ed75702a8 (patch)
treed30db68e7e948fcdeeae5f0fb503654c2d504a81 /drivers/xen
parentbce21a2b48ede7cbcab92db18bc956daf1d5c246 (diff)
downloadlinux-f1d20d8643e54dcde242fd2c8748063ed75702a8.tar.xz
Xen/gntdev: don't needlessly use kvcalloc()
Requesting zeroed memory when all of it will be overwritten subsequently by all ones is a waste of processing bandwidth. In fact, rather than recording zeroed ->grants[], fill that array too with more appropriate "invalid" indicators. Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Juergen Gross <jgross@suse.com> Link: https://lore.kernel.org/r/9a726be2-4893-8ffe-0ef1-b70dd1c229b1@suse.com Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/gntdev.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index ebfd3e7b20d4..f01d58c7a042 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -133,9 +133,12 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
if (NULL == add)
return NULL;
- add->grants = kvcalloc(count, sizeof(add->grants[0]), GFP_KERNEL);
- add->map_ops = kvcalloc(count, sizeof(add->map_ops[0]), GFP_KERNEL);
- add->unmap_ops = kvcalloc(count, sizeof(add->unmap_ops[0]), GFP_KERNEL);
+ add->grants = kvmalloc_array(count, sizeof(add->grants[0]),
+ GFP_KERNEL);
+ add->map_ops = kvmalloc_array(count, sizeof(add->map_ops[0]),
+ GFP_KERNEL);
+ add->unmap_ops = kvmalloc_array(count, sizeof(add->unmap_ops[0]),
+ GFP_KERNEL);
add->pages = kvcalloc(count, sizeof(add->pages[0]), GFP_KERNEL);
if (NULL == add->grants ||
NULL == add->map_ops ||
@@ -143,10 +146,10 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
NULL == add->pages)
goto err;
if (use_ptemod) {
- add->kmap_ops = kvcalloc(count, sizeof(add->kmap_ops[0]),
- GFP_KERNEL);
- add->kunmap_ops = kvcalloc(count, sizeof(add->kunmap_ops[0]),
- GFP_KERNEL);
+ add->kmap_ops = kvmalloc_array(count, sizeof(add->kmap_ops[0]),
+ GFP_KERNEL);
+ add->kunmap_ops = kvmalloc_array(count, sizeof(add->kunmap_ops[0]),
+ GFP_KERNEL);
if (NULL == add->kmap_ops || NULL == add->kunmap_ops)
goto err;
}
@@ -186,6 +189,8 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
goto err;
for (i = 0; i < count; i++) {
+ add->grants[i].domid = DOMID_INVALID;
+ add->grants[i].ref = INVALID_GRANT_REF;
add->map_ops[i].handle = INVALID_GRANT_HANDLE;
add->unmap_ops[i].handle = INVALID_GRANT_HANDLE;
if (use_ptemod) {