Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2080005ybi; Thu, 4 Jul 2019 04:56:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/zqLMnEr2i7FWX8w/CihuJzbu6El5IlAL6KI9xFnxkj6N8ydwKMaP5oXqwhjz/2vQ8/IE X-Received: by 2002:a63:f13:: with SMTP id e19mr2019077pgl.132.1562241403561; Thu, 04 Jul 2019 04:56:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562241403; cv=none; d=google.com; s=arc-20160816; b=omNeZkCwSve0qt8qpjeIeggU9dXNUs4PiAVQPs+thIV/Y9vKMzRnDKvb0Y3RFy0Xle JYr3EJLqVRoMH3KD4WjJTcboXjjP2nKo51lPduUDP9wJCOuDQjR5woxOrzPxuDA8VhXD bec5tdK2DQvL4/4mt26OwKl8LPnHPbQkN3R0YFKRcnsVEHNyWmE/WLP99/0wNdUzdZKZ zplZ0Dh2vy7OVKbnJjaLOIjCrBfozXKyg1ObSlzYTDshKcKJAlJKaa20sIpYbiJ6gnI1 CCuG5FPGaaWPs6k0SFMSltlZu9lY65shX5vn3k4QL9pCVMDu3D/3eZPZ8vYW95by/fVA zjvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=URuDE5yBlbG//pmYSKnjXJMzNebK5EPB3cs5bHAL3HE=; b=RAH9BEsu4DXiKDq3WLYoWfoFON036x1b+V7ZBEDxlRF5FQEL5XAVcPozGwgj6u5l20 bQOupAxvaIPBaPYN0eMCMheMXHIv3YECQ4QQfJ4a9VL83X65dku1DF67WA2OY6g+r4sa ODzjjyWzpFQqUMmwjXB85NVCPLy7irSAWB7qpAUkdXtrsMARkBklB5OZNEIRKtZ77N1b 7N3sfF+IMri7J3aqfb+c7LdoKdmwBttoegJvAk86eVYLFyAp/MIB9w7JTnwaljduyy5q UXXdw7CNJzf6w7BJyxMUxH+O6VFX1v8+hnYPf82zVLJtFQQSbQP9MvdfYvN+PSEPAo35 WFng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13si5747790pfo.59.2019.07.04.04.56.27; Thu, 04 Jul 2019 04:56:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727675AbfGDLy3 (ORCPT + 99 others); Thu, 4 Jul 2019 07:54:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32802 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727594AbfGDLy3 (ORCPT ); Thu, 4 Jul 2019 07:54:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 705D03083394; Thu, 4 Jul 2019 11:54:28 +0000 (UTC) Received: from carbon (ovpn-200-17.brq.redhat.com [10.40.200.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99A408E61A; Thu, 4 Jul 2019 11:54:15 +0000 (UTC) Date: Thu, 4 Jul 2019 13:54:14 +0200 From: Jesper Dangaard Brouer To: Jose Abreu Cc: "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-stm32@st-md-mailman.stormreply.com" , "linux-arm-kernel@lists.infradead.org" , Joao Pinto , "David S . Miller" , Giuseppe Cavallaro , Alexandre Torgue , Maxime Coquelin , Maxime Ripard , Chen-Yu Tsai , Ilias Apalodimas , brouer@redhat.com Subject: Re: [PATCH net-next 3/3] net: stmmac: Introducing support for Page Pool Message-ID: <20190704135414.0dd5df76@carbon> In-Reply-To: References: <1b254bb7fc6044c5e6e2fdd9e00088d1d13a808b.1562149883.git.joabreu@synopsys.com> <20190704120018.4523a119@carbon> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 04 Jul 2019 11:54:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 4 Jul 2019 10:13:37 +0000 Jose Abreu wrote: > From: Jesper Dangaard Brouer > > > The page_pool DMA mapping cannot be "kept" when page traveling into the > > network stack attached to an SKB. (Ilias and I have a long term plan[1] > > to allow this, but you cannot do it ATM). > > The reason I recycle the page is this previous call to: > > skb_copy_to_linear_data() > > So, technically, I'm syncing to CPU the page(s) and then memcpy to a > previously allocated SKB ... So it's safe to just recycle the mapping I > think. I didn't notice the skb_copy_to_linear_data(), will copy the entire frame, thus leaving the page unused and avail for recycle. Then it looks like you are doing the correct thing. I will appreciate if you could add a comment above the call like: /* Data payload copied into SKB, page ready for recycle */ page_pool_recycle_direct(rx_q->page_pool, buf->page); > Its kind of using bounce buffers and I do see performance gain in this > (I think the reason is because my setup uses swiotlb for DMA mapping). > > Anyway, I'm open to some suggestions on how to improve this ... I was surprised to see page_pool being used outside the surrounding XDP APIs (included/net/xdp.h). For you use-case, where you "just" use page_pool as a driver-local fast recycle-allocator for RX-ring that keeps pages DMA mapped, it does make a lot of sense. It simplifies the driver a fair amount: 3 files changed, 63 insertions(+), 144 deletions(-) Thanks for demonstrating a use-case for page_pool besides XDP, and for simplifying a driver with this. > > Also remember that the page_pool requires you driver to do the > > DMA-sync operation. I see a dma_sync_single_for_cpu(), but I > > didn't see a dma_sync_single_for_device() (well, I noticed one > > getting removed). (For some HW Ilias tells me that the > > dma_sync_single_for_device can be elided, so maybe this can still > > be correct for you). > > My HW just needs descriptors refilled which are in different coherent > region so I don't see any reason for dma_sync_single_for_device() ... For you use-case, given you are copying out the data, and not writing into it, then I don't think you need to do sync for device (before giving the device the page again for another RX-ring cycle). The way I understand the danger: if writing to the DMA memory region, and not doing the DMA-sync for-device, then the HW/coherency-system can write-back the memory later. Which creates a race with the DMA-device, if it is receiving a packet and is doing a write into same DMA memory region. Someone correct me if I misunderstood this... -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer