All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
	daniel@iogearbox.net, xiyou.wangcong@gmail.com
Subject: Re: [PATCH v3 net-next 1/1] net_sched: Introduce skbmod action
Date: Tue, 30 Aug 2016 05:20:28 -0700	[thread overview]
Message-ID: <1472559628.14381.283.camel@edumazet-glaptop3.roam.corp.google.com> (raw)
In-Reply-To: <2a6e36a6-f128-ba9d-4d69-90ff5383fb75@mojatatu.com>

On Tue, 2016-08-30 at 07:12 -0400, Jamal Hadi Salim wrote:
> On 16-08-29 02:20 PM, Eric Dumazet wrote:
> 
> >
> > You would need to store everything in an object, managed by rcu.
> >
> > struct my_rcu_safe_struct {
> >      u32 flags;
> >      u8   eth_dst[ETH_ALEN];
> >      u8   eth_src[ETH_ALEN];
> >      __be16 eth_type;
> > };
> >
> > And then allocate a new one when you need to update the infos (from
> > tcf_skbmod_init(())
> >
> > RCU : Read Copy Update.
> >
> > Then in the reader you would use
> >
> > rcu_read_lock();
> > myptr = rcu_dereference(d->ptr);
> > if (myptr) {
> >         if (myptr->flags & SKBMOD_F_DMAC)
> >                  ether_addr_copy(eth_hdr(skb)->h_dest, myptr->eth_dst);
> >          if (myptr->flags & SKBMOD_F_SMAC)
> >                  ether_addr_copy(eth_hdr(skb)->h_source, myptr->eth_src);
> >          if (myptr->flags & SKBMOD_F_ETYPE)
> >                  eth_hdr(skb)->h_proto = myptr->eth_type;
> > }
> > rcu_read_unlock();
> 
> Thanks Eric.
> This is the approach i thought Cong was going to take but in a way that
> it applies to all actions.
> It requires I do this extra allocation per update/create - I am not sure 
> how much of a big deal that is (we take pride in our update rate).
> Let me work and post something simple that captures these ideas
> then wait to see what Cong has in mind for the general approach.


The percpu stats infra is already there, you have to change
tcf_hash_create() last parameter to 'true'.

For example you have to add in struct my_rcu_safe_struct a 'struct
rcu_head rcu;'  field to be able to use kfree_rcu() instead of
synchronize_rcu()

Some very simple actions do not even need rcu_dereference()

RCU have many different variants.

Sometimes READ_ONCE() and WRITE_ONCE() are enough, when all the 'flags'
can be in a single integer, and this avoids an extra dereference and
possible cache miss.

      parent reply	other threads:[~2016-08-30 12:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-28 12:19 [PATCH v3 net-next 1/1] net_sched: Introduce skbmod action Jamal Hadi Salim
2016-08-28 14:48 ` Alexei Starovoitov
2016-08-29 10:35   ` Jamal Hadi Salim
2016-08-28 16:07 ` Eric Dumazet
2016-08-29  5:10   ` Cong Wang
2016-08-29 13:27     ` Eric Dumazet
2016-08-29 10:38   ` Jamal Hadi Salim
2016-08-29 11:00     ` Daniel Borkmann
2016-08-29 11:40       ` Jamal Hadi Salim
2016-08-29 11:55         ` Jamal Hadi Salim
2016-08-29 11:35     ` Jamal Hadi Salim
2016-08-29 18:20       ` Eric Dumazet
2016-08-30 11:12         ` Jamal Hadi Salim
2016-08-30 11:57           ` Jamal Hadi Salim
2016-08-30 12:35             ` Eric Dumazet
2016-09-06 12:03               ` Jamal Hadi Salim
2016-08-30 12:44             ` Eric Dumazet
2016-09-06 12:08               ` Jamal Hadi Salim
2016-09-06 14:25                 ` Eric Dumazet
2016-09-08 10:38                   ` Jamal Hadi Salim
2016-09-08 16:02                     ` Eric Dumazet
2016-09-08 16:11                       ` Eric Dumazet
2016-09-09 12:33                         ` Jamal Hadi Salim
2016-08-30 12:20           ` Eric Dumazet [this message]

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=1472559628.14381.283.camel@edumazet-glaptop3.roam.corp.google.com \
    --to=eric.dumazet@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    /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.