From: Kyle Fortin Date: Wed, 17 May 2017 20:21:54 +0000 (-0400) Subject: scsi: libiscsi: use kvzalloc for iscsi_pool_init X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=bfcc62ed7066268349e8e7955925bdaf4be0eec0;p=openwrt%2Fstaging%2Fblogic.git scsi: libiscsi: use kvzalloc for iscsi_pool_init iscsiadm session login can fail with the following error: iscsiadm: Could not login to [iface: default, target: iqn.1986-03.com... iscsiadm: initiator reported error (9 - internal error) When /etc/iscsi/iscsid.conf sets node.session.cmds_max = 4096, it results in 64K-sized kmallocs per session. A system under fragmented slab pressure may not have any 64K objects available and fail iscsiadm session login. Even though memory objects of a smaller size are available, the large order allocation ends up failing. The kernel prints a warning and does dump_stack, like below: iscsid: page allocation failure: order:4, mode:0xc0d0 CPU: 0 PID: 2456 Comm: iscsid Not tainted 4.1.12-61.1.28.el6uek.x86_64 #2 Call Trace: [] dump_stack+0x63/0x83 [] warn_alloc_failed+0xea/0x140 [] __alloc_pages_slowpath+0x409/0x760 [] __alloc_pages_nodemask+0x2b1/0x2d0 [] ? dev_attr_host_ipaddress+0x20/0xffffffffffffc722 [] alloc_pages_current+0xaf/0x170 [] alloc_kmem_pages+0x31/0xd0 [] ? iscsi_transport_group+0x20/0xffffffffffffc7e2 [] kmalloc_order+0x18/0x50 [] kmalloc_order_trace+0x34/0xe0 [] ? transport_remove_classdev+0x70/0x70 [] __kmalloc+0x27d/0x2a0 [] ? complete_all+0x4d/0x60 [] iscsi_pool_init+0x69/0x160 [libiscsi] [] ? device_initialize+0xb0/0xd0 [] iscsi_session_setup+0x180/0x2f4 [libiscsi] [] ? iscsi_max_lun+0x20/0xfffffffffffffa9e [iscsi_tcp] [] iscsi_sw_tcp_session_create+0xcf/0x150 [iscsi_tcp] [] ? iscsi_max_lun+0x20/0xfffffffffffffa9e [iscsi_tcp] [] iscsi_if_create_session+0x33/0xd0 [] ? iscsi_max_lun+0x20/0xfffffffffffffa9e [iscsi_tcp] [] iscsi_if_recv_msg+0x508/0x8c0 [scsi_transport_iscsi] [] ? __alloc_pages_nodemask+0x19b/0x2d0 [] ? __kmalloc_node_track_caller+0x209/0x2c0 [] iscsi_if_rx+0x7c/0x200 [scsi_transport_iscsi] [] netlink_unicast+0x126/0x1c0 [] netlink_sendmsg+0x36c/0x400 [] sock_sendmsg+0x4d/0x60 [] ___sys_sendmsg+0x30a/0x330 [] ? handle_pte_fault+0x20c/0x230 [] ? __handle_mm_fault+0x1bc/0x330 [] ? handle_mm_fault+0xb2/0x1a0 [] __sys_sendmsg+0x49/0x90 [] SyS_sendmsg+0x19/0x20 [] system_call_fastpath+0x12/0x71 Use kvzalloc for iscsi_pool in iscsi_pool_init. Signed-off-by: Kyle Fortin Tested-by: Kyle Fortin Reviewed-by: Joseph Slember Reviewed-by: Lance Hartmann Acked-by: Lee Duncan Signed-off-by: Martin K. Petersen --- diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index dd6828f7f772..42381adf0769 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -2556,7 +2556,7 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size) * the array. */ if (items) num_arrays++; - q->pool = kzalloc(num_arrays * max * sizeof(void*), GFP_KERNEL); + q->pool = kvzalloc(num_arrays * max * sizeof(void*), GFP_KERNEL); if (q->pool == NULL) return -ENOMEM; @@ -2590,7 +2590,7 @@ void iscsi_pool_free(struct iscsi_pool *q) for (i = 0; i < q->max; i++) kfree(q->pool[i]); - kfree(q->pool); + kvfree(q->pool); } EXPORT_SYMBOL_GPL(iscsi_pool_free);