public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Alexei Starovoitov <ast@plumgrid•com>
To: Eric Dumazet <eric.dumazet@gmail•com>
Cc: "David S. Miller" <davem@davemloft•net>,
	Eric Dumazet <edumazet@google•com>,
	Daniel Borkmann <daniel@iogearbox•net>,
	Thomas Graf <tgraf@suug•ch>, Jamal Hadi Salim <jhs@mojatatu•com>,
	John Fastabend <john.r.fastabend@intel•com>,
	netdev@vger•kernel.org
Subject: Re: [PATCH RFC net-next] pktgen: introduce 'rx' mode
Date: Wed, 29 Apr 2015 16:59:49 -0700	[thread overview]
Message-ID: <55417075.9010601@plumgrid.com> (raw)
In-Reply-To: <1430350786.3711.77.camel@edumazet-glaptop2.roam.corp.google.com>

On 4/29/15 4:39 PM, Eric Dumazet wrote:
>
> Zap the 'burst/clone' thing, this is not going to work for RX.
> TX was okay, not RX.
>
> You could for instance do :
>
> atomic_inc(&skb->users);
> netif_receive_skb(skb);
> if (atomic_read(skb->users) != 1) {
> 	/* This is too bad, I can not recycle this skb because it is still used */
> 	consume_skb(skb);
> 	/* allocate a fresh new skb */
> 	skb = ...
> } else {
> 	/* Yeah ! Lets celebrate, cost of reusing this skb was one atomic op */
> }

ahh, great! I think I'm starting to understand.
then the following should be ok as well?

atomic_add(burst, &skb->users);
do {
    netif_receive_skb(skb);
    if (atomic_read(skb->users) != burst) {
  	/* too bad, can not recycle */
         atomic_sub(burst - 1, &skb->users);
  	consume_skb(skb);
  	/* allocate a fresh new skb */
  	skb = ...
         /* and get out of this loop */
    } else {
	/* Yeah ! the cost of reusing this skb was
            one atomic op amortized over 'burst' iterations */
    }
} while (--burst > 0);

  reply	other threads:[~2015-04-29 23:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-29  2:11 [PATCH RFC net-next] netif_receive_skb performance Alexei Starovoitov
2015-04-29  2:11 ` [PATCH RFC net-next] pktgen: introduce 'rx' mode Alexei Starovoitov
2015-04-29  4:14   ` Eric Dumazet
2015-04-29 21:55     ` Alexei Starovoitov
2015-04-29 22:19       ` Eric Dumazet
2015-04-29 22:38         ` Alexei Starovoitov
2015-04-29 22:56           ` Eric Dumazet
2015-04-29 23:28             ` Alexei Starovoitov
2015-04-29 23:39               ` Eric Dumazet
2015-04-29 23:59                 ` Alexei Starovoitov [this message]
2015-04-29  5:23 ` [PATCH RFC net-next] netif_receive_skb performance Eric Dumazet
2015-04-29 22:15   ` Alexei Starovoitov
2015-04-29  9:37 ` Daniel Borkmann
2015-04-29 22:20   ` Alexei Starovoitov

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=55417075.9010601@plumgrid.com \
    --to=ast@plumgrid$(echo .)com \
    --cc=daniel@iogearbox$(echo .)net \
    --cc=davem@davemloft$(echo .)net \
    --cc=edumazet@google$(echo .)com \
    --cc=eric.dumazet@gmail$(echo .)com \
    --cc=jhs@mojatatu$(echo .)com \
    --cc=john.r.fastabend@intel$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=tgraf@suug$(echo .)ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox