Skip to content

Commit

Permalink
stm class: Use vmalloc for the master map
Browse files Browse the repository at this point in the history
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 torvalds#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: Fengguang Wu <[email protected]>
Signed-off-by: Alexander Shishkin <[email protected]>
CC: [email protected] # v4.4+
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
virtuoso authored and gregkh committed May 25, 2018
1 parent dd010bd commit b5e2ced
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/hwtracing/stm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ static void stm_device_release(struct 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,
Expand All @@ -691,7 +691,7 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
return -EINVAL;

nmasters = stm_data->sw_end - stm_data->sw_start + 1;
stm = kzalloc(sizeof(*stm) + nmasters * sizeof(void *), GFP_KERNEL);
stm = vzalloc(sizeof(*stm) + nmasters * sizeof(void *));
if (!stm)
return -ENOMEM;

Expand Down Expand Up @@ -744,7 +744,7 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
/* matches device_initialize() above */
put_device(&stm->dev);
err_free:
kfree(stm);
vfree(stm);

return err;
}
Expand Down

0 comments on commit b5e2ced

Please sign in to comment.