Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2333685rwb; Wed, 30 Nov 2022 05:30:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Db5gnePASevdm7ceyVL4M2qrcBsjGAcg3JMyJQCbPFImE7xEOlUpsz+eaegtAHc3pwaLs X-Received: by 2002:aa7:8709:0:b0:572:2189:84ef with SMTP id b9-20020aa78709000000b00572218984efmr42357874pfo.28.1669815057486; Wed, 30 Nov 2022 05:30:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669815057; cv=none; d=google.com; s=arc-20160816; b=h9A8XqzeA6A3byKKl/LjCgZuIYyHlTBqHZYOrdr1LYqFFPKyJCCh2obwpwQuhyEWjF ZlZKhHlQp7xieJG0Sk9dualNjODw7mXkTOlBDUQEsNTk5Wtvg2x011iAB8tibqQC6MNc T67QOhCyA7lkTbzQ8A/1eDVx9kyV9BlW3JouB1EwLmXk0NvyIcc0MERPigOJVsvxCkSw recmd541gZ3sfn7FdWcIjwZ1+5Dk4nXucis7AMBxB47N47DH9uH4MuiUdFL91xrQLxVu Eiv29ZuInZ2PPP5UrPHjWpOOLzWH1+/Hx7jf8lRME2ygZRCqH71eD8vSv0jQN5fAl6N/ BtEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=j3gCSpctzSb5QQ/wDIhVeSSLZMDhkOBRyiGRuBRimuo=; b=JrKJawujSu6ZDpJnxRQOxoaA0lvvH7NpjEVGd56BrU8wBflywP124KN3vmNUiZi/qH hWXkqIBKjtMKm+oEIoAhHr8p4FE28r0l1cb30wSQQCwrPHncu0kKeuN6nCueaKBh49SK +H6tHBC2IoG0NMCCRWF6/uFcF2UWqVb/fNpzRhYvBcGP18qQINKlX5afeu3A8Mi5hBSd vzW7C1nEBq0iGrY0gdkn0dCOdhw7OQikkHJ0UmMZpa4LQVX2sF4dmEd4WdMXqBmEcx3J kLpJt6Hk2Qdb5JNGZIs5U3ECtGVumHQ7gKftMqPfVR+QYH59JIk5O3c9vds1k+Hp/vm/ 47XQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s21-20020a632155000000b0046eed3142cesi1259062pgm.350.2022.11.30.05.30.46; Wed, 30 Nov 2022 05:30:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235687AbiK3NS3 (ORCPT + 84 others); Wed, 30 Nov 2022 08:18:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232159AbiK3NS0 (ORCPT ); Wed, 30 Nov 2022 08:18:26 -0500 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BD4124F0F; Wed, 30 Nov 2022 05:18:24 -0800 (PST) Received: by mail-ed1-f51.google.com with SMTP id s12so23995295edd.5; Wed, 30 Nov 2022 05:18:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=j3gCSpctzSb5QQ/wDIhVeSSLZMDhkOBRyiGRuBRimuo=; b=V+W+YM544wbHcC9G8cXtrINwH3eFIe4dyJqg++CvRKtPI3CBHvk9VYF51BRvbsKhy0 PJcU4K3iE413N8f9Miuw4UL45VA4VgFSbayTak0hR6x3Q6GshJ19TtxGjNtu2JMYm7lf ZdhoGytSXHDYxWL32BnMvIa1vr9zdwdp4ymV+MWKb1mBStgTBqg1uW4/t7juF3bSnjpw 42Az6/XDi9sY1sgwxqomWEAORnePcuR/e9jm05/Dc01DobNoh8hjSyVevjXT9D18sH9Z W81Y1110eGxjvgklL4inpeqxmCi5ZgZ2/NQqnf3UkZiY3CqGnU4fV+GqI1ujfMwhe+Rj +SKQ== X-Gm-Message-State: ANoB5pmH9jvfVk97NlVv7FZKih80+YQgIyCe+2yo4braBMtzALumT+GF 8SSSzMk+NI06pyj26/iC6cSgyeoyentfCA== X-Received: by 2002:a05:6402:144f:b0:46b:51e5:832a with SMTP id d15-20020a056402144f00b0046b51e5832amr11078029edx.331.1669814302988; Wed, 30 Nov 2022 05:18:22 -0800 (PST) Received: from gmail.com (fwdproxy-cln-020.fbsv.net. [2a03:2880:31ff:14::face:b00c]) by smtp.gmail.com with ESMTPSA id i9-20020a170906698900b007bff9fb211fsm644089ejr.57.2022.11.30.05.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 05:18:22 -0800 (PST) Date: Wed, 30 Nov 2022 05:18:20 -0800 From: Breno Leitao To: "Iwashima, Kuniyuki" Cc: "davem@davemloft.net" , "dsahern@kernel.org" , "edumazet@google.com" , "kuba@kernel.org" , "leit@fb.com" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "pabeni@redhat.com" , "yoshfuji@linux-ipv6.org" Subject: Re: [PATCH RESEND net-next] tcp: socket-specific version of WARN_ON_ONCE() Message-ID: References: <20221124112229.789975-1-leitao@debian.org> <20221129010055.75780-1-kuniyu@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 29, 2022 at 09:16:16PM +0000, Iwashima, Kuniyuki wrote: > > On Nov 29, 2022, at 21:48, Breno Leitao wrote: > >> On Tue, Nov 29, 2022 at 10:00:55AM +0900, Kuniyuki Iwashima wrote: > >>> +void tcp_sock_warn(const struct tcp_sock *tp) > >>> +{ > >>> + const struct sock *sk = (const struct sock *)tp; > >>> + struct inet_sock *inet = inet_sk(sk); > >>> + struct inet_connection_sock *icsk = inet_csk(sk); > >>> + > >>> + WARN_ON(1); > >>> + > >>> + if (!tp) > >> > >> Is this needed ? > > > > We are de-referencing tp/sk in the lines below, so, I think it is safe to > > check if they are not NULL before the de-refencing it. > > tp->snd_cwnd is accessed just after this WARN, > so I thought there were no cases where tp is NULL. Oh, important to say that we want to re-use this macro on other places as well. This initial usage (on tcp_snd_cwnd_set()) is just for the initial patch. I see value replacing some WARN_ON_*() by TCP_SOCK_WARN_ON_ONCE() in other parts of the code, so, this check is to protect this warning when TCP_SOCK_WARN_ON_ONCE() is called from different places. Anyway, I definitely can remove the check here, but, we might want to re-add it later, as we replace some WARN_ON_* by TCP_SOCK_WARN_ON_*(); > I think this additional if could confuse future readers and > want to make sure if there is such a case. How come checking if a pointer is valid before de-refencing it could confuse readers? Thank you for the review!