Re: [PATCH] regset: use vmalloc() for regset_get_alloc()

From: Matthew Wilcox
Date: Thu Feb 01 2024 - 20:25:03 EST


On Thu, Feb 01, 2024 at 05:12:03PM -0800, Douglas Anderson wrote:
> While browsing through ChromeOS crash reports, I found one with an
> allocation failure that looked like this:
>
> chrome: page allocation failure: order:7,
> mode:0x40dc0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO),
> nodemask=(null),cpuset=urgent,mems_allowed=0

That does seem bad ...

> @@ -16,14 +17,14 @@ static int __regset_get(struct task_struct *target,
> if (size > regset->n * regset->size)
> size = regset->n * regset->size;
> if (!p) {
> - to_free = p = kzalloc(size, GFP_KERNEL);
> + to_free = p = vmalloc(size);

It's my impression that sometimes this size might be relatively small?
Perhaps we should make this kvmalloc so that we can satisfy it from the
slab allocator if it is small?

Also, I assume that we don't rely on this memory being physically
contiguous; we don't, for example, do I/O on it?