All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olivier Deme <odeme-UsMDwKmwmRBx67MzidHQgQC/G2K4zDHf@public.gmane.org>
To: dev-VfR2kkLFssw@public.gmane.org
Subject: Re: [PATCH] kni:optimization of rte_kni_rx_burst
Date: Wed, 25 Feb 2015 12:13:42 +0000	[thread overview]
Message-ID: <54EDBC76.2050507@druidsoftware.com> (raw)
In-Reply-To: <14248648813214-git-send-email-Hemant-KZfg59tc24xl57MIdRCFDg@public.gmane.org>

Thank you Hemant, I think there might be one issue left with the patch 
though.
The alloc_q must initially be filled with mbufs before getting mbuf back 
on the tx_q.

So the patch should allow rte_kni_rx_burst to check if alloc_q is empty.
If so, it should invoke kni_allocate_mbufs(kni, 0)
(to fill the alloc_q with MAX_MBUF_BURST_NUM mbufs)

The patch for rte_kni_rx_burst would then look like:

@@ -575,7 +575,7 @@ rte_kni_rx_burst(struct rte_kni *kni, struct 
rte_mbuf **mbufs, unsigned num)

      /* If buffers removed, allocate mbufs and then put them into 
alloc_q */
      if (ret)
-        kni_allocate_mbufs(kni);
+      kni_allocate_mbufs(kni, ret);
+  else if (unlikely(kni->alloc_q->write == kni->alloc_q->read))
+      kni_allocate_mbufs(kni, 0);


Olivier.

On 25/02/15 11:48, Hemant Agrawal wrote:
> From: Hemant Agrawal <hemant-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>
> if any buffer is read from the tx_q, MAX_BURST buffers will be allocated and attempted to be added to to the alloc_q.
> This seems terribly inefficient and it also looks like the alloc_q will quickly fill to its maximum capacity. If the system buffers are low in number, it will reach "out of memory" situation.
>
> This patch allocates the number of buffers as many dequeued from tx_q.
>
> Signed-off-by: Hemant Agrawal <hemant-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> ---
>   lib/librte_kni/rte_kni.c | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
> index 4e70fa0..4cf8e30 100644
> --- a/lib/librte_kni/rte_kni.c
> +++ b/lib/librte_kni/rte_kni.c
> @@ -128,7 +128,7 @@ struct rte_kni_memzone_pool {
>   
>   
>   static void kni_free_mbufs(struct rte_kni *kni);
> -static void kni_allocate_mbufs(struct rte_kni *kni);
> +static void kni_allocate_mbufs(struct rte_kni *kni, int num);
>   
>   static volatile int kni_fd = -1;
>   static struct rte_kni_memzone_pool kni_memzone_pool = {
> @@ -575,7 +575,7 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned num)
>   
>   	/* If buffers removed, allocate mbufs and then put them into alloc_q */
>   	if (ret)
> -		kni_allocate_mbufs(kni);
> +		kni_allocate_mbufs(kni, ret);
>   
>   	return ret;
>   }
> @@ -594,7 +594,7 @@ kni_free_mbufs(struct rte_kni *kni)
>   }
>   
>   static void
> -kni_allocate_mbufs(struct rte_kni *kni)
> +kni_allocate_mbufs(struct rte_kni *kni, int num)
>   {
>   	int i, ret;
>   	struct rte_mbuf *pkts[MAX_MBUF_BURST_NUM];
> @@ -620,7 +620,10 @@ kni_allocate_mbufs(struct rte_kni *kni)
>   		return;
>   	}
>   
> -	for (i = 0; i < MAX_MBUF_BURST_NUM; i++) {
> +	if (num == 0 || num > MAX_MBUF_BURST_NUM)
> +		num = MAX_MBUF_BURST_NUM;
> +
> +	for (i = 0; i < num; i++) {
>   		pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool);
>   		if (unlikely(pkts[i] == NULL)) {
>   			/* Out of memory */
> @@ -636,7 +639,7 @@ kni_allocate_mbufs(struct rte_kni *kni)
>   	ret = kni_fifo_put(kni->alloc_q, (void **)pkts, i);
>   
>   	/* Check if any mbufs not put into alloc_q, and then free them */
> -	if (ret >= 0 && ret < i && ret < MAX_MBUF_BURST_NUM) {MAX_MBUF_BURST_NUM
>
> +	if (ret >= 0 && ret < i && ret < num) {
>   		int j;
>   
>   		for (j = ret; j < i; j++)

-- 
	*Olivier Demé*
*Druid Software Ltd.*
*Tel: +353 1 202 1831*
*Email: odeme-UsMDwKmwmRBx67MzidHQgQC/G2K4zDHf@public.gmane.org <mailto:odeme-UsMDwKmwmRBx67MzidHQgQC/G2K4zDHf@public.gmane.org>*
*URL: http://www.druidsoftware.com*
	*Hall 7, stand 7F70.*
Druid Software: Monetising enterprise small cells solutions.

  parent reply	other threads:[~2015-02-25 12:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-25 11:48 [PATCH] kni:optimization of rte_kni_rx_burst Hemant Agrawal
     [not found] ` <14248648813214-git-send-email-Hemant-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-02-25 12:13   ` Olivier Deme [this message]
     [not found]     ` <54EDBC76.2050507-UsMDwKmwmRBx67MzidHQgQC/G2K4zDHf@public.gmane.org>
2015-02-25 12:24       ` Hemant-KZfg59tc24xl57MIdRCFDg
     [not found]         ` <BY2PR0301MB069369AA0C7436E5F9A63AE9C2170-swgC6WJTr6E3qekZfdyv35wN6zqB+hSMnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2015-02-25 12:28           ` Olivier Deme
2015-02-25 12:38           ` Marc Sune
     [not found]             ` <54EDC23A.2080302-kpkqNMk1I7M@public.gmane.org>
2015-02-25 12:51               ` Olivier Deme
2015-02-25 13:29               ` Jay Rolette
     [not found]                 ` <CADNuJVqw4hBD1kk1Y4A2+8-5yi0A0K9_5zBQaO3zOnnwXC0nog-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-02-26  7:00                   ` Hemant-KZfg59tc24xl57MIdRCFDg
     [not found]                     ` <BY2PR0301MB06939B503E040A8173F21408C2140-swgC6WJTr6E3qekZfdyv35wN6zqB+hSMnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2015-02-26 12:56                       ` Marc Sune

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=54EDBC76.2050507@druidsoftware.com \
    --to=odeme-usmdwkmwmrbx67mzidhqgqc/g2k4zdhf@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    /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.