Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Md Haris Iqbal <haris.iqbal@ionos.com>
Cc: linux-rdma@vger.kernel.org, Jason Gunthorpe <jgg@ziepe.ca>,
	Danil Kipnis <danil.kipnis1@ionos.com>,
	Jack Wang <jinpu.wang@ionos.com>
Subject: Re: [PATCH 7/9] RDMA/rtrs-clt: Back off the reconnect delay exponentially
Date: Thu, 26 Nov 2026 14:03:06 +0200	[thread overview]
Message-ID: <20261126120306.GI774860@unreal> (raw)
In-Reply-To: <20261123143719.938876-8-haris.iqbal@ionos.com>

On Mon, Nov 23, 2026 at 03:37:17PM +0100, Md Haris Iqbal wrote:
> From: Danil Kipnis <danil.kipnis1@ionos.com>
> 
> A path that loses its link waits out the full, flat reconnect_delay_sec
> (30s on rnbd, + 0-8s jitter) before its first retry, and every retry
> after that, no matter how quickly the far end actually comes back.
> Nothing about that delay depends on how the path went down:
> rtrs_clt_err_recovery_work() runs the same way whether the trigger was a
> CM disconnect, a heartbeat timeout, or a port error, so a transient blip
> pays the same price as a genuinely dead fabric.
> 
> Start the delay at RTRS_RECONNECT_BACKOFF_INIT_MS (1s) after the first
> failure and double it on each further consecutive failure, capped at the
> configured reconnect_delay_sec, which becomes the steady-state ceiling
> rather than a constant. reconnect_attempts already counts consecutive
> failures since the path last came up and already resets to 0 in
> rtrs_clt_path_up() on success, so it doubles as the backoff step with no
> new per-path state. The existing anti-herd jitter (RTRS_RECONNECT_SEED)
> is kept as-is on top of every step. RTRS_RECONNECT_BACKOFF_MAX_SHIFT (8)
> only bounds the shift below reconnect_delay_sec's u8 range (max 255s);
> it is a safety margin, not a behavior knob.
> 
> Signed-off-by: Danil Kipnis <danil.kipnis1@ionos.com>
> Reviewed-by: Md Haris Iqbal <haris.iqbal@ionos.com>
> Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
> Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
> ---
>  drivers/infiniband/ulp/rtrs/rtrs-clt.c | 35 ++++++++++++++++++++++++--
>  1 file changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> index 54d72fa52cb1..7930039dcd32 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> @@ -34,6 +34,26 @@
>   */
>  #define RTRS_RECONNECT_SEED 8000
>  
> +/*
> + * Delay before the first reconnect attempt after a failure, doubled on each
> + * further consecutive failure and capped at reconnect_delay_sec. Lets a path
> + * that recovers quickly (a transient CM error, a brief port flap) start
> + * retrying off this short initial delay instead of the full configured
> + * delay, while a path facing a genuinely dead fabric still settles at the
> + * same steady state as before. RTRS_RECONNECT_SEED jitter is added on top
> + * of every attempt as before, so the actual first retry lands anywhere in
> + * [RTRS_RECONNECT_BACKOFF_INIT_MS, RTRS_RECONNECT_BACKOFF_INIT_MS +
> + * RTRS_RECONNECT_SEED).
> + */
> +/* Matches RTRS_RECONNECT_BACKOFF's value by coincidence, not by shared purpose. */
> +#define RTRS_RECONNECT_BACKOFF_INIT_MS 1000
> +/*
> + * Shifting RTRS_RECONNECT_BACKOFF_INIT_MS by more than this always exceeds
> + * reconnect_delay_sec's range (u8, so at most 255000 ms); capping the shift
> + * avoids relying on shift-by-large-amount being well defined.
> + */
> +#define RTRS_RECONNECT_BACKOFF_MAX_SHIFT 8
> +
>  #define FIRST_CONN 0x01
>  /* limit to 128 * 4k = 512k max IO */
>  #define RTRS_MAX_SEGMENTS          128
> @@ -1537,11 +1557,22 @@ static void rtrs_clt_err_recovery_work(struct work_struct *work)
>  {
>  	struct rtrs_clt_path *clt_path;
>  	struct rtrs_clt_sess *clt;
> -	int delay_ms;
> +	unsigned int shift;
> +	u32 delay_ms;
>  
>  	clt_path = container_of(work, struct rtrs_clt_path, err_recovery_work);
>  	clt = clt_path->clt;
> -	delay_ms = clt->reconnect_delay_sec * 1000;
> +	/*
> +	 * reconnect_attempts counts consecutive failures since the path last
> +	 * came up (rtrs_clt_path_up() resets it to 0), so it doubles as the
> +	 * backoff step: 0 failures so far -> the initial delay, each further
> +	 * failure doubles it, capped once it reaches the configured steady
> +	 * state delay.
> +	 */
> +	shift = min_t(unsigned int, clt_path->reconnect_attempts,
> +		      RTRS_RECONNECT_BACKOFF_MAX_SHIFT);
> +	delay_ms = min_t(u32, clt->reconnect_delay_sec * 1000,
> +			 RTRS_RECONNECT_BACKOFF_INIT_MS << shift);

Please avoid the min_t() and max_t() macros, as they implicitly cast
operands of different types. Use the correct types from the beginning.

Thanks

>  	rtrs_clt_stop_and_destroy_conns(clt_path);
>  	queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork,
>  			   msecs_to_jiffies(delay_ms +
> -- 
> 2.43.0
> 
> 

  reply	other threads:[~2026-11-26 12:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 14:37 [PATCH 0/9] Misc patches for RTRS Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 1/9] RDMA/rtrs-clt: Add mpath_policy module parameter Md Haris Iqbal
2026-11-23 14:44   ` sashiko-bot
2026-11-26 11:59   ` Leon Romanovsky
2026-11-23 14:37 ` [PATCH 2/9] RDMA/rtrs-clt: Fix refcount imbalance in rtrs_clt_write_req error path Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 3/9] RDMA/rtrs-clt: Trigger error recovery when posting LOCAL_INV fails Md Haris Iqbal
2026-11-23 15:02   ` sashiko-bot
2026-11-24 14:44     ` Haris Iqbal
2026-11-23 14:37 ` [PATCH 4/9] RDMA/rtrs-srv: Fix processing messages for Big-Endian archs Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 5/9] RDMA/rtrs-clt: rename pathname parameter to sessname in rtrs_clt_open() Md Haris Iqbal
2026-11-23 14:42   ` sashiko-bot
2026-11-24 15:03     ` Haris Iqbal
2026-11-23 14:37 ` [PATCH 6/9] RDMA/rtrs-clt: Fix reconnect jitter being applied in milliseconds Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 7/9] RDMA/rtrs-clt: Back off the reconnect delay exponentially Md Haris Iqbal
2026-11-26 12:03   ` Leon Romanovsky [this message]
2026-11-23 14:37 ` [PATCH 8/9] RDMA/rtrs-srv: Snapshot the READ request header instead of reusing it Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 9/9] RDMA/rtrs-clt: Close all paths before freeing any in rtrs_clt_close() Md Haris Iqbal
2026-11-26 12:04   ` Leon Romanovsky
2026-11-23 15:02 ` [PATCH 0/9] Misc patches for RTRS sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126120306.GI774860@unreal \
    --to=leon@kernel.org \
    --cc=danil.kipnis1@ionos.com \
    --cc=haris.iqbal@ionos.com \
    --cc=jgg@ziepe.ca \
    --cc=jinpu.wang@ionos.com \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox