Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2001620ybi; Thu, 4 Jul 2019 03:31:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6O/Os7Xt1rO0AFh36hxCtax5vwl95aEwm6Q1pOJXESQU0qAY0rhmG6DQJwiOiT+6cV2BL X-Received: by 2002:a63:4a51:: with SMTP id j17mr6512106pgl.284.1562236301311; Thu, 04 Jul 2019 03:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562236301; cv=none; d=google.com; s=arc-20160816; b=bExc3+fL3G/fXTBnpadb+e+UYXO2RAfxKvAxc/LeYT+cmze0+AWp07mdSRXtGB+spO zFKiW1MfH14/gvZaoKg8xG4KD5bCGbP0TmYBt1+STjsIC7bGTDJurpwBA0NAwjPBKPkx ovPm26d5EWcCqqbGCxMZZFuZNzlWzbhLkQMV0/oPzwqA4Tt4ifISU/AnE0R23sGxb5fL RdsSf07fUUhov8p+1OL8yMEWjfexYNNtohjcAkwm20Xg0TEuTzA7tmGJ3Sh41NiX++Qb fW4pbTIo11I35zg65A7jQH4qcIvAGM2OipbB3BprxecCX0pac1ILCTrPqrHiCyTHYRw7 sivA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vfNfNOecUkgsCK5iRU+RHp5HzJkwACPrVEZHclgWgQw=; b=FSasL7forrWK3p7IdMAjj/GX52+KQG6M51fk0KmPFYYkMC4Id39JCcy0ilJKfs7QK5 N/5aem5vqcpHF6z/HML2LmpDBOeOAJmkL4l57YI1d93NGEmfdL7E4fr126QI+nNhkcBy LM3HQ13bfpGW3iwPhU5Vbzia1steLSbjLbigJYncGxegLCxCAzqXDVmlZ+FRcnipHRTm GK4UI0tVePpKTRMdOFaR00VKAZiQfLe0vKIQxy37aKkdRy5+PFdUpPk+apgpy+P+bIni VlCxnxSgSwUuXGpKxDdPQ41+QvoFmbvj7BGa58n7tmitkyu3o31KYHEC9ns3a94QJysm Pq5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FVKkQerj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j66si4755540plb.375.2019.07.04.03.31.24; Thu, 04 Jul 2019 03:31:41 -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; dkim=pass header.i=@linaro.org header.s=google header.b=FVKkQerj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727517AbfGDKbE (ORCPT + 99 others); Thu, 4 Jul 2019 06:31:04 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:35154 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727403AbfGDKbD (ORCPT ); Thu, 4 Jul 2019 06:31:03 -0400 Received: by mail-wr1-f68.google.com with SMTP id c27so6080191wrb.2 for ; Thu, 04 Jul 2019 03:31:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=vfNfNOecUkgsCK5iRU+RHp5HzJkwACPrVEZHclgWgQw=; b=FVKkQerj/tMYlojr2Q5WpayQ+ByGFY3Q0bQtVLvJKEM1f46amoOo4TzfdoVLbfpGFq auEpc18Ed67ELqkaR3F4F29TioKOp/61uAHgb0KbVLNJAxbS4ihHPUdgj72YJsYh7VYN 2YsD/Dr+6AT5Bc9ROI6C7GZeZcrtaOcW8tGXoeLQsvpXeo3w+YXmXKQMuvtcn6UNyvAW OtKUgoPW4socc1x5F5+1yvX4S+ZxiEX6RSZ+WoIYjsc/tR9U2HM6g6cpB0b2tBB3yiiy vGJ/S/IVFtqZEVsIwglpjE1jcjwuZS9V6cxvvV6qGnTcPUmWaDcRLQjnKyvS0O+avSWa Lrew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=vfNfNOecUkgsCK5iRU+RHp5HzJkwACPrVEZHclgWgQw=; b=oD2mu8HophWHOPoww9vErxflkKewFDSIEdt0U0BnkeVbVO4u43mkP+wPPe3gZsy9QF OCqGu5AWWpbF9FXWCAiROrp0GG4Bim/EGlJMC2UgcFaNeti2yryN7JqmfJHGIXlEfZcK rme8reO/FvdWBsgsbeHiztgd+8UVrlu7M8gOqNkHyD16yeiUSKllB0MKSYiMhp1J6xsS XoOnOBFmt3SIB5NtrI+7oTi1bsLntiR5+w15x5Se7EVXA9QOvzhUIyCUbGIrkI42dJTy pJ9vvbJ3CQfvegF9XF6MwdagO89q9FmKx/1IflPVoZl0EW2VXcDza6u9rpCK4uFa3d6e g0rg== X-Gm-Message-State: APjAAAXXzIAZuGwxIgbiH3IBxFg30P/ip3AIvEy62qjzRbFMqYZKA8ry MBdomZY36Hsd07o1yWODmx1yGA== X-Received: by 2002:a5d:5186:: with SMTP id k6mr35965127wrv.30.1562236261279; Thu, 04 Jul 2019 03:31:01 -0700 (PDT) Received: from apalos (athedsl-428434.home.otenet.gr. [79.131.225.144]) by smtp.gmail.com with ESMTPSA id k63sm6177278wmb.2.2019.07.04.03.30.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2019 03:31:00 -0700 (PDT) Date: Thu, 4 Jul 2019 13:30:57 +0300 From: Ilias Apalodimas To: Jesper Dangaard Brouer Cc: Jose Abreu , 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 Subject: Re: [PATCH net-next 3/3] net: stmmac: Introducing support for Page Pool Message-ID: <20190704103057.GA29734@apalos> References: <1b254bb7fc6044c5e6e2fdd9e00088d1d13a808b.1562149883.git.joabreu@synopsys.com> <20190704120018.4523a119@carbon> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190704120018.4523a119@carbon> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org HI Jesper, Ivan, > On Wed, 3 Jul 2019 12:37:50 +0200 > Jose Abreu wrote: > > > @@ -3547,6 +3456,9 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) > > > > napi_gro_receive(&ch->rx_napi, skb); > > > > + page_pool_recycle_direct(rx_q->page_pool, buf->page); > > This doesn't look correct. > > 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). > > You will have to call: > page_pool_release_page(rx_q->page_pool, buf->page); > > This will do a DMA-unmap, and you will likely loose your performance > gain :-( > > > > + buf->page = NULL; > > + > > priv->dev->stats.rx_packets++; > > priv->dev->stats.rx_bytes += frame_len; > > } > > 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). On our case (and in the page_pool API in general) you have to track buffers when both .ndo_xdp_xmit() and XDP_TX are used. So the lifetime of a packet might be 1. page pool allocs packet. The API doesn't sync but i *think* you don't have to explicitly since the CPU won't touch that buffer until the NAPI handler kicks in. On the napi handler you need to dma_sync_single_for_cpu() and process the packet. 2a) no XDP is required so the packet is unmapped and free'd 2b) .ndo_xdp_xmit is called so tyhe buffer need to be mapped/unmapped 2c) XDP_TX is called. In that case we re-use an Rx buffer so we need to dma_sync_single_for_device() 2a and 2b won't cause any issues In 2c the buffer will be recycled and fed back to the device with a *correct* sync (for_device) and all those buffers are allocated as DMA_BIDIRECTIONAL. So bvottom line i *think* we can skip the dma_sync_single_for_device() on the initial allocation *only*. If am terribly wrong please let me know :) Thanks /Ilias > > > [1] https://github.com/xdp-project/xdp-project/blob/master/areas/mem/page_pool02_SKB_return_callback.org > -- > Best regards, > Jesper Dangaard Brouer > MSc.CS, Principal Kernel Engineer at Red Hat > LinkedIn: http://www.linkedin.com/in/brouer