Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3520950pxu; Tue, 8 Dec 2020 14:27:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJy7Tz26kQGyb9Tj5z0oy0O8kDzgI50n37x2Nhhf3JXUFzMW/EoycyHV2g7FsiKDjuVsbJto X-Received: by 2002:a17:906:4982:: with SMTP id p2mr24736411eju.416.1607466471566; Tue, 08 Dec 2020 14:27:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607466471; cv=none; d=google.com; s=arc-20160816; b=CkOD3jHMqVMFL/aROsA9A7J0GdTMYxKoE/uJBshsmgzRXz9ZLmIDDhlUKyZ/GlRzZL WLP5o1hUnsKKub4vE7Kz6d4GFsiR0iR4wbO4Aa8tQuPrc1/9Dm8tC4TNn86ZLICt+RsC ZEpC/VuOe0R7fZe6eUdgqA8z3j7YOp8weivex3UyO5dR1d43Hjn8xHELRpgOxNYR34nN M9s6Tu0gQedAJF6y7laMxwrAsjYMNXQ09Rss2VxxnKCpkjbOgm77lsfoegi1wDi8gdIn K7gaqIdvCDhn/+W+h7A/cVkilLEwQF7GRkzzL33ygXcr8adDvLdYfK0Melp9Xw1jqhKD FIFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=N7VdFbyyCDi1uq6j0l/SA3U8jgEM1OrggvkOS/Hf/OQ=; b=TIbtJgbBnJlLWR4D4JAoy91JsWrdFFIUMnNp5pUBD61RvP4+cEmKwNJxSY/qN+LsnL qcePbkAuJjp7AgiadmaEp33AZVnmuuPDFRpKORjhS0ymvPOjCwb6t+XOPr6O8ZSSkaNQ kuzlkbOqqUdZvTtzaGMo5Stn1OKJSOLLgnMezYtdYc41+96VBeh38PycqgHH6XQafwmq NTIPI79zYOnIii5KlXSM091tLvS/+D2Pll79QctUaO9GH+k04rHCGu2tjRyeX4lU2pCp cEQMXBtu2BaTyLc8H7IHli7xA6SPzsQ6jSOqpYGLpNxzacZAaWzPsmvH868hdnHnkjWC v3QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EJX+HvXF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn4si3155486ejc.519.2020.12.08.14.27.25; Tue, 08 Dec 2020 14:27:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EJX+HvXF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731222AbgLHWYF (ORCPT + 99 others); Tue, 8 Dec 2020 17:24:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730393AbgLHWYA (ORCPT ); Tue, 8 Dec 2020 17:24:00 -0500 Received: from mail-vs1-xe42.google.com (mail-vs1-xe42.google.com [IPv6:2607:f8b0:4864:20::e42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52126C061793; Tue, 8 Dec 2020 14:23:20 -0800 (PST) Received: by mail-vs1-xe42.google.com with SMTP id w18so10358154vsk.12; Tue, 08 Dec 2020 14:23:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=N7VdFbyyCDi1uq6j0l/SA3U8jgEM1OrggvkOS/Hf/OQ=; b=EJX+HvXFO17F1iSSmiS2Awhj83og4g6aSeHMNIgEz+7nD0GBW/qvdy4S8g9Sk71K4A eEXTVd0+IhSBCao77zjlBUkvyH8fRfFduW9Be9ebt0TxEr7KK+oWXv25c7ccsnvw1q2c l42cPgCKFY0jOcHm6YUhrWDnPux7+/eMmNAEzfC2/3IclhKk3wo5PCBcj9/kDMHuKWS/ 5FCdNokOSygirtN0CpRhVf7PlsPk6HI94VpOintTBoMG5wWFIErZtj72VPpz+XObceW/ DpwCJwmMMDY0nOkIz4py8psHU6jTyNBor+vJdx9MQNMUk89PAAgggmP4lx2oZRraQS/o T9AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=N7VdFbyyCDi1uq6j0l/SA3U8jgEM1OrggvkOS/Hf/OQ=; b=lIsTugO6ObzCVajItr3QX4XJB3G0qoY/3+OWkSchu1zmsJ83euukdS/30qAPHHZ5F5 FDxHHUnO9Ka9QRW0aWT8npxRGazm3WoFH28juCgtllBeQC7sZP2WHstBl27vxDTr7ejd 2NIcg7rMmCwlVRswmGGeGKH+KVGb0r2hoprvjcXlRdl8r0kiv9163ExTQPiM5s95IKq8 VOXRRK65Aa2nK6uPJlDQVpxW39/50guitCXZn8SjeFRwQKNNi6m0nhwaoArV/mRFNdlS FlVC1ZZjtVFWA71jz+E4GNeh3NZgAiRZcTKsYrOV6mjwbDBfOUVohh9jyDuyTJOcyyfM KlJA== X-Gm-Message-State: AOAM530OsykWEjCc2prkeScFQa1NPW2pISKREmTdvwwKkyhWWfDsE+L+ XmIE7SUPWTGAYQO83xzbjfwjxct+/rXCOU7712Qb3pA3/FTGjA== X-Received: by 2002:a67:d319:: with SMTP id a25mr8662985vsj.57.1607466199202; Tue, 08 Dec 2020 14:23:19 -0800 (PST) MIME-Version: 1.0 References: <20201206034408.31492-1-TheSven73@gmail.com> <20201208115035.74221c31@kicinski-fedora-pc1c0hjn.DHCP.thefacebook.com> In-Reply-To: <20201208115035.74221c31@kicinski-fedora-pc1c0hjn.DHCP.thefacebook.com> From: Sven Van Asbroeck Date: Tue, 8 Dec 2020 17:23:08 -0500 Message-ID: Subject: Re: [PATCH net v1 1/2] lan743x: improve performance: fix rx_napi_poll/interrupt ping-pong To: Jakub Kicinski Cc: Bryan Whitehead , Microchip Linux Driver Support , David S Miller , Andrew Lunn , netdev , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 8, 2020 at 2:50 PM Jakub Kicinski wrote: > > > > > +done: > > /* update RX_TAIL */ > > lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), > > rx_tail_flags | rx->last_tail); > > -done: > > + > > I assume this rings the doorbell to let the device know that more > buffers are available? If so it's a little unusual to do this at the > end of NAPI poll. The more usual place would be to do this every n > times a new buffer is allocated (in lan743x_rx_init_ring_element()?) > That's to say for example ring the doorbell every time a buffer is put > at an index divisible by 16. Yes, I believe it tells the device that new buffers have become available. I wonder why it's so unusual to do this at the end of a napi poll? Omitting this could result in sub-optimal use of buffers, right? Example: - tail is at position 0 - core calls napi_poll(weight=64) - napi poll consumes 15 buffers and pushes 15 skbs, then ring empty - index not divisible by 16, so tail is not updated - weight not reached, so napi poll re-enables interrupts and bails out Result: now there are 15 buffers which the device could potentially use, but because the tail wasn't updated, it doesn't know about them. It does make sense to update the tail more frequently than only at the end of the napi poll, though? I'm new to napi polling, so I'm quite interested to learn about this. > > > > + /* up to half of elements in a full rx ring are > > + * extension frames. these do not generate skbs. > > + * to prevent napi/interrupt ping-pong, limit default > > + * weight to the smallest no. of skbs that can be > > + * generated by a full rx ring. > > + */ > > netif_napi_add(adapter->netdev, > > &rx->napi, lan743x_rx_napi_poll, > > - rx->ring_size - 1); > > + (rx->ring_size - 1) / 2); > > This is rather unusual, drivers should generally pass NAPI_POLL_WEIGHT > here. I agree. The problem is that a full ring buffer of 64 buffers will only contain 32 buffers with network data - the others are timestamps. So napi_poll(weight=64) can never reach its full weight. Even with a full buffer, it always assumes that it has to stop polling, and re-enable interrupts, which results in a ping-pong. Would it be better to fix the weight counting? Increase the count for every buffer consumed, instead of for every skb pushed?