Commit 1c15c791 authored by Alexander Shishkin's avatar Alexander Shishkin Committed by Stefan Bader

stm class: Use vmalloc for the master map

BugLink: https://bugs.launchpad.net/bugs/1776177

commit b5e2ced9 upstream.

Fengguang is running into a warning from the buddy allocator:

> swapper/0: page allocation failure: order:9, mode:0x14040c0(GFP_KERNEL|__GFP_COMP), nodemask=(null)
> CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.17.0-rc1 #262
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
> Call Trace:
...
>  __kmalloc+0x14b/0x180: ____cache_alloc at mm/slab.c:3127
>  stm_register_device+0xf3/0x5c0: stm_register_device at drivers/hwtracing/stm/core.c:695
...

Which is basically a result of the stm class trying to allocate ~512kB
for the dummy_stm with its default parameters. There's no reason, however,
for it not to be vmalloc()ed instead, which is what this patch does.
Reported-by: default avatarFengguang Wu <fengguang.wu@intel.com>
Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
CC: stable@vger.kernel.org # v4.4+
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent b6625a9c
...@@ -602,7 +602,7 @@ static void stm_device_release(struct device *dev) ...@@ -602,7 +602,7 @@ static void stm_device_release(struct device *dev)
{ {
struct stm_device *stm = to_stm_device(dev); struct stm_device *stm = to_stm_device(dev);
kfree(stm); vfree(stm);
} }
int stm_register_device(struct device *parent, struct stm_data *stm_data, int stm_register_device(struct device *parent, struct stm_data *stm_data,
...@@ -619,7 +619,7 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data, ...@@ -619,7 +619,7 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
return -EINVAL; return -EINVAL;
nmasters = stm_data->sw_end - stm_data->sw_start; nmasters = stm_data->sw_end - stm_data->sw_start;
stm = kzalloc(sizeof(*stm) + nmasters * sizeof(void *), GFP_KERNEL); stm = vzalloc(sizeof(*stm) + nmasters * sizeof(void *));
if (!stm) if (!stm)
return -ENOMEM; return -ENOMEM;
...@@ -656,7 +656,7 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data, ...@@ -656,7 +656,7 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
err_device: err_device:
put_device(&stm->dev); put_device(&stm->dev);
err_free: err_free:
kfree(stm); vfree(stm);
return err; return 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