Commit b3f7931f authored by Juergen Gross's avatar Juergen Gross

xen/gntdev: switch from kcalloc() to kvcalloc()

With sufficient many pages to map gntdev can reach order 9 allocation
sizes. As there is no need to have physically contiguous buffers switch
to kvcalloc() in order to avoid failing allocations.
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Reviewed-by: default avatarOleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
parent 3b06ac67
...@@ -112,14 +112,14 @@ static void gntdev_free_map(struct gntdev_grant_map *map) ...@@ -112,14 +112,14 @@ static void gntdev_free_map(struct gntdev_grant_map *map)
gnttab_free_pages(map->count, map->pages); gnttab_free_pages(map->count, map->pages);
#ifdef CONFIG_XEN_GRANT_DMA_ALLOC #ifdef CONFIG_XEN_GRANT_DMA_ALLOC
kfree(map->frames); kvfree(map->frames);
#endif #endif
kfree(map->pages); kvfree(map->pages);
kfree(map->grants); kvfree(map->grants);
kfree(map->map_ops); kvfree(map->map_ops);
kfree(map->unmap_ops); kvfree(map->unmap_ops);
kfree(map->kmap_ops); kvfree(map->kmap_ops);
kfree(map->kunmap_ops); kvfree(map->kunmap_ops);
kfree(map); kfree(map);
} }
...@@ -133,12 +133,13 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count, ...@@ -133,12 +133,13 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
if (NULL == add) if (NULL == add)
return NULL; return NULL;
add->grants = kcalloc(count, sizeof(add->grants[0]), GFP_KERNEL); add->grants = kvcalloc(count, sizeof(add->grants[0]), GFP_KERNEL);
add->map_ops = kcalloc(count, sizeof(add->map_ops[0]), GFP_KERNEL); add->map_ops = kvcalloc(count, sizeof(add->map_ops[0]), GFP_KERNEL);
add->unmap_ops = kcalloc(count, sizeof(add->unmap_ops[0]), GFP_KERNEL); add->unmap_ops = kvcalloc(count, sizeof(add->unmap_ops[0]), GFP_KERNEL);
add->kmap_ops = kcalloc(count, sizeof(add->kmap_ops[0]), GFP_KERNEL); add->kmap_ops = kvcalloc(count, sizeof(add->kmap_ops[0]), GFP_KERNEL);
add->kunmap_ops = kcalloc(count, sizeof(add->kunmap_ops[0]), GFP_KERNEL); add->kunmap_ops = kvcalloc(count,
add->pages = kcalloc(count, sizeof(add->pages[0]), GFP_KERNEL); sizeof(add->kunmap_ops[0]), GFP_KERNEL);
add->pages = kvcalloc(count, sizeof(add->pages[0]), GFP_KERNEL);
if (NULL == add->grants || if (NULL == add->grants ||
NULL == add->map_ops || NULL == add->map_ops ||
NULL == add->unmap_ops || NULL == add->unmap_ops ||
...@@ -157,7 +158,7 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count, ...@@ -157,7 +158,7 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
if (dma_flags & (GNTDEV_DMA_FLAG_WC | GNTDEV_DMA_FLAG_COHERENT)) { if (dma_flags & (GNTDEV_DMA_FLAG_WC | GNTDEV_DMA_FLAG_COHERENT)) {
struct gnttab_dma_alloc_args args; struct gnttab_dma_alloc_args args;
add->frames = kcalloc(count, sizeof(add->frames[0]), add->frames = kvcalloc(count, sizeof(add->frames[0]),
GFP_KERNEL); GFP_KERNEL);
if (!add->frames) if (!add->frames)
goto err; goto err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment