)]}'
{
  "commit": "32252168aff53ec52978ebcd3d403ce9976210ff",
  "tree": "8a2937de576bc546276bfdf4fa4305612c1e6c46",
  "parents": [
    "9f000d1250559656c5cc72035693792659f5b7c0"
  ],
  "author": {
    "name": "Sharath Srinivasan",
    "email": "sharath.srinivasan@oracle.com",
    "time": "Thu Nov 12 21:43:50 2026 -0700"
  },
  "committer": {
    "name": "Jakub Kicinski",
    "email": "kuba@kernel.org",
    "time": "Tue Nov 17 17:52:26 2026 -0800"
  },
  "message": "net/rds: wait for connections to be freed on transport unload\n\nSince connection free became asynchronous, rds_conn_destroy() only\nquiesces the connection; the actual free - including the transport\u0027s\nconn_free, which lives in the transport module - runs when the last\nreference is dropped.  The transports\u0027 exit paths destroy all of\ntheir connections and then proceed to unload, so a free that is still\npending - once the following patches hand out references to lookups,\nsockets and incs - would execute transport module code after that\nmodule\u0027s text is gone.  At this point in the series the initial\nreference is the only one, so the wait only has work to do for IB,\nwhere it also catches the late arrivals described below; the\nguarantee becomes load-bearing with those patches.\n\nCount each transport\u0027s live connections in t_conn_count (incremented\nwhen a connection is published in __rds_conn_create(), decremented as\nthe last step of rds_conn_destroy_fini()) and make the transport exit\npaths - rds_ib_exit(), rds_tcp_exit() and rds_loop_exit() - wait for\nthe count to drop to zero after destroying their connections.\n\nA bound socket holds a module reference on its own transport\n(rds_trans_get_preferred()), but that does not bound the wait: once\nthe following patches make incs hold a connection reference, an\nunread datagram pins its connection for as long as the application\nleaves it on the receive queue, and rds_find_bound() does not filter\non transport, so that socket may well belong to a different transport\nthan the connection and pin nothing that stops this unload.\nProceeding after a timeout would turn a leak into a use-after-free in\nthis module\u0027s text, so the wait is unbounded: it polls the count,\nwarns every ten seconds naming the transport and the number of\nconnections outstanding, and returns only when the count reaches\nzero.  rmmod therefore blocks while data is queued and unread, which\nis the historical RDS contract - teardown does not discard queued\ndata.\nThe wait is deliberately not interruptible: the exit function has\nalready passed the point of no return, and a killed rmmod would leave\nthe module half torn down and unloadable, which is worse than a\nblocked one.  The polling wakes every 100 ms, so the hung task detector\ndoes not fire.\n\nThe wake at the end of rds_conn_destroy_fini() can run from a thread\nexecuting transport module text, but never as that thread\u0027s last use\nof it: the CM event handler\u0027s reference (added later in the series) is\nalways dropped before the rdma_destroy_id() in the connection\u0027s own\nshutdown returns, and rds_rdma_exit() stops the listener - waiting for\nany handler running on it - before rds_ib_exit() starts to wait.\n\nrds_ib_exit() has one more wrinkle, and an existing hole.\nrds_ib_dev_shutdown() only drops the connections still attached to a\ndevice, and each of them moves itself to ib_nodev_conns from its own\nshutdown work, asynchronously; the flush_workqueue(rds_wq) in\nrds_ib_unregister_client() does not wait for those per-connection\nworkqueues.  A connection that had not migrated by the time\nrds_ib_destroy_nodev_conns() made its single sweep was never\ndestroyed: it outlived the module, still pointing at\nrds_ib_transport.  With the count, it would hold the count up for\ngood instead.  So the wait takes a resweep callback, which\nrds_ib_exit() points at rds_ib_destroy_nodev_conns(): late arrivals\nget destroyed on the next poll instead of being waited on.  The sweep\nclaims and unlinks every node it gathers (see the previous patch), so\na resweep never hands a connection to rds_conn_destroy() twice.\n\nIn rds_ib_exit(), tearing down the last connection can also drop the\nfinal reference on a device, which defers rds_ib_dev_free() - again\nthis module\u0027s text - to rds_wq.  The flush of rds_wq that the device\ngate patch added after the sweep moves after the wait, so that it\ncovers the connections the resweep destroys as well; rds_ib_dev_free()\nqueues nothing further on rds_wq, so a single pass drains it.\n\nBased on the Oracle UEK commits \"net/rds: wait_event_timeout\nuntil zero connections during rmmod\" and \"net/rds:\nEach RDS transport should keep its own connection count\".\n\nFixes: 4716af3897e9 (\"net/rds: Give each connection path its own workqueue\")\nCc: \u003cstable+noautosel@kernel.org\u003e # depends on the connection reference counting earlier in this series\nSigned-off-by: Sharath Srinivasan \u003csharath.srinivasan@oracle.com\u003e\n[achender: reimplementation for net-next: t_conn_count did not exist\n upstream and is introduced here; single global waitqueue instead of\n per-transport (the loop transport never goes through\n rds_trans_register()); unbounded wait with a periodic warning in\n place of UEK\u0027s wait_event_timeout() + WARN_ON(), plus the resweep for\n IB\u0027s asynchronous device detach; also cover rds_loop_exit(); rewrite\n commit message]\nSigned-off-by: Allison Henderson \u003cachender@kernel.org\u003e\nLink: https://patch.msgid.link/20261113044355.2932029-8-achender@kernel.org\nSigned-off-by: Jakub Kicinski \u003ckuba@kernel.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "258a6bc3c57301feacfdc8f826f0417e20a5aafa",
      "old_mode": 33188,
      "old_path": "net/rds/connection.c",
      "new_id": "c7655e9339ca9d7ca1cff0cc6db382736887e3f8",
      "new_mode": 33188,
      "new_path": "net/rds/connection.c"
    },
    {
      "type": "modify",
      "old_id": "e14110ea37b669cc07ddc103f49122ba409f7349",
      "old_mode": 33188,
      "old_path": "net/rds/ib.c",
      "new_id": "7b1f611c0a3e50e5729091afb16af36b1bcbcba4",
      "new_mode": 33188,
      "new_path": "net/rds/ib.c"
    },
    {
      "type": "modify",
      "old_id": "3d063a23bd0b674dfdc09a47bdf654f66020667a",
      "old_mode": 33188,
      "old_path": "net/rds/loop.c",
      "new_id": "71f760ccd4585586acb03d1d94edfb73e95e4e36",
      "new_mode": 33188,
      "new_path": "net/rds/loop.c"
    },
    {
      "type": "modify",
      "old_id": "6cc5ea183491bfac62c42c7844c282c67ef2ed4c",
      "old_mode": 33188,
      "old_path": "net/rds/rds.h",
      "new_id": "b4311edb36bf4c3d7415160516f450697b8b784f",
      "new_mode": 33188,
      "new_path": "net/rds/rds.h"
    },
    {
      "type": "modify",
      "old_id": "059c9a1729f8643ceeba413413d870ac8792182f",
      "old_mode": 33188,
      "old_path": "net/rds/tcp.c",
      "new_id": "900269ae634159f452335af873f68ae5f49953a3",
      "new_mode": 33188,
      "new_path": "net/rds/tcp.c"
    }
  ]
}
