Commit 7658aeda authored by Yishai Hadas's avatar Yishai Hadas Committed by Alex Williamson

vfio/platform: Use GFP_KERNEL_ACCOUNT for userspace persistent allocations

Use GFP_KERNEL_ACCOUNT for userspace persistent allocations.

The GFP_KERNEL_ACCOUNT option lets the memory allocator know that this
is untrusted allocation triggered from userspace and should be a subject
of kmem accounting, and as such it is controlled by the cgroup
mechanism.
Signed-off-by: default avatarYishai Hadas <yishaih@nvidia.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20230108154427.32609-7-yishaih@nvidia.comSigned-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 4a6c971a
...@@ -142,7 +142,7 @@ static int vfio_platform_regions_init(struct vfio_platform_device *vdev) ...@@ -142,7 +142,7 @@ static int vfio_platform_regions_init(struct vfio_platform_device *vdev)
cnt++; cnt++;
vdev->regions = kcalloc(cnt, sizeof(struct vfio_platform_region), vdev->regions = kcalloc(cnt, sizeof(struct vfio_platform_region),
GFP_KERNEL); GFP_KERNEL_ACCOUNT);
if (!vdev->regions) if (!vdev->regions)
return -ENOMEM; return -ENOMEM;
......
...@@ -186,9 +186,8 @@ static int vfio_set_trigger(struct vfio_platform_device *vdev, int index, ...@@ -186,9 +186,8 @@ static int vfio_set_trigger(struct vfio_platform_device *vdev, int index,
if (fd < 0) /* Disable only */ if (fd < 0) /* Disable only */
return 0; return 0;
irq->name = kasprintf(GFP_KERNEL_ACCOUNT, "vfio-irq[%d](%s)",
irq->name = kasprintf(GFP_KERNEL, "vfio-irq[%d](%s)", irq->hwirq, vdev->name);
irq->hwirq, vdev->name);
if (!irq->name) if (!irq->name)
return -ENOMEM; return -ENOMEM;
...@@ -286,7 +285,8 @@ int vfio_platform_irq_init(struct vfio_platform_device *vdev) ...@@ -286,7 +285,8 @@ int vfio_platform_irq_init(struct vfio_platform_device *vdev)
while (vdev->get_irq(vdev, cnt) >= 0) while (vdev->get_irq(vdev, cnt) >= 0)
cnt++; cnt++;
vdev->irqs = kcalloc(cnt, sizeof(struct vfio_platform_irq), GFP_KERNEL); vdev->irqs = kcalloc(cnt, sizeof(struct vfio_platform_irq),
GFP_KERNEL_ACCOUNT);
if (!vdev->irqs) if (!vdev->irqs)
return -ENOMEM; return -ENOMEM;
......
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