Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

devlink: use kvzalloc() to allocate devlink instance resources

During live migration of a virtual machine, the SR-IOV VF need to be
re-registered. It may fail when the memory is badly fragmented.

The related log is as follows.

kernel: hv_netvsc 6045bdaa-c0d1-6045-bdaa-c0d16045bdaa eth0: VF slot 1 added
...
kernel: kworker/0:0: page allocation failure: order:7, mode:0x40dc0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null),cpuset=/,mems_allowed=0
kernel: CPU: 0 PID: 24006 Comm: kworker/0:0 Tainted: G E 5.4...x86_64 #1
kernel: Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS 090008 12/07/2018
kernel: Workqueue: events work_for_cpu_fn
kernel: Call Trace:
kernel: dump_stack+0x8b/0xc8
kernel: warn_alloc+0xff/0x170
kernel: __alloc_pages_slowpath+0x92c/0xb2b
kernel: ? get_page_from_freelist+0x1d4/0x1140
kernel: __alloc_pages_nodemask+0x2f9/0x320
kernel: alloc_pages_current+0x6a/0xb0
kernel: kmalloc_order+0x1e/0x70
kernel: kmalloc_order_trace+0x26/0xb0
kernel: ? __switch_to_asm+0x34/0x70
kernel: __kmalloc+0x276/0x280
kernel: ? _raw_spin_unlock_irqrestore+0x1e/0x40
kernel: devlink_alloc+0x29/0x110
kernel: mlx5_devlink_alloc+0x1a/0x20 [mlx5_core]
kernel: init_one+0x1d/0x650 [mlx5_core]
kernel: local_pci_probe+0x46/0x90
kernel: work_for_cpu_fn+0x1a/0x30
kernel: process_one_work+0x16d/0x390
kernel: worker_thread+0x1d3/0x3f0
kernel: kthread+0x105/0x140
kernel: ? max_active_store+0x80/0x80
kernel: ? kthread_bind+0x20/0x20
kernel: ret_from_fork+0x3a/0x50

Signed-off-by: Jian Wen <wenjian1@xiaomi.com>
Link: https://lore.kernel.org/r/20240327082128.942818-1-wenjian1@xiaomi.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Jian Wen and committed by
Jakub Kicinski
730fffce 45e0ba9c

+3 -3
+3 -3
net/devlink/core.c
··· 314 314 mutex_destroy(&devlink->lock); 315 315 lockdep_unregister_key(&devlink->lock_key); 316 316 put_device(devlink->dev); 317 - kfree(devlink); 317 + kvfree(devlink); 318 318 } 319 319 320 320 void devlink_put(struct devlink *devlink) ··· 420 420 if (!devlink_reload_actions_valid(ops)) 421 421 return NULL; 422 422 423 - devlink = kzalloc(sizeof(*devlink) + priv_size, GFP_KERNEL); 423 + devlink = kvzalloc(struct_size(devlink, priv, priv_size), GFP_KERNEL); 424 424 if (!devlink) 425 425 return NULL; 426 426 ··· 455 455 return devlink; 456 456 457 457 err_xa_alloc: 458 - kfree(devlink); 458 + kvfree(devlink); 459 459 return NULL; 460 460 } 461 461 EXPORT_SYMBOL_GPL(devlink_alloc_ns);