Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3556574pxu; Tue, 8 Dec 2020 15:32:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5JSS15PSxO37epl3L7ZmDBnAiNkhiTBgtOi9ENWh9QXgiRLLzuvsz8l+fG6VmpeW6vFVE X-Received: by 2002:a17:906:ce3c:: with SMTP id sd28mr38675ejb.485.1607470343476; Tue, 08 Dec 2020 15:32:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607470343; cv=none; d=google.com; s=arc-20160816; b=YK550Qkj2PuSZDKIKyqj8pRLmAOC6S3TqDPfqRYjYtlXNeaYag+d5GYkp7Ntf5VbQW c/XAwg1QgYZz5dCdoW5nKfGe1BIWU/QM8Kh1SLAEH4l/JgmafDY9TQbuqywSD/jijI22 L1heFaP3aR9pU66LHXUuAHnrM50fMcjc3S6Y0suR6UGw8VTAwjh1+mnu/WZ43ZIN+YN/ holAHnfhywskuflNLhJCUzg1e8005D5rCYXPFXqwmaWpcO+5UeibQxcwmkt+9H2UF7za WnNB2og21f/yYS6afwe00EqvWeQNDsATVRhFZ6rIiosCi2K6Z060xVT6LhX4fLfDu7+F 4ziQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:dkim-signature :date; bh=1yUIeDvJ4ICf4Ar3yC1ZVoq2nuD+rc5Q6UjJMADoPqM=; b=b1Vons6qoHFpOukC0kcdvVFTeK+Gp3kd6Yo1SQWGaUvdmuKoSIGo2OsryQyJkDOZlY fPNUyaPJeh3/uOuijz+ld4VO7CpAC2fZaV0TTRGqB/6rhkkrdVcjdDei6jFc/SujjF3i JFMCT92Q5eESaENMY4HaGY88N9XULreWbBx+fToq0Nl9aTCIcgty+cHkVjFJ4uLGUuyU fswxvH3tmNj8y8yaeExubx045ZG5POQ3Zg1FXRorH02gSRDywSUm88YTr9sIUWgsa19x v4bFiTg+oikxrfYTvLRKm7y1vEffQEx3fF/7Cc17azn3HOJbvSZWNx31W9xBDVjIoxPV FgtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iiZ+qqjv; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q4si3552150eji.447.2020.12.08.15.32.00; Tue, 08 Dec 2020 15:32:23 -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=@kernel.org header.s=k20201202 header.b=iiZ+qqjv; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731719AbgLHXaa (ORCPT + 99 others); Tue, 8 Dec 2020 18:30:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:56442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbgLHXaa (ORCPT ); Tue, 8 Dec 2020 18:30:30 -0500 Date: Tue, 8 Dec 2020 15:29:48 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607470190; bh=WgVApkYVoKhoTRwTRt6e7T2tWvuWR7kTKpTqXuuxxg4=; h=From:To:Cc:Subject:In-Reply-To:References:From; b=iiZ+qqjv7e9/5krZWYNYd7SFRCQswxLmzz8oBYlNM+T8rXi4hoTq/ivCbjxK7iFIx ASdchJuMgv8wr3vq13A5Nh2gwdsrTdXiUkr916DuHKKZ/v7LdUIG6vbzDLU5zW+3bP p3BWxV6sNs9Y1g57AUxoJuoIuWwEjey+alR2xCWrZPzSBzEDzM5Idhn0wFozmCz1Bd FMdm+IX/dozpKWg/2rD8lqsFFb4ROcvu1MhCglmsvTrjAvfQVj49z8xf5JG0PkwVDi RsPU6AnLJjhCdpebcgooXzrhCfTjOfSip/9Hnvma/zP4H0UzTg2hpuq5k5fz8vQYDw 8QCGPBP8WKmNA== From: Jakub Kicinski To: Sven Van Asbroeck Cc: Bryan Whitehead , Microchip Linux Driver Support , David S Miller , Andrew Lunn , netdev , Linux Kernel Mailing List , Eric Dumazet Subject: Re: [PATCH net v1 1/2] lan743x: improve performance: fix rx_napi_poll/interrupt ping-pong Message-ID: <20201208152948.006606b3@kicinski-fedora-pc1c0hjn.DHCP.thefacebook.com> In-Reply-To: References: <20201206034408.31492-1-TheSven73@gmail.com> <20201208115035.74221c31@kicinski-fedora-pc1c0hjn.DHCP.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 8 Dec 2020 17:23:08 -0500 Sven Van Asbroeck wrote: > 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. Perhaps 16 for a device with 64 descriptors is rather high indeed. Let's say 8. If the device misses 8 packet buffers on the ring, that should be negligible. Depends on the cost of the CSR write, usually packet processing is putting a lot of pressure on the memory subsystem of the CPU, hence amortizing the write over multiple descriptors helps. The other thing is that you could delay the descriptor writes to write full cache lines, but I don't think that will help on IMX6. > 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. There is a tracepoint which records how many packets NAPI has polled: napi:napi_poll, you can see easily what your system is doing. What you want to avoid is the situation where the device already used up all the descriptors by the time driver finishes the Rx processing. That'd result in drops. So the driver should push the buffers back to the device reasonably early. With a ring of 64 descriptors and NAPI budget of 64 it's not unlikely that the ring will be completely used when processing runs. > > > + /* 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. Interesting I don't think we ever had this problem before. Let me CC Eric to see if he has any thoughts on the case. AFAIU you should think of the weight as way of arbitrating between devices (if there is more than one). NAPI does not do any deferral (in wall clock time terms) of processing, so the only difference you may get for lower weight is that softirq kthread will get a chance to kick in earlier. > Would it be better to fix the weight counting? Increase the count > for every buffer consumed, instead of for every skb pushed?