From patchwork Wed Oct 23 08:14:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13846667 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 475F5153BFC for ; Wed, 23 Oct 2024 08:15:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729671305; cv=none; b=Ml6d5GZ/3pgYuOJAbVsHnkxf/eaWotUw1QMuiFwT72xqydeST7fsxihH4XJ/IWVPmFJuWeM4ZMI5jiKkhePaAl1l190+dpo0OVb7IqIT66O5+91TB5AdIqpR8wdNMhOLL1OU3VrCA6Ybn32NVusmng+r4VqIOHoInYM0KH+LAcU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729671305; c=relaxed/simple; bh=JyL7KJmrLwRMMayuDJ9HXC3NVA97DsX7qIjzWmPwPUY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VbU/RxKXwmoPQqHsyaPgfoyXuvCEeg0TABPFyEDEGSviLnKBAAPi2YC+qSSpO3GQ+s/Bqv+xibwKKaksmYxnjBvsmM/LztXVw5z9RanIYlP6A3FDoKKnil8e8DTZsC/Zg8mKOVbMfqZy/G65PyT1rpKA8z2LAtjSNbDOfN20ZXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RA1lFo1e; arc=none smtp.client-ip=209.85.160.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RA1lFo1e" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-288661760d3so3586806fac.3 for ; Wed, 23 Oct 2024 01:15:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729671303; x=1730276103; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kotvKiyO7pUmUjvSeAfq2wtPetyDaGJ7qjohyJRt1aw=; b=RA1lFo1ewHIQRPKrjP56kV/Khd0vLnPOkA0zLWyipMxnL7dqTh6rZzdlCK7VwkL+GM 0wRalKUIbPCVb860VkSr3V0tjAJr45424DBYXFaO9c9rqgCCxzkaSOIsk8n3BHeGnVYK ZO9oHpvQK6Ys3dDvt3QA+NY5mKO/SklacJxOZXfiL8gdGlBH7e7+Z627LHJzopj6pHgf yOvkZsKm9rmghtAUT49wRrMTjxwnzICV2UW7BoVYSgT0DmKalUC5vqZ/ostp1ONsZjzd iO1xOJW3EH9acydwGpoQ6ukUDTsKECg6zUsWvZe9pfJUEl55BKddEW937e2F+FU03sy/ OCCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729671303; x=1730276103; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kotvKiyO7pUmUjvSeAfq2wtPetyDaGJ7qjohyJRt1aw=; b=M+s9r7tsaJvBlD0kbcmDpISFK3NZwimZ2nB6bwi6xVKkdcjCuDWg9sw/89vK6V58fG oURMQyhON4/DAUF1bT9TemWqDmHrdh5lMGmQb5/ZSMFw82qVmn7A2V++O5nk+neQj/gq Ryxd9l7t8Xxmm7Fg6O0yhOw5XnqkqFuVMDMknCRuz+AF2TXvKjmZszEZ0b8swkv1DYR3 bZUXOIlZqKqnD2J3AzD0UTo2JXVJ14Pdl61s+zOY8rMvwqcNgT2JhFKLDIjWVNJjP1Pl BTlByrVe9Z0QYlmYCyAs3MYobygZli/pB1uCWec9LwOAinQvRQD9vBBbMaXs0OqXqDtX FiBw== X-Gm-Message-State: AOJu0YxwMZkHRRB3CK61lXC8cpemD4SYJVaxuw9RLcNp/vfpl/VIswfw 3nREcMTpWPSUfV/ZhylilxdXJC9LZqRPWNuhRkKKtVqYVuE+T5wlWPzHUw== X-Google-Smtp-Source: AGHT+IFrO/pcfB+9oEHp4+4+xWalJfsqHZClAXUQBoVZm9ZoHXjKO1V17XOeocPPWoL/CqbUEDCz0Q== X-Received: by 2002:a05:6870:8a0a:b0:288:6644:9c1c with SMTP id 586e51a60fabf-28ccb39b1e0mr1886556fac.6.1729671303135; Wed, 23 Oct 2024 01:15:03 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.21]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec1312d1fsm5837786b3a.5.2024.10.23.01.15.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 01:15:02 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, Jason Xing , Neal Cardwell Subject: [PATCH net-next v3 1/2] tcp: add a common helper to debug the underlying issue Date: Wed, 23 Oct 2024 16:14:51 +0800 Message-Id: <20241023081452.9151-2-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20241023081452.9151-1-kerneljasonxing@gmail.com> References: <20241023081452.9151-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Following the commit c8770db2d544 ("tcp: check skb is non-NULL in tcp_rto_delta_us()"), we decided to add a helper so that it's easier to get verbose warning on either cases. Link: https://lore.kernel.org/all/5632e043-bdba-4d75-bc7e-bf58014492fd@redhat.com/ Suggested-by: Paolo Abeni Signed-off-by: Jason Xing Cc: Neal Cardwell Reviewed-by: David Ahern --- v3 Link: https://lore.kernel.org/all/f6e70c8d-b9d8-4d15-bb25-69fbec0d138a@kernel.org/ 1. add reviewed-by tag (David) v2 Link: https://lore.kernel.org/all/38811a75-ae98-48e7-96c0-bb1a39a0d722@kernel.org/ 1. fix "break quoted strings at a space character" warning (David Ahern) --- include/net/tcp.h | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 739a9fb83d0c..8b8d94bb1746 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -2430,6 +2430,19 @@ void tcp_plb_update_state(const struct sock *sk, struct tcp_plb_state *plb, void tcp_plb_check_rehash(struct sock *sk, struct tcp_plb_state *plb); void tcp_plb_update_state_upon_rto(struct sock *sk, struct tcp_plb_state *plb); +static inline void tcp_warn_once(const struct sock *sk, bool cond, const char *str) +{ + WARN_ONCE(cond, + "%sout:%u sacked:%u lost:%u retrans:%u tlp_high_seq:%u sk_state:%u ca_state:%u advmss:%u mss_cache:%u pmtu:%u\n", + str, + tcp_sk(sk)->packets_out, tcp_sk(sk)->sacked_out, + tcp_sk(sk)->lost_out, tcp_sk(sk)->retrans_out, + tcp_sk(sk)->tlp_high_seq, sk->sk_state, + inet_csk(sk)->icsk_ca_state, + tcp_sk(sk)->advmss, tcp_sk(sk)->mss_cache, + inet_csk(sk)->icsk_pmtu_cookie); +} + /* At how many usecs into the future should the RTO fire? */ static inline s64 tcp_rto_delta_us(const struct sock *sk) { @@ -2441,17 +2454,7 @@ static inline s64 tcp_rto_delta_us(const struct sock *sk) return rto_time_stamp_us - tcp_sk(sk)->tcp_mstamp; } else { - WARN_ONCE(1, - "rtx queue empty: " - "out:%u sacked:%u lost:%u retrans:%u " - "tlp_high_seq:%u sk_state:%u ca_state:%u " - "advmss:%u mss_cache:%u pmtu:%u\n", - tcp_sk(sk)->packets_out, tcp_sk(sk)->sacked_out, - tcp_sk(sk)->lost_out, tcp_sk(sk)->retrans_out, - tcp_sk(sk)->tlp_high_seq, sk->sk_state, - inet_csk(sk)->icsk_ca_state, - tcp_sk(sk)->advmss, tcp_sk(sk)->mss_cache, - inet_csk(sk)->icsk_pmtu_cookie); + tcp_warn_once(sk, 1, "rtx queue empty: "); return jiffies_to_usecs(rto); } From patchwork Wed Oct 23 08:14:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13846668 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCE1C15C13F for ; Wed, 23 Oct 2024 08:15:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729671308; cv=none; b=H2oF/xvZGSSF7G63MFHKzS0lM0YPUI9QnYSIoa+Iud5+DGI31SFxF9ljTDewtZWgmPRvLNZ6tIv2/+4SVaIh6gTWH0Yiq2pedin6chv0rZJCxjGwQyGP1YkVW5JshtOuUvD3GbkUyft3Sj35fL9R7rhmrSKJc/7+Dsyh6aLaeVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729671308; c=relaxed/simple; bh=TGV+TDsctUgneUan+to+MWzX/iPyiUeA4AKWokegHfA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gdqo/UczBg29x8UBl3QJMh6/CkMWjoSCKMksYMotxf3I3rCGbnOWXnPX0ODPUGMv3end0w0EL4Jg209Nad2xFISQIrR2icw00T1bETbXvzyiHkYs2wllZFIu8kfQ9MGZI03EuglBtzcQHaxgwpWZhcLoo9EJI8XUpGxmc8ICqY0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Yt5fnLjb; arc=none smtp.client-ip=209.85.215.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Yt5fnLjb" Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-7ed9c16f687so501614a12.0 for ; Wed, 23 Oct 2024 01:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729671306; x=1730276106; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I3lDrf8nMbheae0kI9Cq9wDU/qv8Sa2XrwC1/t0b94w=; b=Yt5fnLjbOjxtsHaa8aPKa/yWunA8DZPIb20u7BEPnZksFovy2lrD6EktG++qailTMX w7ILKL69HzT6wqsdfoNhOZcZt1iczSJF1f7db2aFQFnFjX8jMZGEtOfI73Ck/rBXo2ho VItI/KEjRWZ+ZYDNy0sTKcIV0xP1yIYZCaNl0t/0GX+Mzp3jdOU5PApykqM0T2i9RX+C 7MpfgBYq49VdsOJiING6InpdaJHfgZ0yT6gENB33zY+aEVpfS5Rb3LVlm0CACNQkhDzf 9EIGiqWWnnpNvaJQCyHxhEozT0IBpKuWuo3Xs+eaNxrnRTkj81rI2HRuoBd6dtUVQ0KS wVsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729671306; x=1730276106; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I3lDrf8nMbheae0kI9Cq9wDU/qv8Sa2XrwC1/t0b94w=; b=MdvG2JbwmJAZ+2JCvMchnf7P+ZYGRlBuF9QGHZ83ZMODgmYSJVDoIzOGJnzkBpGi1h wGiTHKLyLzbV5jo1fQ4ljJqGkmbRMWqAtsGM00otbhtV5ZHfB4NPHUKyffdFdGW/qCAg YsLFjjJOX9F31SailiSxEzCrDcDUBBooo1XJZ8Qvwf2Z9yhhj8MdUCR2V/cO1Vja1hes R8iHgeisYTpmpt4byJ0z1we97mbSqffzEbeGzYXaiBGRoceVzBIE1SxTxeoWUAAexGNe BeU7JvDjoP6HSbAy3jNS8oo+5y98eeiIkQmhDbjCyjo4sIHlyqIpe4zz0nVmDPnHDITJ Ee+Q== X-Gm-Message-State: AOJu0YwZrxEqdTqgWUo9pTnW88V0cQxlcbt3GNeJyuenus50xOwkdE3b P8TVa7/pVw4SNK3SkyA7ODj5AXn4W+lq5G376qD2qn/IA2GKuibV X-Google-Smtp-Source: AGHT+IE+vKPLhg1UzhA2Ko991QH82Cxc/X7DJX+l0HqsEK1jHh23tAoIvRqu/5He/Ed237uPn1QU/g== X-Received: by 2002:a05:6a21:78b:b0:1d9:21fb:d31f with SMTP id adf61e73a8af0-1d978bb2aacmr2016659637.45.1729671306036; Wed, 23 Oct 2024 01:15:06 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.21]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec1312d1fsm5837786b3a.5.2024.10.23.01.15.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 01:15:05 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, Jason Xing , Neal Cardwell Subject: [PATCH net-next v3 2/2] tcp: add more warn of socket in tcp_send_loss_probe() Date: Wed, 23 Oct 2024 16:14:52 +0800 Message-Id: <20241023081452.9151-3-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20241023081452.9151-1-kerneljasonxing@gmail.com> References: <20241023081452.9151-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Add two fields to print in the helper which here covers tcp_send_loss_probe(). Link: https://lore.kernel.org/all/5632e043-bdba-4d75-bc7e-bf58014492fd@redhat.com/ Suggested-by: Paolo Abeni Signed-off-by: Jason Xing Cc: Neal Cardwell Reviewed-by: David Ahern --- v3 Link: https://lore.kernel.org/all/20241021155245.83122-3-kerneljasonxing@gmail.com/ 1. add missing string "invalid inflight: " (David) 2. add reviewed-by tag (David) 3. remove tcp_current_mss() due to possible change happening on the socket's state (Eric) v2 Link:https://lore.kernel.org/all/CAL+tcoAr7RHhaZGV12wYDcPPPaubAqdxMCmy7Jujtr8b3+bY=w@mail.gmail.com/ 1. use "" instead of NULL in tcp_send_loss_probe() --- include/net/tcp.h | 3 ++- net/ipv4/tcp_output.c | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 8b8d94bb1746..e9b37b76e894 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -2433,8 +2433,9 @@ void tcp_plb_update_state_upon_rto(struct sock *sk, struct tcp_plb_state *plb); static inline void tcp_warn_once(const struct sock *sk, bool cond, const char *str) { WARN_ONCE(cond, - "%sout:%u sacked:%u lost:%u retrans:%u tlp_high_seq:%u sk_state:%u ca_state:%u advmss:%u mss_cache:%u pmtu:%u\n", + "%scwn:%u out:%u sacked:%u lost:%u retrans:%u tlp_high_seq:%u sk_state:%u ca_state:%u advmss:%u mss_cache:%u pmtu:%u\n", str, + tcp_snd_cwnd(tcp_sk(sk)), tcp_sk(sk)->packets_out, tcp_sk(sk)->sacked_out, tcp_sk(sk)->lost_out, tcp_sk(sk)->retrans_out, tcp_sk(sk)->tlp_high_seq, sk->sk_state, diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 054244ce5117..5485a70b5fe5 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2954,9 +2954,7 @@ void tcp_send_loss_probe(struct sock *sk) } skb = skb_rb_last(&sk->tcp_rtx_queue); if (unlikely(!skb)) { - WARN_ONCE(tp->packets_out, - "invalid inflight: %u state %u cwnd %u mss %d\n", - tp->packets_out, sk->sk_state, tcp_snd_cwnd(tp), mss); + tcp_warn_once(sk, tp->packets_out, "invalid inflight: "); smp_store_release(&inet_csk(sk)->icsk_pending, 0); return; }