Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.199 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796232261; b=ogLPoES01bPxGxFoD2BXVP9njDlXu9EUdUCjaVF/RY+41AFG8QFVobrKQCrZhmAHwvSf t8aDSnsYXFsD1/zN6jraUcyXsdWYULcH98tS3Q2yfmXjv/4j5OcG/s2L1rW8miJGgloTM F+VzNMwHpXshq2yr0VQpFSZrlrO7uVJmyIeiyfsFSWEsghrlE8mw2OQE6i3uyXqmavcjw RJ+kaVlKEz3bxxf5OsYcVkvuqwDxqazZExKb/BLiDkEPaC9s9R931zrxjZ4HXj+nRZcYa N1sq7jJmazpRWNUz9Qe678Inqd2IRztvnKaDR/BFIIkPAtu1FD1DNIPGmcqCgNBMhWw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796232261; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=8pDdiiKq5tUbzN/VZCRvBqHHknqYl3rIZdefQSN31D8=; b=QLzD89pz9JezXa68K0npVLZBpLWALibiDWXEYfrYpNNYCQ8KzbRxHtM249r/zsdJfH4n nPuFsbahA6x/sXQvksPGEgJk2oPvNUXmfoBgxVHSdh77C9JxkiRNPJB3jaKNC5MzdTs61 kLPpK0CknCwnqFpDvTKgine2ZMhcUkHZKDaZhBZJDwEHRDyqR3SYwD3tOMvdGhe8gKPdb t/CTJ7MN1eufRcvXYLescb4EPmD4RbaBjERGgQByCY2h2d6191qi+rS6TtCg8faVBQx+u 8CincbTisRqTx8XoV2hUBDWMjTnQH8PYC+czhlejcYV5O7ppY2Tf989yWxHfmq/z4ng== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--zhenwenliang.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=B1PXWuej; arc=none smtp.remote-ip=209.85.167.199 Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5DC5606A322 for ; Wed, 2 Dec 2026 17:24:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A5DC5606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--zhenwenliang.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=B1PXWuej Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-57eac2a0602so5188496b6e.2 for ; Wed, 02 Dec 2026 09:24:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796232259; x=1796837059; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=8pDdiiKq5tUbzN/VZCRvBqHHknqYl3rIZdefQSN31D8=; b=B1PXWuejh0IxvHiqDPJeJEtpQjPgvADxrfKYE9KrTk2TYoV/Certel/0K8Q/UvmLuZ tnFujhz1BQVxAw8Np6jkdsoqp5FYKpF5lSD8ERmTs8Y61L91huoYhZyYLDejmxbiYw4t 3iZ0qYcOnqk+b4+c8seG8YkPzggMAA87Oxs1+RWD1O2JNVFaMMqrNngSf7rN2Iudr/t8 R34AQ9F+byS6u3Yv6MSIsI+8jckut7lQC9WQsAHsZRPigpq9EndlFUIFTji2j9qTUZFf KrLJvcP+0IcpLVUhANVrOJ90sO3ySZQ91HMnmyym+e05kCX2ScmG00ErPSzkcVifz9lg qoBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796232259; x=1796837059; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=8pDdiiKq5tUbzN/VZCRvBqHHknqYl3rIZdefQSN31D8=; b=cTi6vFPDavPPmgUk0uBHxDo6xVxwu8iL62ZazAIl5vJ5wkmJUoHF/lZMniseLRo3iY Z4BO2xoO6hhsqynnSZ0tGl4lv5nQxAxLJeSihXsnEc2A1TRJmYXSlmNkfxeaNkR1O0tu W04RaqsWpTgKJR/YLxI0zggQ2aPAlPIrcm1ors5r1pHNO3NUTy6P4YonyESemabFFy+i 6v1I2WPnrQEknKUMREdJVjw2NDRV7HnDySLLIcMb3CP3pp0yafwdFGyYzpBqsLYIaOYN EDIkvQuwEKE236VceibjlB0PZgPmdL6hXHvA9UqWHjUuO4FJijeIafgQwvUKhsGDZ4J0 YcSA== X-Forwarded-Encrypted: i=1; AL+hErGgxGfXCkxC2HKGeHqHFC7uYNPiXRi73rSBiXnQulYrYtgkSn7kvKXzhPBg8N0G8vreHPSx74QyR9NP@vger.kernel.org X-Gm-Message-State: APuU4Z9uMy6xCdywzKxOOfsMj/6jOFTBE68wbvhZRM2FRf6/2gH4L3Ta jPzzHZGo3Pyu1oWNH4Mxxr5LT8RpP8Qv3CaNVFNEes5k8wqiPxzXD6jA5d2dnTWnukZPy/0ChB6 WQwEItrEYV01C6DXCs6eMtnYe+fVtCA== X-Received: from ilei13-n1.prod.google.com ([2002:a05:6e02:61cd:10b0:522:1702:a165]) (user=zhenwenliang job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:508f:b0:4c4:c7cc:f8ee with SMTP id 5614622812f47-57a0a20af5fmr46533811b6e.13.1796232259237; Wed, 02 Dec 2026 09:24:19 -0800 (PST) Date: Wed, 2 Dec 2026 17:24:15 +0000 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261202172415.2785749-1-zhenwenliang@google.com> Subject: [PATCH net v2] net/rds: wake the shutdown waiter after returning the FRWR slot From: Zhenwen Liang To: Allison Henderson Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com Content-Type: text/plain; charset="UTF-8" rds_ib_conn_path_shutdown() waits until, among other things, i_fastreg_inuse_count is 0 and i_fastreg_wrs is back at RDS_IB_DEFAULT_FR_WR. rds_transition_frwr_state() wakes it when it drops i_fastreg_inuse_count, but every caller still holds an i_fastreg_wrs slot at that point and returns it later without a wake-up. A waiter that rechecks in between goes back to sleep, and shutdown waits for its 1 s timeout on any architecture. Wake the waiter after the slot is returned instead, using wq_has_sleeper() so that the increment is ordered before the wait queue check. Allison Henderson pointed out that the sashiko review of a similar fix flagged this site. The analysis was checked, and this patch prepared, with the help of a formal analysis tool we are developing that uses AI assistance; I have reviewed the analysis and the patch. Fixes: 3a2886cca703 ("net/rds: Keep track of and wait for FRWR segments in use upon shutdown") Suggested-by: Allison Henderson Signed-off-by: Zhenwen Liang --- v2: Wake the waiter after i_fastreg_wrs is incremented, not in rds_transition_frwr_state(), where the wait condition cannot hold yet (Sashiko review). New subject. v1: https://lore.kernel.org/r/20261130164729.981519-1-zhenwenliang@google.com/ The other unordered waker, rds_ib_ring_free(), is fixed separately: https://lore.kernel.org/r/20261129024701.277838-1-zhenwenliang@google.com/ Compile-tested only (arm64). net/rds/ib_frmr.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c index 8397aa4a17ac..b6172d8ca43d 100644 --- a/net/rds/ib_frmr.c +++ b/net/rds/ib_frmr.c @@ -45,11 +45,19 @@ rds_transition_frwr_state(struct rds_ib_mr *ibmr, */ smp_mb__before_atomic(); atomic_dec(&ibmr->ic->i_fastreg_inuse_count); - if (waitqueue_active(&rds_ib_ring_empty_wait)) - wake_up(&rds_ib_ring_empty_wait); } } +/* Return an i_fastreg_wrs slot and wake rds_ib_conn_path_shutdown(), which + * waits for all slots to be back. + */ +static void rds_ib_put_fastreg_wr(struct rds_ib_connection *ic) +{ + atomic_inc(&ic->i_fastreg_wrs); + if (wq_has_sleeper(&rds_ib_ring_empty_wait)) + wake_up(&rds_ib_ring_empty_wait); +} + static struct rds_ib_mr *rds_ib_alloc_frmr(struct rds_ib_device *rds_ibdev, int npages) { @@ -184,7 +192,7 @@ static int rds_ib_post_reg_frmr(struct rds_ib_mr *ibmr) return ret; out_inc: - atomic_inc(&ibmr->ic->i_fastreg_wrs); + rds_ib_put_fastreg_wr(ibmr->ic); return ret; } @@ -301,7 +309,7 @@ static int rds_ib_post_inv(struct rds_ib_mr *ibmr) * before incrementing i_fastreg_wrs */ smp_mb__before_atomic(); - atomic_inc(&ibmr->ic->i_fastreg_wrs); + rds_ib_put_fastreg_wr(ibmr->ic); pr_err("RDS/IB: %s returned error(%d)\n", __func__, ret); goto out; } @@ -354,7 +362,7 @@ void rds_ib_mr_cqe_handler(struct rds_ib_connection *ic, struct ib_wc *wc) * before incrementing i_fastreg_wrs */ smp_mb__before_atomic(); - atomic_inc(&ic->i_fastreg_wrs); + rds_ib_put_fastreg_wr(ic); } void rds_ib_unreg_frmr(struct list_head *list, unsigned int *nfreed, -- 2.56.1.911.g883d8bcb20-goog