All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Aaron Lu <aaron.lu@intel.com>
Cc: Saeed Mahameed <saeedm@mellanox.com>,
	"pstaszewski@itcare.pl" <pstaszewski@itcare.pl>,
	"eric.dumazet@gmail.com" <eric.dumazet@gmail.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Tariq Toukan <tariqt@mellanox.com>,
	"ilias.apalodimas@linaro.org" <ilias.apalodimas@linaro.org>,
	"yoel@kviknet.dk" <yoel@kviknet.dk>,
	"mgorman@techsingularity.net" <mgorman@techsingularity.net>,
	brouer@redhat.com
Subject: Re: Kernel 4.19 network performance - forwarding/routing normal users traffic
Date: Fri, 2 Nov 2018 12:40:37 +0100	[thread overview]
Message-ID: <20181102124037.352b15de@redhat.com> (raw)
In-Reply-To: <20181102052356.GA17587@intel.com>

On Fri, 2 Nov 2018 13:23:56 +0800
Aaron Lu <aaron.lu@intel.com> wrote:

> On Thu, Nov 01, 2018 at 08:23:19PM +0000, Saeed Mahameed wrote:
> > On Thu, 2018-11-01 at 23:27 +0800, Aaron Lu wrote:  
> > > On Thu, Nov 01, 2018 at 10:22:13AM +0100, Jesper Dangaard Brouer
> > > wrote:
> > > ... ...  
> > > > Section copied out:
> > > > 
> > > >   mlx5e_poll_tx_cq
> > > >   |          
> > > >    --16.34%--napi_consume_skb
> > > >              |          
> > > >              |--12.65%--__free_pages_ok
> > > >              |          |          
> > > >              |           --11.86%--free_one_page
> > > >              |                     |          
> > > >              |                     |--10.10%
> > > > --queued_spin_lock_slowpath
> > > >              |                     |          
> > > >              |                      --0.65%--_raw_spin_lock  
> > > 
> > > This callchain looks like it is freeing higher order pages than order
> > > 0:
> > > __free_pages_ok is only called for pages whose order are bigger than
> > > 0.  
> > 
> > mlx5 rx uses only order 0 pages, so i don't know where these high order
> > tx SKBs are coming from..   
> 
> Perhaps here:
> __netdev_alloc_skb(), __napi_alloc_skb(), __netdev_alloc_frag() and
> __napi_alloc_frag() will all call page_frag_alloc(), which will use
> __page_frag_cache_refill() to get an order 3 page if possible, or fall
> back to an order 0 page if order 3 page is not available.
> 
> I'm not sure if your workload will use the above code path though.

TL;DR: this is order-0 pages (code-walk trough proof below)

To Aaron, the network stack *can* call __free_pages_ok() with order-0
pages, via:

static void skb_free_head(struct sk_buff *skb)
{
	unsigned char *head = skb->head;

	if (skb->head_frag)
		skb_free_frag(head);
	else
		kfree(head);
}

static inline void skb_free_frag(void *addr)
{
	page_frag_free(addr);
}

/*
 * Frees a page fragment allocated out of either a compound or order 0 page.
 */
void page_frag_free(void *addr)
{
	struct page *page = virt_to_head_page(addr);

	if (unlikely(put_page_testzero(page)))
		__free_pages_ok(page, compound_order(page));
}
EXPORT_SYMBOL(page_frag_free);


Notice for the mlx5 driver it support several RX-memory models, so it
can be hard to follow, but from the perf report output we can see that
is uses mlx5e_skb_from_cqe_linear, which use build_skb.

--13.63%--mlx5e_skb_from_cqe_linear
          |          
           --5.02%--build_skb
                     |          
                      --1.85%--__build_skb
                                |          
                                 --1.00%--kmem_cache_alloc

/* build_skb() is wrapper over __build_skb(), that specifically
 * takes care of skb->head and skb->pfmemalloc
 * This means that if @frag_size is not zero, then @data must be backed
 * by a page fragment, not kmalloc() or vmalloc()
 */
struct sk_buff *build_skb(void *data, unsigned int frag_size)
{
	struct sk_buff *skb = __build_skb(data, frag_size);

	if (skb && frag_size) {
		skb->head_frag = 1;
		if (page_is_pfmemalloc(virt_to_head_page(data)))
			skb->pfmemalloc = 1;
	}
	return skb;
}
EXPORT_SYMBOL(build_skb);

It still doesn't prove, that the @data is backed by by a order-0 page.
For the mlx5 driver is uses mlx5e_page_alloc_mapped ->
page_pool_dev_alloc_pages(), and I can see perf report using
__page_pool_alloc_pages_slow().

The setup for page_pool in mlx5 uses order=0.

	/* Create a page_pool and register it with rxq */
	pp_params.order     = 0;
	pp_params.flags     = 0; /* No-internal DMA mapping in page_pool */
	pp_params.pool_size = pool_size;
	pp_params.nid       = cpu_to_node(c->cpu);
	pp_params.dev       = c->pdev;
	pp_params.dma_dir   = rq->buff.map_dir;

	/* page_pool can be used even when there is no rq->xdp_prog,
	 * given page_pool does not handle DMA mapping there is no
	 * required state to clear. And page_pool gracefully handle
	 * elevated refcnt.
	 */
	rq->page_pool = page_pool_create(&pp_params);
	if (IS_ERR(rq->page_pool)) {
		err = PTR_ERR(rq->page_pool);
		rq->page_pool = NULL;
		goto err_free;
	}
	err = xdp_rxq_info_reg_mem_model(&rq->xdp_rxq,
					 MEM_TYPE_PAGE_POOL, rq->page_pool);

 
-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

  reply	other threads:[~2018-11-02 20:47 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-31 21:57 Kernel 4.19 network performance - forwarding/routing normal users traffic Paweł Staszewski
2018-10-31 22:09 ` Eric Dumazet
2018-10-31 22:20   ` Paweł Staszewski
2018-10-31 22:45     ` Paweł Staszewski
2018-11-01  9:22     ` Jesper Dangaard Brouer
2018-11-01 10:34       ` Paweł Staszewski
2018-11-01 15:27       ` Aaron Lu
2018-11-01 20:23         ` Saeed Mahameed
2018-11-02  5:23           ` Aaron Lu
2018-11-02 11:40             ` Jesper Dangaard Brouer [this message]
2018-11-02 14:20               ` Aaron Lu
2018-11-02 19:02                 ` Paweł Staszewski
2018-11-03  0:16                   ` Paweł Staszewski
2018-11-03 12:01                     ` Paweł Staszewski
2018-11-03 12:58                     ` Jesper Dangaard Brouer
2018-11-03 15:23                       ` Paweł Staszewski
2018-11-03 15:43                         ` Paweł Staszewski
2018-11-03 12:53                 ` Jesper Dangaard Brouer
2018-11-05  6:28                   ` Aaron Lu
2018-11-05  9:10                     ` Jesper Dangaard Brouer
2018-11-05  8:42                   ` Tariq Toukan
2018-11-05  8:48                     ` Aaron Lu
2018-11-01  3:37 ` David Ahern
2018-11-01 10:55   ` Jesper Dangaard Brouer
2018-11-01 13:52     ` Paweł Staszewski
2018-11-01 17:23       ` David Ahern
2018-11-01 17:30         ` Paweł Staszewski
2018-11-03 17:32           ` David Ahern
2018-11-04  0:24             ` Paweł Staszewski
2018-11-05 20:17               ` Jesper Dangaard Brouer
2018-11-08  0:59                 ` Paweł Staszewski
2018-11-08  1:13                   ` Paweł Staszewski
2018-11-08 14:43                   ` Paweł Staszewski
2018-11-07 21:06               ` David Ahern
2018-11-08 13:33                 ` Paweł Staszewski
2018-11-08 16:06                   ` David Ahern
2018-11-08 16:25                     ` Paweł Staszewski
2018-11-08 16:27                       ` Paweł Staszewski
2018-11-08 16:32                         ` David Ahern
2018-11-08 17:30                           ` Paweł Staszewski
2018-11-08 18:05                             ` David Ahern
2018-11-09  0:40                           ` Paweł Staszewski
2018-11-09  0:42                             ` David Ahern
2018-11-09  4:52                               ` Saeed Mahameed
2018-11-09  7:52                                 ` Jesper Dangaard Brouer
2018-11-09  9:56                                 ` Paweł Staszewski
2018-11-09 10:20                     ` Paweł Staszewski
2018-11-09 16:21                       ` David Ahern
2018-11-09 19:59                         ` Paweł Staszewski
2018-11-10  0:06                         ` David Ahern
2018-11-10 13:18                           ` Paweł Staszewski
2018-11-10 14:56                             ` David Ahern
2018-11-19 21:59                           ` David Ahern
2018-11-20 23:00                             ` Paweł Staszewski
2018-11-01  9:50 ` Saeed Mahameed
2018-11-01 11:09   ` Paweł Staszewski
2018-11-01 16:49     ` Paweł Staszewski
2018-11-01 20:37     ` Saeed Mahameed
2018-11-01 21:18       ` Paweł Staszewski
2018-11-01 21:24         ` Paweł Staszewski
2018-11-01 21:34           ` Paweł Staszewski
2018-11-03  0:18       ` Paweł Staszewski
2018-11-08 19:12         ` Paweł Staszewski
2018-11-09 22:20           ` Paweł Staszewski
2018-11-10 19:34             ` Jesper Dangaard Brouer
2018-11-10 19:49               ` Paweł Staszewski
2018-11-10 19:56                 ` Paweł Staszewski
2018-11-10 22:06                   ` Jesper Dangaard Brouer
2018-11-10 22:19                     ` Paweł Staszewski
2018-11-11  8:03                       ` Jesper Dangaard Brouer
2018-11-11 10:26                         ` Paweł Staszewski
2018-11-10 20:02               ` Paweł Staszewski
2018-11-10 21:01                 ` Jesper Dangaard Brouer
2018-11-10 21:53                   ` Paweł Staszewski
2018-11-10 22:04                     ` Paweł Staszewski
2018-11-11  8:56                     ` Jesper Dangaard Brouer
2018-11-12 19:19                       ` Paweł Staszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181102124037.352b15de@redhat.com \
    --to=brouer@redhat.com \
    --cc=aaron.lu@intel.com \
    --cc=eric.dumazet@gmail.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=mgorman@techsingularity.net \
    --cc=netdev@vger.kernel.org \
    --cc=pstaszewski@itcare.pl \
    --cc=saeedm@mellanox.com \
    --cc=tariqt@mellanox.com \
    --cc=yoel@kviknet.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.