When running qbv test of TSN feature in RT kernel, there is below call trace BUG: sleeping function called from invalid context at include/linux/sched/mm.h:229 in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 502, name: tsntool preempt_count: 0, expected: 0 RCU nest depth: 1, expected: 0 CPU: 0 PID: 502 Comm: tsntool Not tainted 5.15.65-rt48-yocto-preempt-rt #1 Hardware name: LS1028A RDB Board (DT) Call trace: dump_backtrace+0x0/0x1a0 ...... __might_resched+0x160/0x1c0 __might_sleep+0x58/0xb0 kmem_cache_alloc+0x260/0x310 __alloc_skb+0x1a8/0x1d0 tsn_event+0x58/0x230 atomic_notifier_call_chain+0x6c/0x9c call_tsn_notifiers+0x30/0x40 enetc_qbv_set+0x2e8/0x5fc cmd_qbv_set.isra.0+0x1d4/0x300 tsn_qbv_set+0x2c/0x44 ...... el0t_64_sync+0x1a0/0x1a4 So, replace GFP_KERNEL with GFP_ATOMIC to avoid sleeping in atomic context.
Signed-off-by: Meng Li <[email protected]> --- net/tsn/genl_tsn.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/tsn/genl_tsn.c b/net/tsn/genl_tsn.c index fdb2288394a3..4fca4a998af9 100644 --- a/net/tsn/genl_tsn.c +++ b/net/tsn/genl_tsn.c @@ -3506,7 +3506,7 @@ static int tsn_multicast_to_user(unsigned long event, int res = 0; /* If new attributes are added, please revisit this allocation */ - skb = genlmsg_new(sizeof(*tsn_info), GFP_KERNEL); + skb = genlmsg_new(sizeof(*tsn_info), GFP_ATOMIC); if (!skb) { pr_err("Allocation failure.\n"); return -ENOMEM; @@ -3514,7 +3514,7 @@ static int tsn_multicast_to_user(unsigned long event, switch (event) { case TSN_QBV_CONFIGCHANGETIME_ARRIVE: - nlh = genlmsg_put(skb, 0, 1, &tsn_family, 0, TSN_CMD_QBV_SET); + nlh = genlmsg_put(skb, 0, 1, &tsn_family, GFP_ATOMIC, TSN_CMD_QBV_SET); qbvdata = &tsn_info->ntdata.qbv_notify; res = NLA_PUT_U64(skb, TSN_QBV_ATTR_CTRL_BASETIME, qbvdata->admin.base_time); @@ -3561,7 +3561,7 @@ static int tsn_multicast_to_user(unsigned long event, (void)genlmsg_end(skb, nlh); res = genlmsg_multicast_allns(&tsn_family, skb, 0, - TSN_MCGRP_QBV, GFP_KERNEL); + TSN_MCGRP_QBV, GFP_ATOMIC); skb = NULL; if (res && res != -ESRCH) { pr_err("genlmsg_multicast_allns error: %d\n", res); -- 2.36.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#12441): https://lists.yoctoproject.org/g/linux-yocto/message/12441 Mute This Topic: https://lists.yoctoproject.org/mt/98555945/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
