Since the fence info ioctl limits output data length to 4096 bytes, we
can just use a 4096-byte on-stack buffer for it (which is confirmed to
be safe via runtime stack usage measurements). This ioctl is used for
every frame rendered to the display, so eliminating dynamic memory
allocation overhead here improves frame rendering performance.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
static long sync_fence_ioctl_fence_info(struct sync_fence *fence,
unsigned long arg)
{
- struct sync_fence_info_data *data;
+ u8 data_buf[4096] __aligned(sizeof(long));
+ struct sync_fence_info_data *data = (typeof(data))data_buf;
__u32 size;
__u32 len = 0;
int ret, i;
if (size > 4096)
size = 4096;
- data = kzalloc(size, GFP_KERNEL);
- if (data == NULL)
- return -ENOMEM;
-
#ifdef CONFIG_SYNC_DEBUG
strlcpy(data->name, fence->name, sizeof(data->name));
#endif
ret = 0;
out:
- kfree(data);
return ret;
}