Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1288538rdb; Sun, 8 Oct 2023 00:09:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8f6Rh0D+Vy25YHyIbWxryx81KSzVZwoMkyrDyQbTcLvNNnawQaYlNHGmnTdMAtCpu0lv3 X-Received: by 2002:a05:6808:197:b0:3ae:5442:ed11 with SMTP id w23-20020a056808019700b003ae5442ed11mr12228669oic.54.1696748950156; Sun, 08 Oct 2023 00:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696748950; cv=none; d=google.com; s=arc-20160816; b=xdDrqbJT0LL2OjGMYQ6UplmjLvJ1VoeKY5w2Znj+xDBA7P7LheO9vNc9UIeBz+FA4a WQeZiR75cE+DqsfO+KbMUeJo4DwRLtWaA3eWArKY+0NhCaBOjIKk0TAuQPDpqDLhX9Cs a01tIIZ/u2aT+t7RQG7tun9k1JDpaNjw+AGnh8B9pkF3V+AoRZmOQSOnDq608/4iAR1J PXf6lnGxWMla1p9ecpFeiPidLdWuZBtxaoyJnl6qhQUubLiafAZKf6XKpXqXFEfEnpn0 zD1jx6I+54PPk1bea/bpuTJSQkOCcLLcNNl6RvmmMhHFTHz+FSay8V16GFIy1WFgxnaC 9QTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6boweBsbEPYLh1haUGvUFhb+7tfvWfkGzP1aLPKTUnI=; fh=BrqZMW8jZrPvQPkx1Q1LARmakMyYMGjLZPpVcJ2dAQs=; b=clzn8hXVn4ycfD/qyuhzHwiZQOxCzIAx90egLruB3RqefJXl4TRazKpjMxtxbYTl/t r1aNk13ELP/6QDHLhWRfrBHQBmoRpJtMQFfOAR09wN7jhuWQimDOElWDYhRMF9SQzQrU QEoXgHokC0jJgohXDdQ7wYQaAPDeyLwXoVKUbyuL52KIP3zzAGRmaF632nFhF75FznFc EIUB8w6jY5CU20sTf5oDHnIFDmVTx81DHq2tYELTfWcuabZpd5eM3aOcamgrUOvC7qyE 2hHuxiyH1v7KXkRxBeEBAZ/kGtZeXWCH1GR2CIIALbwjMTTPQlLJIHCIedW4F+lG8LdZ 40gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=F39qHPk5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id s63-20020a632c42000000b00573f867019fsi6993548pgs.443.2023.10.08.00.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 00:09:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=F39qHPk5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4FB3A80ADF0C; Sun, 8 Oct 2023 00:09:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234237AbjJHHJF (ORCPT + 99 others); Sun, 8 Oct 2023 03:09:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234218AbjJHHJA (ORCPT ); Sun, 8 Oct 2023 03:09:00 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18F69FA for ; Sun, 8 Oct 2023 00:08:57 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-51e24210395so8135a12.0 for ; Sun, 08 Oct 2023 00:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696748935; x=1697353735; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6boweBsbEPYLh1haUGvUFhb+7tfvWfkGzP1aLPKTUnI=; b=F39qHPk5zk2pyBIKhEM6PcfKPQRqnY9pi/x8dTGkHBXtoFP1RZ9kgEew/bWJahSX7u ijedCeuRSfwz7OjfdCyxdqgtiBIWDVnZ+085y5EzOmOe01pKu/WoqWvlKM610Lf5ihNv BMUgGXOMdVPIH/J4H13eMVDC7AnXJsSP84YgXJgXK+hcNEhDJZUgmt1wUlUZv3PKqkU0 g3k1jhh3eNn9QqkZXTNDOqxxoGlKUKZouNkqgcyvOvgTA+tlURIcHSfsmXi4Jc2lAOHi Va+NwqU0sc3x25H3/Yd53hz8MkS+gfLDgULe90K8Q9KqVKkuV57WLP+bSXUphgxnKMpJ 4SZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696748935; x=1697353735; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6boweBsbEPYLh1haUGvUFhb+7tfvWfkGzP1aLPKTUnI=; b=t2+Ubxns/AuFdGE18Ui7ULh77w1qie6Pi/9h59LyCbYyUjkHa8XrMyDXgP7E66cN6V 7X5fM6q4byOIUKLV35bKGzvhBqrPYnGTMdFZBWJJLJHRuPWWHJp8tC5zurS5jh3rrMtN StF7aMc0gybD4BOkNda6VwCO/NMKPqcsYa2Q21k3zn4MBxNb1u5v7MCIZtac+eT/Ml2r n+Y+sL9n+bbqfiR6JHw6IZt4prhjYkg4ZU9xu9jKzyvTTMW+u+duSjrP0R11FgT/6AuG Iak3YNHB1F5qrZ5nIck03p7mJU/B8IhV131k1ajOv3mr8Obqx6pWiCow6DUYYSl3fua1 c/pA== X-Gm-Message-State: AOJu0Yx96gxuEY8w09zhb76X1QgOie9JpiDPtafYzpZ3Q1En9jI9tm+E 7+T9ykmG/E7lbPu91/CX9jwC60HutCnzuQvohtVMKg== X-Received: by 2002:a50:9f6c:0:b0:52e:f99a:b5f8 with SMTP id b99-20020a509f6c000000b0052ef99ab5f8mr308559edf.7.1696748935193; Sun, 08 Oct 2023 00:08:55 -0700 (PDT) MIME-Version: 1.0 References: <20231003145150.2498-1-ansuelsmth@gmail.com> <20231003145150.2498-4-ansuelsmth@gmail.com> <652056c5.5d0a0220.2b60d.c5dc@mx.google.com> In-Reply-To: <652056c5.5d0a0220.2b60d.c5dc@mx.google.com> From: Eric Dumazet Date: Sun, 8 Oct 2023 09:08:41 +0200 Message-ID: Subject: Re: [net-next PATCH v2 4/4] netdev: use napi_schedule bool instead of napi_schedule_prep/__napi_schedule To: Christian Marangi Cc: Jason Gunthorpe , Leon Romanovsky , Wolfgang Grandegger , Marc Kleine-Budde , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Chris Snook , Raju Rangoju , Jeroen de Borst , Praveen Kaligineedi , Shailend Chand , Douglas Miller , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Nick Child , Haren Myneni , Rick Lindsley , Dany Madden , Thomas Falcon , Tariq Toukan , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Krzysztof Halasa , Kalle Valo , Jeff Johnson , Gregory Greenman , Chandrashekar Devegowda , Intel Corporation , Chiranjeevi Rapolu , Liu Haijun , M Chetan Kumar , Ricardo Martinez , Loic Poulain , Sergey Ryazanov , Johannes Berg , Yuanjun Gong , Simon Horman , Rob Herring , Ziwei Xiao , Rushil Gupta , Coco Li , Thomas Gleixner , Junfeng Guo , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Wei Fang , Krzysztof Kozlowski , Yuri Karpov , Zhengchao Shao , Andrew Lunn , Zheng Zengkai , Lee Jones , Maximilian Luz , "Rafael J. Wysocki" , Dawei Li , Anjaneyulu , Benjamin Berg , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 08 Oct 2023 00:09:09 -0700 (PDT) On Fri, Oct 6, 2023 at 8:49=E2=80=AFPM Christian Marangi wrote: > > On Thu, Oct 05, 2023 at 06:16:26PM +0200, Eric Dumazet wrote: > > On Tue, Oct 3, 2023 at 8:36=E2=80=AFPM Christian Marangi wrote: > > > > > > Replace if condition of napi_schedule_prep/__napi_schedule and use bo= ol > > > from napi_schedule directly where possible. > > > > > > Signed-off-by: Christian Marangi > > > --- > > > drivers/net/ethernet/atheros/atlx/atl1.c | 4 +--- > > > drivers/net/ethernet/toshiba/tc35815.c | 4 +--- > > > drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 4 +--- > > > 3 files changed, 3 insertions(+), 9 deletions(-) > > > > > > diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/e= thernet/atheros/atlx/atl1.c > > > index 02aa6fd8ebc2..a9014d7932db 100644 > > > --- a/drivers/net/ethernet/atheros/atlx/atl1.c > > > +++ b/drivers/net/ethernet/atheros/atlx/atl1.c > > > @@ -2446,7 +2446,7 @@ static int atl1_rings_clean(struct napi_struct = *napi, int budget) > > > > > > static inline int atl1_sched_rings_clean(struct atl1_adapter* adapte= r) > > > { > > > - if (!napi_schedule_prep(&adapter->napi)) > > > + if (!napi_schedule(&adapter->napi)) > > > /* It is possible in case even the RX/TX ints are dis= abled via IMR > > > * register the ISR bits are set anyway (but do not p= roduce IRQ). > > > * To handle such situation the napi functions used t= o check is > > > @@ -2454,8 +2454,6 @@ static inline int atl1_sched_rings_clean(struct= atl1_adapter* adapter) > > > */ > > > return 0; > > > > > > - __napi_schedule(&adapter->napi); > > > - > > > /* > > > * Disable RX/TX ints via IMR register if it is > > > * allowed. NAPI handler must reenable them in same > > > diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/eth= ernet/toshiba/tc35815.c > > > index 14cf6ecf6d0d..a8b8a0e13f9a 100644 > > > --- a/drivers/net/ethernet/toshiba/tc35815.c > > > +++ b/drivers/net/ethernet/toshiba/tc35815.c > > > @@ -1436,9 +1436,7 @@ static irqreturn_t tc35815_interrupt(int irq, v= oid *dev_id) > > > if (!(dmactl & DMA_IntMask)) { > > > /* disable interrupts */ > > > tc_writel(dmactl | DMA_IntMask, &tr->DMA_Ctl); > > > - if (napi_schedule_prep(&lp->napi)) > > > - __napi_schedule(&lp->napi); > > > - else { > > > + if (!napi_schedule(&lp->napi)) { > > > printk(KERN_ERR "%s: interrupt taken in poll\= n", > > > dev->name); > > > BUG(); > > > > Hmmm... could you also remove this BUG() ? I think this code path can b= e taken > > if some applications are using busy polling. > > > > Or simply rewrite this with the traditional > > > > if (napi_schedule_prep(&lp->napi)) { > > /* disable interrupts */ > > tc_writel(dmactl | DMA_IntMask, &tr->DMA_Ctl); > > __napi_schedule(&lp->napi); > > } > > > > > > Mhhh is it safe to do so? I mean it seems very wrong to print a warning > and BUG() instead of disabling the interrupt only if napi can be > scheduled... Maybe is very old code? The more I see this the more I see > problem... (randomly disabling the interrupt and then make the kernel > die) I am pretty sure this BUG() can be hit these days with busy polling or setting gro_flush_timeout. I wish we could remove these bugs before someone copy-paste them. Again, this is orthogonal, I might simply stop doing reviews if this is not useful.