Commit 1e51592
IB/cm: Do not hold reference on cm_id unless needed
Typically, when the CM sends a MAD it bumps a reference count
on the associated cm_id. There are some exceptions, such
as when the MAD is a direct response to a receive MAD. For
example, the CM may generate an MRA in response to a duplicate
REQ. But, in general, if a MAD may be sent as a result of
the user invoking an API call (e.g. ib_send_cm_rep(),
ib_send_cm_rtu(), etc.), a reference is taken on the cm_id.
This reference is necessary if the MAD requires a response.
The reference allows routing a response MAD back to the
cm_id, or, if no response is received, allows updating the
cm_id state to reflect the failure.
For MADs which do not generate a response from the
target, however, there's no need to hold a reference on the cm_id.
Such MADs will not be retried by the MAD layer and their
completions do not change the state of the cm_id.
There are 2 internal calls used to allocate MADs which take
a reference on the cm_id: cm_alloc_msg() and cm_alloc_priv_msg().
The latter calls the former. It turns out that all other places
where cm_alloc_msg() is called are for MADs that do not generate
a response from the target: sending an RTU, DREP, REJ, MRA, or
SIDR REP. In all of these cases, there's no need to hold a
reference on the cm_id.
The benefit of dropping unneeded references is that it allows
destruction of the cm_id to proceed immediately. Currently,
the cm_destroy_id() call blocks as long as there's a reference
held on the cm_id. Worse, is that cm_destroy_id() will send
MADs, which it then needs to complete. Sending the MADs is
beneficial, as they notify the peer that a connection is
being destroyed. However, since the MADs hold a reference
on the cm_id, they block destruction and cannot be retried.
Move cm_id referencing from cm_alloc_msg() to cm_alloc_priv_msg().
The latter should hold a reference on the cm_id in all cases but
one, which will be handled in a separate patch. cm_alloc_priv_msg()
is used when sending a REQ, REP, DREQ, and SIDR REQ, all of which
require a response.
Also, merge common code into cm_alloc_priv_msg() and combine the
freeing of all messages which do not need a response.
Signed-off-by: Sean Hefty <[email protected]>
Signed-off-by: Or Har-Toov <[email protected]>
Signed-off-by: Vlad Dumitrescu <[email protected]>
Link: https://patch.msgid.link/1f0f96acace72790ecf89087fc765dead960189e.1731495873.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <[email protected]>1 parent 0492458 commit 1e51592
1 file changed
+24
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
313 | 312 | | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | 313 | | |
319 | 314 | | |
320 | 315 | | |
| |||
323 | 318 | | |
324 | 319 | | |
325 | 320 | | |
326 | | - | |
327 | | - | |
328 | 321 | | |
329 | 322 | | |
330 | | - | |
331 | 323 | | |
332 | 324 | | |
333 | 325 | | |
334 | 326 | | |
335 | | - | |
| 327 | + | |
336 | 328 | | |
337 | 329 | | |
338 | 330 | | |
| |||
341 | 333 | | |
342 | 334 | | |
343 | 335 | | |
| 336 | + | |
344 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | 416 | | |
424 | 417 | | |
425 | 418 | | |
| |||
1567 | 1560 | | |
1568 | 1561 | | |
1569 | 1562 | | |
1570 | | - | |
| 1563 | + | |
1571 | 1564 | | |
1572 | 1565 | | |
1573 | 1566 | | |
| |||
1576 | 1569 | | |
1577 | 1570 | | |
1578 | 1571 | | |
1579 | | - | |
1580 | | - | |
1581 | 1572 | | |
1582 | 1573 | | |
1583 | 1574 | | |
| |||
1634 | 1625 | | |
1635 | 1626 | | |
1636 | 1627 | | |
1637 | | - | |
| 1628 | + | |
1638 | 1629 | | |
1639 | 1630 | | |
1640 | 1631 | | |
| |||
1990 | 1981 | | |
1991 | 1982 | | |
1992 | 1983 | | |
1993 | | - | |
| 1984 | + | |
1994 | 1985 | | |
1995 | 1986 | | |
1996 | 1987 | | |
| |||
2304 | 2295 | | |
2305 | 2296 | | |
2306 | 2297 | | |
2307 | | - | |
| 2298 | + | |
2308 | 2299 | | |
2309 | 2300 | | |
2310 | 2301 | | |
2311 | 2302 | | |
2312 | 2303 | | |
2313 | 2304 | | |
2314 | 2305 | | |
2315 | | - | |
2316 | | - | |
2317 | 2306 | | |
2318 | 2307 | | |
2319 | 2308 | | |
| |||
2479 | 2468 | | |
2480 | 2469 | | |
2481 | 2470 | | |
2482 | | - | |
| 2471 | + | |
2483 | 2472 | | |
2484 | 2473 | | |
2485 | 2474 | | |
| |||
2683 | 2672 | | |
2684 | 2673 | | |
2685 | 2674 | | |
2686 | | - | |
| 2675 | + | |
2687 | 2676 | | |
2688 | 2677 | | |
2689 | 2678 | | |
2690 | 2679 | | |
2691 | 2680 | | |
2692 | 2681 | | |
2693 | 2682 | | |
2694 | | - | |
2695 | | - | |
2696 | 2683 | | |
2697 | 2684 | | |
2698 | 2685 | | |
| |||
2819 | 2806 | | |
2820 | 2807 | | |
2821 | 2808 | | |
2822 | | - | |
| 2809 | + | |
2823 | 2810 | | |
2824 | 2811 | | |
2825 | 2812 | | |
| |||
2878 | 2865 | | |
2879 | 2866 | | |
2880 | 2867 | | |
2881 | | - | |
| 2868 | + | |
2882 | 2869 | | |
2883 | 2870 | | |
2884 | 2871 | | |
| |||
3386 | 3373 | | |
3387 | 3374 | | |
3388 | 3375 | | |
3389 | | - | |
| 3376 | + | |
3390 | 3377 | | |
3391 | 3378 | | |
3392 | 3379 | | |
| |||
3525 | 3512 | | |
3526 | 3513 | | |
3527 | 3514 | | |
3528 | | - | |
| 3515 | + | |
3529 | 3516 | | |
3530 | 3517 | | |
3531 | 3518 | | |
3532 | 3519 | | |
3533 | 3520 | | |
3534 | 3521 | | |
3535 | 3522 | | |
3536 | | - | |
3537 | | - | |
3538 | 3523 | | |
3539 | 3524 | | |
3540 | 3525 | | |
| |||
3780 | 3765 | | |
3781 | 3766 | | |
3782 | 3767 | | |
3783 | | - | |
3784 | 3768 | | |
3785 | 3769 | | |
| 3770 | + | |
3786 | 3771 | | |
3787 | 3772 | | |
3788 | 3773 | | |
3789 | | - | |
| 3774 | + | |
3790 | 3775 | | |
3791 | 3776 | | |
3792 | 3777 | | |
3793 | | - | |
| 3778 | + | |
3794 | 3779 | | |
3795 | 3780 | | |
3796 | 3781 | | |
| |||
3839 | 3824 | | |
3840 | 3825 | | |
3841 | 3826 | | |
3842 | | - | |
3843 | | - | |
3844 | 3827 | | |
3845 | 3828 | | |
3846 | 3829 | | |
| |||
3861 | 3844 | | |
3862 | 3845 | | |
3863 | 3846 | | |
3864 | | - | |
3865 | | - | |
| 3847 | + | |
3866 | 3848 | | |
3867 | | - | |
| 3849 | + | |
3868 | 3850 | | |
3869 | 3851 | | |
3870 | 3852 | | |
| |||
0 commit comments