Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1534596rdb; Mon, 2 Oct 2023 12:34:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnXIoCK8DkXQJu9WahaWBocQz+Dtb0e/eRegU2NzTrUIxNaAOyzW3YAnY7CXY9oTO7uRyJ X-Received: by 2002:a05:6a20:13c6:b0:14b:ee48:85b4 with SMTP id ho6-20020a056a2013c600b0014bee4885b4mr11669138pzc.60.1696275263993; Mon, 02 Oct 2023 12:34:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696275263; cv=none; d=google.com; s=arc-20160816; b=XMiHI9UWdPKsYEMqvnzwYpLAvmu1YP+/oiOuTje5utm4i7YzqR205xyqThJYu/7k0V x6GcJrl3Qo3MKSKbdQa499QSXG936jbQoucOqJb+IaEWbrLEwBufyH6dhJQBlAU2LNgW KCzxLEVur0HLMzr0joFSnKQdZAX07zPvr9ymwgYtQ5ytbh7AWg05qSC5A2Pa8BsZCC3q fItlpV+IsIiCQ+L0E78Lfll1CcJZztj9cFjXY1LoX3WLtWPwhi+huf5bzMtI6rwckjne /9ohqcZy2cs4gQ33rtpLC9S0iaKvPEs6G4XRsLBe9rLljWr1sQIXHKeQJzUW9zk0xwwI iojQ== 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=hDLvwoAl09xn/ODnoM44OyqQjxJOIWQGJH/GqYuQ4IQ=; fh=RUTTD7tS7ncQw6Pe2iFOc+1OI2lu38jYp6WaYrSwKWc=; b=UqoCsD7Er5FDiIjJgrA+0jkXoqVtrK6nqkiO/9LOUF8pzHww3B8Z3evfcNihDMBgfQ 9BHfmcoVZrePn0DycVaxd9BYG2c3d+Q5za00z5qyYncc7OcfraQ8QWepv60wr6SSqgek 72aP7dZBDhMLXH7MmGbb+XR7pk1TdFNKHq5S+z7klQzSqerCX4tfsaqeE2weFKR6yEqS YrjsNqamy1CZrfa7jemBv6UVbawLH8SmwZ1cxIXY9khXGotQX8vrxrake19NVe2jXf0o u8mVh8Z7LSQ7dCHbOEZlzJb0SicRhqW10zQ/d8gAx6EcJionqibAUh1D+lywG8QIwTC2 waPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=32huvWoT; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id u11-20020a170902e5cb00b001b895fc0cfdsi28815155plf.388.2023.10.02.12.34.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 12:34:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=32huvWoT; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-wireless-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 groat.vger.email (Postfix) with ESMTP id 3CF248077489; Mon, 2 Oct 2023 05:50:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237226AbjJBMth (ORCPT + 54 others); Mon, 2 Oct 2023 08:49:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237245AbjJBMte (ORCPT ); Mon, 2 Oct 2023 08:49:34 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6CAFCC2 for ; Mon, 2 Oct 2023 05:49:27 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40662119cd0so88505e9.1 for ; Mon, 02 Oct 2023 05:49:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696250965; x=1696855765; 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=hDLvwoAl09xn/ODnoM44OyqQjxJOIWQGJH/GqYuQ4IQ=; b=32huvWoTtQmkH8X+8aFW4MTBV/FJ2J5hlJWuiJ6pNrp490tONyw2P3a7gWYd1WKxn0 68Ye3I5hBxWTHMqg3IsAtQawidGh3h59YBaJGesgnaH9uP+L2sq3CSlF3TB4rKgl+k+W bD70AfF1JIppBQrWwXHm35IC/FG5cQDQVdiK+gWuLMbcYJ/ncJmJWQa+R8U4+bwIrJjr YZCWqceq4umTE/pn7zPcAh/Xy4ir2VeLEJ0pbWFoGeMj/FnR6i/2X5yG0Yr+MsNkSBRf d+s3Pn787XeJW5+t/nkYbbLFvNqHuhNjOLGlE4riQ4+lFUA7AUOzdCd7RP6UqzMMLh08 TpjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696250965; x=1696855765; 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=hDLvwoAl09xn/ODnoM44OyqQjxJOIWQGJH/GqYuQ4IQ=; b=Vl60Ts8MJDTtze2C7bSiLlHcfSJD4z32gJa6nVfY/4NwAfpoSvfDwWYyMVbi6m0HCU PO0nRpGK45gFmzGMLoTXK373upiC8xIk3kfTHo28QjBmzMfa3yqm1pO9quwRwBllCctn 7LwN9nsxfbkmYf/L8Gd5916usul8DW7GCIfEwV1GW3ZO24haQ2YTqaafnRn0b5VePBTh FnTOATL15/ayHuKAdnnHFmebwsp3RfqQ17oJl8sOsrOz1T3Sw9wx7CC5NKnBsqLEM0dN 3yBRoHr9J59trHp6euyAXg9BJTyYwl1H9Iln9gYA6QtTWYDnbGYD8Q8in9Hv+C7YMg1/ HBWg== X-Gm-Message-State: AOJu0YyEgeMrpvdX162viuGFShgZi1wqxSLEZ9gFxKsX+zJcNcrY+8hv DPECCjpbL7zTM2qw068CHQHm8Eud8J5GzZiVAWnNAw== X-Received: by 2002:a05:600c:4688:b0:405:35bf:7362 with SMTP id p8-20020a05600c468800b0040535bf7362mr113965wmo.0.1696250964910; Mon, 02 Oct 2023 05:49:24 -0700 (PDT) MIME-Version: 1.0 References: <20230922111247.497-1-ansuelsmth@gmail.com> <65181064.050a0220.7887c.c7ee@mx.google.com> <651ab7b8.050a0220.e15ed.9d6a@mx.google.com> <651abb07.050a0220.5435c.9eae@mx.google.com> In-Reply-To: <651abb07.050a0220.5435c.9eae@mx.google.com> From: Eric Dumazet Date: Mon, 2 Oct 2023 14:49:11 +0200 Message-ID: Subject: Re: [net-next PATCH 1/3] net: introduce napi_is_scheduled helper To: Christian Marangi Cc: Vincent Whitchurch , Raju Rangoju , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Ping-Ke Shih , Kalle Valo , Simon Horman , Daniel Borkmann , Jiri Pirko , Hangbin Liu , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@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=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 02 Oct 2023 05:50:14 -0700 (PDT) On Mon, Oct 2, 2023 at 2:43=E2=80=AFPM Christian Marangi wrote: > > On Mon, Oct 02, 2023 at 02:35:22PM +0200, Eric Dumazet wrote: > > On Mon, Oct 2, 2023 at 2:29=E2=80=AFPM Christian Marangi wrote: > > > > > Ehhh the idea here was to reduce code duplication since the very same > > > test will be done in stmmac. So I guess this code cleanup is a NACK a= nd > > > I have to duplicate the test in the stmmac driver. > > > > I simply wanted to add a comment in front of this function/helper, > > advising not using it unless absolutely needed. > > > > Thus my question "In which context is it safe to call this helper ?" > > > > As long as it was private with a driver, I did not mind. > > > > But if made public in include/linux/netdevice.h, I would rather not > > have to explain > > to future users why it can be problematic. > > Oh ok! > > We have plenty of case similar to this. (example some clock API very > internal that should not be used normally or regmap related) > > I will include some comments warning that this should not be used in > normal circumstances and other warnings. If you have suggestion on what > to add feel free to write them. > > Any clue on how to proceed with the sge driver? > I would remove use of this helper for something with no race ? Feel free to submit this : (Alternative would be to change napi_schedule() to return a boolean) diff --git a/drivers/net/ethernet/chelsio/cxgb3/sge.c b/drivers/net/ethernet/chelsio/cxgb3/sge.c index 2e9a74fe0970df333226b80af8716f30865c01b7..09d0e6aa4db982e3488e0c28bed= 33e83453801d0 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb3/sge.c @@ -2501,14 +2501,6 @@ static int napi_rx_handler(struct napi_struct *napi, int budget) return work_done; } -/* - * Returns true if the device is already scheduled for polling. - */ -static inline int napi_is_scheduled(struct napi_struct *napi) -{ - return test_bit(NAPI_STATE_SCHED, &napi->state); -} - /** * process_pure_responses - process pure responses from a response que= ue * @adap: the adapter @@ -2674,9 +2666,9 @@ static int rspq_check_napi(struct sge_qset *qs) { struct sge_rspq *q =3D &qs->rspq; - if (!napi_is_scheduled(&qs->napi) && - is_new_response(&q->desc[q->cidx], q)) { - napi_schedule(&qs->napi); + if (is_new_response(&q->desc[q->cidx], q) && + napi_schedule_prep(&qs->napi)) { + __napi_schedule(&qs->napi); return 1; } return 0;