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>

authored by Jan Beulich and committed by Boris Ostrovsky f1d20d86 bce21a2b

+12 -7
+12 -7
drivers/xen/gntdev.c
··· 133 if (NULL == add) 134 return NULL; 135 136 - add->grants = kvcalloc(count, sizeof(add->grants[0]), GFP_KERNEL); 137 - add->map_ops = kvcalloc(count, sizeof(add->map_ops[0]), GFP_KERNEL); 138 - add->unmap_ops = kvcalloc(count, sizeof(add->unmap_ops[0]), GFP_KERNEL); 139 add->pages = kvcalloc(count, sizeof(add->pages[0]), GFP_KERNEL); 140 if (NULL == add->grants || 141 NULL == add->map_ops || ··· 146 NULL == add->pages) 147 goto err; 148 if (use_ptemod) { 149 - add->kmap_ops = kvcalloc(count, sizeof(add->kmap_ops[0]), 150 - GFP_KERNEL); 151 - add->kunmap_ops = kvcalloc(count, sizeof(add->kunmap_ops[0]), 152 - GFP_KERNEL); 153 if (NULL == add->kmap_ops || NULL == add->kunmap_ops) 154 goto err; 155 } ··· 189 goto err; 190 191 for (i = 0; i < count; i++) { 192 add->map_ops[i].handle = INVALID_GRANT_HANDLE; 193 add->unmap_ops[i].handle = INVALID_GRANT_HANDLE; 194 if (use_ptemod) {
··· 133 if (NULL == add) 134 return NULL; 135 136 + add->grants = kvmalloc_array(count, sizeof(add->grants[0]), 137 + GFP_KERNEL); 138 + add->map_ops = kvmalloc_array(count, sizeof(add->map_ops[0]), 139 + GFP_KERNEL); 140 + add->unmap_ops = kvmalloc_array(count, sizeof(add->unmap_ops[0]), 141 + GFP_KERNEL); 142 add->pages = kvcalloc(count, sizeof(add->pages[0]), GFP_KERNEL); 143 if (NULL == add->grants || 144 NULL == add->map_ops || ··· 143 NULL == add->pages) 144 goto err; 145 if (use_ptemod) { 146 + add->kmap_ops = kvmalloc_array(count, sizeof(add->kmap_ops[0]), 147 + GFP_KERNEL); 148 + add->kunmap_ops = kvmalloc_array(count, sizeof(add->kunmap_ops[0]), 149 + GFP_KERNEL); 150 if (NULL == add->kmap_ops || NULL == add->kunmap_ops) 151 goto err; 152 } ··· 186 goto err; 187 188 for (i = 0; i < count; i++) { 189 + add->grants[i].domid = DOMID_INVALID; 190 + add->grants[i].ref = INVALID_GRANT_REF; 191 add->map_ops[i].handle = INVALID_GRANT_HANDLE; 192 add->unmap_ops[i].handle = INVALID_GRANT_HANDLE; 193 if (use_ptemod) {