Skip to content

Commit 8ead139

Browse files
zhuyjgregkh
authored andcommitted
RDMA/rxe: Flush delayed SKBs while releasing RXE resources
commit 3c3e9a9 upstream. When skb packets are sent out, these skb packets still depends on the rxe resources, for example, QP, sk, when these packets are destroyed. If these rxe resources are released when the skb packets are destroyed, the call traces will appear. To avoid skb packets hang too long time in some network devices, a timestamp is added when these skb packets are created. If these skb packets hang too long time in network devices, these network devices can free these skb packets to release rxe resources. Reported-by: syzbot+8425ccfb599521edb153@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=8425ccfb599521edb153 Tested-by: syzbot+8425ccfb599521edb153@syzkaller.appspotmail.com Fixes: 1a633bd ("RDMA/rxe: Let destroy qp succeed with stuck packet") Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev> Link: https://patch.msgid.link/20250726013104.463570-1-yanjun.zhu@linux.dev Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e7ea470 commit 8ead139

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

drivers/infiniband/sw/rxe/rxe_net.c

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -345,33 +345,15 @@ int rxe_prepare(struct rxe_av *av, struct rxe_pkt_info *pkt,
345345

346346
static void rxe_skb_tx_dtor(struct sk_buff *skb)
347347
{
348-
struct net_device *ndev = skb->dev;
349-
struct rxe_dev *rxe;
350-
unsigned int qp_index;
351-
struct rxe_qp *qp;
348+
struct rxe_qp *qp = skb->sk->sk_user_data;
352349
int skb_out;
353350

354-
rxe = rxe_get_dev_from_net(ndev);
355-
if (!rxe && is_vlan_dev(ndev))
356-
rxe = rxe_get_dev_from_net(vlan_dev_real_dev(ndev));
357-
if (WARN_ON(!rxe))
358-
return;
359-
360-
qp_index = (int)(uintptr_t)skb->sk->sk_user_data;
361-
if (!qp_index)
362-
return;
363-
364-
qp = rxe_pool_get_index(&rxe->qp_pool, qp_index);
365-
if (!qp)
366-
goto put_dev;
367-
368351
skb_out = atomic_dec_return(&qp->skb_out);
369-
if (qp->need_req_skb && skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW)
352+
if (unlikely(qp->need_req_skb &&
353+
skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW))
370354
rxe_sched_task(&qp->send_task);
371355

372356
rxe_put(qp);
373-
put_dev:
374-
ib_device_put(&rxe->ib_dev);
375357
sock_put(skb->sk);
376358
}
377359

@@ -383,6 +365,7 @@ static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt)
383365
sock_hold(sk);
384366
skb->sk = sk;
385367
skb->destructor = rxe_skb_tx_dtor;
368+
rxe_get(pkt->qp);
386369
atomic_inc(&pkt->qp->skb_out);
387370

388371
if (skb->protocol == htons(ETH_P_IP))
@@ -405,6 +388,7 @@ static int rxe_loopback(struct sk_buff *skb, struct rxe_pkt_info *pkt)
405388
sock_hold(sk);
406389
skb->sk = sk;
407390
skb->destructor = rxe_skb_tx_dtor;
391+
rxe_get(pkt->qp);
408392
atomic_inc(&pkt->qp->skb_out);
409393

410394
if (skb->protocol == htons(ETH_P_IP))
@@ -497,6 +481,9 @@ struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av,
497481
goto out;
498482
}
499483

484+
/* Add time stamp to skb. */
485+
skb->tstamp = ktime_get();
486+
500487
skb_reserve(skb, hdr_len + LL_RESERVED_SPACE(ndev));
501488

502489
/* FIXME: hold reference to this netdev until life of this skb. */

drivers/infiniband/sw/rxe/rxe_qp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp,
244244
err = sock_create_kern(&init_net, AF_INET, SOCK_DGRAM, 0, &qp->sk);
245245
if (err < 0)
246246
return err;
247-
qp->sk->sk->sk_user_data = (void *)(uintptr_t)qp->elem.index;
247+
qp->sk->sk->sk_user_data = qp;
248248

249249
/* pick a source UDP port number for this QP based on
250250
* the source QPN. this spreads traffic for different QPs

0 commit comments

Comments
 (0)