* [PATCH] fsl/fman: avoid sleeping in atomic context while adding an address
@ 2018-03-04 18:48 Denis Kirjanov
2018-03-05 14:17 ` Madalin-cristian Bucur
2018-03-07 15:48 ` David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Denis Kirjanov @ 2018-03-04 18:48 UTC (permalink / raw)
To: madalin.bucur; +Cc: netdev, Denis Kirjanov
__dev_mc_add grabs an adress spinlock so use
atomic context in kmalloc.
/ # ifconfig eth0 inet 192.168.0.111
[ 89.331622] BUG: sleeping function called from invalid context at mm/slab.h:420
[ 89.339002] in_atomic(): 1, irqs_disabled(): 0, pid: 1035, name: ifconfig
[ 89.345799] 2 locks held by ifconfig/1035:
[ 89.349908] #0: (rtnl_mutex){+.+.}, at: [<(ptrval)>] devinet_ioctl+0xc0/0x8a0
[ 89.357258] #1: (_xmit_ETHER){+...}, at: [<(ptrval)>] __dev_mc_add+0x28/0x80
[ 89.364520] CPU: 1 PID: 1035 Comm: ifconfig Not tainted 4.16.0-rc3-dirty #8
[ 89.371464] Call Trace:
[ 89.373908] [e959db60] [c066f948] dump_stack+0xa4/0xfc (unreliable)
[ 89.380177] [e959db80] [c00671d8] ___might_sleep+0x248/0x280
[ 89.385833] [e959dba0] [c01aec34] kmem_cache_alloc_trace+0x174/0x320
[ 89.392179] [e959dbd0] [c04ab920] dtsec_add_hash_mac_address+0x130/0x240
[ 89.398874] [e959dc00] [c04a9d74] set_multi+0x174/0x1b0
[ 89.404093] [e959dc30] [c04afb68] dpaa_set_rx_mode+0x68/0xe0
[ 89.409745] [e959dc40] [c057baf8] __dev_mc_add+0x58/0x80
[ 89.415052] [e959dc60] [c060fd64] igmp_group_added+0x164/0x190
[ 89.420878] [e959dca0] [c060ffa8] ip_mc_inc_group+0x218/0x460
[ 89.426617] [e959dce0] [c06120fc] ip_mc_up+0x3c/0x190
[ 89.431662] [e959dd10] [c0607270] inetdev_event+0x250/0x620
[ 89.437227] [e959dd50] [c005f190] notifier_call_chain+0x80/0xf0
[ 89.443138] [e959dd80] [c0573a74] __dev_notify_flags+0x54/0xf0
[ 89.448964] [e959dda0] [c05743f8] dev_change_flags+0x48/0x60
[ 89.454615] [e959ddc0] [c0606744] devinet_ioctl+0x544/0x8a0
[ 89.460180] [e959de10] [c060987c] inet_ioctl+0x9c/0x1f0
[ 89.465400] [e959de80] [c05479a8] sock_ioctl+0x168/0x460
[ 89.470708] [e959ded0] [c01cf3ec] do_vfs_ioctl+0xac/0x8c0
[ 89.476099] [e959df20] [c01cfc40] SyS_ioctl+0x40/0xc0
[ 89.481147] [e959df40] [c0011318] ret_from_syscall+0x0/0x3c
[ 89.486715] --- interrupt: c01 at 0x1006943c
[ 89.486715] LR = 0x100c45ec
Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
---
drivers/net/ethernet/freescale/fman/fman_dtsec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index ea43b4974149..7af31ddd093f 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -1100,7 +1100,7 @@ int dtsec_add_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr)
set_bucket(dtsec->regs, bucket, true);
/* Create element to be added to the driver hash table */
- hash_entry = kmalloc(sizeof(*hash_entry), GFP_KERNEL);
+ hash_entry = kmalloc(sizeof(*hash_entry), GFP_ATOMIC);
if (!hash_entry)
return -ENOMEM;
hash_entry->addr = addr;
--
2.13.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [PATCH] fsl/fman: avoid sleeping in atomic context while adding an address
2018-03-04 18:48 [PATCH] fsl/fman: avoid sleeping in atomic context while adding an address Denis Kirjanov
@ 2018-03-05 14:17 ` Madalin-cristian Bucur
2018-03-07 15:48 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: Madalin-cristian Bucur @ 2018-03-05 14:17 UTC (permalink / raw)
To: Denis Kirjanov; +Cc: netdev@vger.kernel.org
> -----Original Message-----
> From: Denis Kirjanov [mailto:kda@linux-powerpc.org]
> Sent: Sunday, March 4, 2018 8:48 PM
> To: Madalin-cristian Bucur <madalin.bucur@nxp.com>
> Cc: netdev@vger.kernel.org; Denis Kirjanov <kda@linux-powerpc.org>
> Subject: [PATCH] fsl/fman: avoid sleeping in atomic context while adding an
> address
>
> __dev_mc_add grabs an adress spinlock so use
> atomic context in kmalloc.
>
> / # ifconfig eth0 inet 192.168.0.111
> [ 89.331622] BUG: sleeping function called from invalid context at
> mm/slab.h:420
> [ 89.339002] in_atomic(): 1, irqs_disabled(): 0, pid: 1035, name: ifconfig
> [ 89.345799] 2 locks held by ifconfig/1035:
> [ 89.349908] #0: (rtnl_mutex){+.+.}, at: [<(ptrval)>]
> devinet_ioctl+0xc0/0x8a0
> [ 89.357258] #1: (_xmit_ETHER){+...}, at: [<(ptrval)>]
> __dev_mc_add+0x28/0x80
> [ 89.364520] CPU: 1 PID: 1035 Comm: ifconfig Not tainted 4.16.0-rc3-dirty
> #8
> [ 89.371464] Call Trace:
> [ 89.373908] [e959db60] [c066f948] dump_stack+0xa4/0xfc (unreliable)
> [ 89.380177] [e959db80] [c00671d8] ___might_sleep+0x248/0x280
> [ 89.385833] [e959dba0] [c01aec34]
> kmem_cache_alloc_trace+0x174/0x320
> [ 89.392179] [e959dbd0] [c04ab920]
> dtsec_add_hash_mac_address+0x130/0x240
> [ 89.398874] [e959dc00] [c04a9d74] set_multi+0x174/0x1b0
> [ 89.404093] [e959dc30] [c04afb68] dpaa_set_rx_mode+0x68/0xe0
> [ 89.409745] [e959dc40] [c057baf8] __dev_mc_add+0x58/0x80
> [ 89.415052] [e959dc60] [c060fd64] igmp_group_added+0x164/0x190
> [ 89.420878] [e959dca0] [c060ffa8] ip_mc_inc_group+0x218/0x460
> [ 89.426617] [e959dce0] [c06120fc] ip_mc_up+0x3c/0x190
> [ 89.431662] [e959dd10] [c0607270] inetdev_event+0x250/0x620
> [ 89.437227] [e959dd50] [c005f190] notifier_call_chain+0x80/0xf0
> [ 89.443138] [e959dd80] [c0573a74] __dev_notify_flags+0x54/0xf0
> [ 89.448964] [e959dda0] [c05743f8] dev_change_flags+0x48/0x60
> [ 89.454615] [e959ddc0] [c0606744] devinet_ioctl+0x544/0x8a0
> [ 89.460180] [e959de10] [c060987c] inet_ioctl+0x9c/0x1f0
> [ 89.465400] [e959de80] [c05479a8] sock_ioctl+0x168/0x460
> [ 89.470708] [e959ded0] [c01cf3ec] do_vfs_ioctl+0xac/0x8c0
> [ 89.476099] [e959df20] [c01cfc40] SyS_ioctl+0x40/0xc0
> [ 89.481147] [e959df40] [c0011318] ret_from_syscall+0x0/0x3c
> [ 89.486715] --- interrupt: c01 at 0x1006943c
> [ 89.486715] LR = 0x100c45ec
>
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
> ---
> drivers/net/ethernet/freescale/fman/fman_dtsec.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> index ea43b4974149..7af31ddd093f 100644
> --- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> +++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> @@ -1100,7 +1100,7 @@ int dtsec_add_hash_mac_address(struct
> fman_mac *dtsec, enet_addr_t *eth_addr)
> set_bucket(dtsec->regs, bucket, true);
>
> /* Create element to be added to the driver hash table */
> - hash_entry = kmalloc(sizeof(*hash_entry), GFP_KERNEL);
> + hash_entry = kmalloc(sizeof(*hash_entry), GFP_ATOMIC);
> if (!hash_entry)
> return -ENOMEM;
> hash_entry->addr = addr;
> --
> 2.13.6
Acked-by: Madalin Bucur <madalin.bucur@nxp.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fsl/fman: avoid sleeping in atomic context while adding an address
2018-03-04 18:48 [PATCH] fsl/fman: avoid sleeping in atomic context while adding an address Denis Kirjanov
2018-03-05 14:17 ` Madalin-cristian Bucur
@ 2018-03-07 15:48 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2018-03-07 15:48 UTC (permalink / raw)
To: kda; +Cc: madalin.bucur, netdev
From: Denis Kirjanov <kda@linux-powerpc.org>
Date: Sun, 4 Mar 2018 21:48:17 +0300
> __dev_mc_add grabs an adress spinlock so use
> atomic context in kmalloc.
...
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
Applied, thank you.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] fsl/fman: avoid sleeping in atomic context while adding an address
@ 2019-01-04 5:50 Yi Wang
2019-01-04 12:52 ` Madalin-cristian Bucur
0 siblings, 1 reply; 5+ messages in thread
From: Yi Wang @ 2019-01-04 5:50 UTC (permalink / raw)
To: madalin.bucur
Cc: davem, netdev, linux-kernel, xue.zhihong, wang.yi59, huang.junhua,
Junhua Huang
From: Junhua Huang <huang.junhua@zte.com.cn>
dev_set_rx_mode will call function pointer mac_dev->add_hash_mac_addr
while holding spin_lock_bh. The function pointer points to
memac_add_hash_mac_address when ethernet type is fman-memac,
which will kmalloc use GFP_KERNEL flag.
/ # ifconfig eth2 192.168.1.168
[ 576.604544] BUG: sleeping function called from invalid context at mm/slab.h:393
[ 576.610587] in_atomic(): 1, irqs_disabled(): 0, pid: 2751, name: ifconfig
[ 576.616105] 2 locks held by ifconfig/2751:
[ 576.618916] #0:(rtnl_mutex)at: [<c00000000080ba60>] .rtnl_lock+0x1c/0x30
[ 576.625523] #1:(_xmit_ETHER)at: [<c0000000007f9430>] .dev_set_rx_mode+0x24/0x54
[ 576.632745] CPU: 5 PID: 2751 Comm: ifconfig Tainted: G W 4.9.115-rt93-EMBSYS-@332 #3
[ 576.642942] Call Trace:
[ 576.644085] [c00000007499b440] [c000000000a09eb4] .dump_stack+0xe0/0x14c (unreliable)
[ 576.650642] [c00000007499b4d0] [c000000000076f3c] .___might_sleep+0x1ac/0x278
[ 576.656493] [c00000007499b560] [c0000000001aad6c] .kmem_cache_alloc+0x144/0x28c
[ 576.662518] [c00000007499b620] [c000000000634c18] .memac_add_hash_mac_address+0x100/0x194
[ 576.669416] [c00000007499b6b0] [c000000000630b54] .set_multi+0x1bc/0x20c
[ 576.674829] [c00000007499b760] [c00000000063718c] .dpaa_set_rx_mode+0x84/0x104
[ 576.680765] [c00000007499b7e0] [c0000000007f9394] .__dev_set_rx_mode+0x64/0xdc
[ 576.686701] [c00000007499b870] [c0000000007f943c] .dev_set_rx_mode+0x30/0x54
[ 576.692464] [c00000007499b8f0] [c0000000007f98f4] .__dev_change_flags+0x98/0x1c4
[ 576.698573] [c00000007499b980] [c0000000007f9a4c] .dev_change_flags+0x2c/0x80
[ 576.704429] [c00000007499ba10] [c0000000008cde28] .devinet_ioctl+0x624/0x8e0
[ 576.710191] [c00000007499bb00] [c0000000008d1678] .inet_ioctl+0x1f4/0x250
[ 576.715697] [c00000007499bb70] [c0000000007c89d8] .sock_do_ioctl+0x50/0xa8
[ 576.721284] [c00000007499bc00] [c0000000007c94e8] .sock_ioctl+0x2b8/0x39c
[ 576.726786] [c00000007499bca0] [c0000000001e2500] .do_vfs_ioctl+0xc8/0x8b4
[ 576.732373] [c00000007499bd90] [c0000000001e2d44] .SyS_ioctl+0x58/0xa4
[ 576.737612] [c00000007499be30] [c0000000000007a4] system_call+0x38/0x108
Signed-off-by: Junhua Huang <huangjunhua@zte.com.cn>
---
drivers/net/ethernet/freescale/fman/fman_memac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c
index 71a5ded..21dd557 100644
--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
+++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
@@ -923,7 +923,7 @@ int memac_add_hash_mac_address(struct fman_mac *memac, enet_addr_t *eth_addr)
hash = get_mac_addr_hash_code(addr) & HASH_CTRL_ADDR_MASK;
/* Create element to be added to the driver hash table */
- hash_entry = kmalloc(sizeof(*hash_entry), GFP_KERNEL);
+ hash_entry = kmalloc(sizeof(*hash_entry), GFP_ATOMIC);
if (!hash_entry)
return -ENOMEM;
hash_entry->addr = addr;
--
2.15.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [PATCH] fsl/fman: avoid sleeping in atomic context while adding an address
2019-01-04 5:50 Yi Wang
@ 2019-01-04 12:52 ` Madalin-cristian Bucur
0 siblings, 0 replies; 5+ messages in thread
From: Madalin-cristian Bucur @ 2019-01-04 12:52 UTC (permalink / raw)
To: Yi Wang
Cc: davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, xue.zhihong@zte.com.cn,
huang.junhua@zte.com.cn, Junhua Huang
Hi,
this is a duplicate of this other patch addressing the issue:
commit 0d9c9a238faf925823bde866182c663b6d734f2e
Author: Scott Wood <oss@buserror.net>
Date: Thu Dec 27 18:29:09 2018 -0600
fsl/fman: Use GFP_ATOMIC in {memac,tgec}_add_hash_mac_address()
Thank you,
Madalin
> -----Original Message-----
> From: Yi Wang <wang.yi59@zte.com.cn>
> Sent: Friday, January 4, 2019 7:50 AM
> To: Madalin-cristian Bucur <madalin.bucur@nxp.com>
> Cc: davem@davemloft.net; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; xue.zhihong@zte.com.cn; wang.yi59@zte.com.cn;
> huang.junhua@zte.com.cn; Junhua Huang <huangjunhua@zte.com.cn>
> Subject: [PATCH] fsl/fman: avoid sleeping in atomic context while adding
> an address
>
> From: Junhua Huang <huang.junhua@zte.com.cn>
>
> dev_set_rx_mode will call function pointer mac_dev->add_hash_mac_addr
> while holding spin_lock_bh. The function pointer points to
> memac_add_hash_mac_address when ethernet type is fman-memac,
> which will kmalloc use GFP_KERNEL flag.
>
> / # ifconfig eth2 192.168.1.168
> [ 576.604544] BUG: sleeping function called from invalid context at
> mm/slab.h:393
> [ 576.610587] in_atomic(): 1, irqs_disabled(): 0, pid: 2751, name:
> ifconfig
> [ 576.616105] 2 locks held by ifconfig/2751:
> [ 576.618916] #0:(rtnl_mutex)at: [<c00000000080ba60>]
> .rtnl_lock+0x1c/0x30
> [ 576.625523] #1:(_xmit_ETHER)at: [<c0000000007f9430>]
> .dev_set_rx_mode+0x24/0x54
> [ 576.632745] CPU: 5 PID: 2751 Comm: ifconfig Tainted: G W 4.9.115-
> rt93-EMBSYS-@332 #3
> [ 576.642942] Call Trace:
> [ 576.644085] [c00000007499b440] [c000000000a09eb4]
> .dump_stack+0xe0/0x14c (unreliable)
> [ 576.650642] [c00000007499b4d0] [c000000000076f3c]
> .___might_sleep+0x1ac/0x278
> [ 576.656493] [c00000007499b560] [c0000000001aad6c]
> .kmem_cache_alloc+0x144/0x28c
> [ 576.662518] [c00000007499b620] [c000000000634c18]
> .memac_add_hash_mac_address+0x100/0x194
> [ 576.669416] [c00000007499b6b0] [c000000000630b54]
> .set_multi+0x1bc/0x20c
> [ 576.674829] [c00000007499b760] [c00000000063718c]
> .dpaa_set_rx_mode+0x84/0x104
> [ 576.680765] [c00000007499b7e0] [c0000000007f9394]
> .__dev_set_rx_mode+0x64/0xdc
> [ 576.686701] [c00000007499b870] [c0000000007f943c]
> .dev_set_rx_mode+0x30/0x54
> [ 576.692464] [c00000007499b8f0] [c0000000007f98f4]
> .__dev_change_flags+0x98/0x1c4
> [ 576.698573] [c00000007499b980] [c0000000007f9a4c]
> .dev_change_flags+0x2c/0x80
> [ 576.704429] [c00000007499ba10] [c0000000008cde28]
> .devinet_ioctl+0x624/0x8e0
> [ 576.710191] [c00000007499bb00] [c0000000008d1678]
> .inet_ioctl+0x1f4/0x250
> [ 576.715697] [c00000007499bb70] [c0000000007c89d8]
> .sock_do_ioctl+0x50/0xa8
> [ 576.721284] [c00000007499bc00] [c0000000007c94e8]
> .sock_ioctl+0x2b8/0x39c
> [ 576.726786] [c00000007499bca0] [c0000000001e2500]
> .do_vfs_ioctl+0xc8/0x8b4
> [ 576.732373] [c00000007499bd90] [c0000000001e2d44] .SyS_ioctl+0x58/0xa4
> [ 576.737612] [c00000007499be30] [c0000000000007a4]
> system_call+0x38/0x108
>
> Signed-off-by: Junhua Huang <huangjunhua@zte.com.cn>
> ---
> drivers/net/ethernet/freescale/fman/fman_memac.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c
> b/drivers/net/ethernet/freescale/fman/fman_memac.c
> index 71a5ded..21dd557 100644
> --- a/drivers/net/ethernet/freescale/fman/fman_memac.c
> +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
> @@ -923,7 +923,7 @@ int memac_add_hash_mac_address(struct fman_mac *memac,
> enet_addr_t *eth_addr)
> hash = get_mac_addr_hash_code(addr) & HASH_CTRL_ADDR_MASK;
>
> /* Create element to be added to the driver hash table */
> - hash_entry = kmalloc(sizeof(*hash_entry), GFP_KERNEL);
> + hash_entry = kmalloc(sizeof(*hash_entry), GFP_ATOMIC);
> if (!hash_entry)
> return -ENOMEM;
> hash_entry->addr = addr;
> --
> 2.15.2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-04 12:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-04 18:48 [PATCH] fsl/fman: avoid sleeping in atomic context while adding an address Denis Kirjanov
2018-03-05 14:17 ` Madalin-cristian Bucur
2018-03-07 15:48 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2019-01-04 5:50 Yi Wang
2019-01-04 12:52 ` Madalin-cristian Bucur
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).