All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@netronome.com>
To: Thomas Graf <tgraf@suug.ch>
Cc: dev@openvswitch.org, netdev@vger.kernel.org,
	Pravin Shelar <pshelar@nicira.com>,
	Jesse Gross <jesse@nicira.com>
Subject: Re: [PATCH/RFC repost 4/8] datapath: execution of select group action
Date: Wed, 24 Sep 2014 15:01:11 +0900	[thread overview]
Message-ID: <20140924060107.GC13314@vergenet.net> (raw)
In-Reply-To: <20140919140527.GB8257@casper.infradead.org>

On Fri, Sep 19, 2014 at 03:05:27PM +0100, Thomas Graf wrote:
> On 09/18/14 at 10:55am, Simon Horman wrote:
> > +const struct nlattr *bucket_actions(const struct nlattr *attr)
> > +{
> > +	const struct nlattr *a;
> > +	int rem;
> > +
> > +	for (a = nla_data(attr), rem = nla_len(attr); rem > 0;
> > +	     a = nla_next(a, &rem)) {
> > +		if (nla_type(a) == OVS_BUCKET_ATTR_ACTIONS) {
> > +			return a;
> > +		}
> > +	}
> > +
> > +	return NULL;
> > +}
> 
> This is identical to nla_find(). I realize this is not the only
> example but I think we should stop replicating existing Netlink
> functionality and add missing pieces to lib/nlattr.c.

Thanks. For starters I have removed bucket_actions() and replaced
its usage with a call to nla_find().

> > +static u16 bucket_weight(const struct nlattr *attr)
> > +{
> > +	const struct nlattr *weight;
> > +
> > +	/* validate_and_copy_bucket() ensures that the first
> > +	 * attribute is OVS_BUCKET_ATTR_WEIGHT */
> > +	weight = nla_data(attr);
> > +	BUG_ON(nla_type(weight) != OVS_BUCKET_ATTR_WEIGHT);
> > +	return nla_get_u16(weight);
> > +}
> > +
> > +static int select_group(struct datapath *dp, struct sk_buff *skb,
> > +			const struct nlattr *attr)
> > +{
> > +	const struct nlattr *best_bucket = NULL;
> > +	const struct nlattr *acts_list;
> > +	const struct nlattr *bucket;
> > +	struct sk_buff *sample_skb;
> > +	u32 best_score = 0;
> > +	u32 basis;
> > +	u32 i = 0;
> > +	int rem;
> > +
> > +	basis = skb_get_hash(skb);
> > +
> > +	/* Only possible type of attributes is OVS_SELECT_GROUP_ATTR_BUCKET */
> > +	for (bucket = nla_data(attr), rem = nla_len(attr); rem > 0;
> > +	     bucket = nla_next(bucket, &rem)) {
> > +		uint16_t weight = bucket_weight(bucket);
> 
> I think we should validate only once when we copy then assume it is
> correct.

That is the intention of this code, is it doing something else?

I think there is some scope to store the bucket in a more efficient
form for execution. But I'm not sure that any other actions
receive such treatment. So I postponed inventing that wheel.

> > +		// XXX: This hashing seems expensive
> > +		u32 score = (jhash_1word(i, basis) & 0xffff) * weight;
> 
> Maybe just calculate a weighted distribution table pointing to the
> buckets which you index with 8 bits of the hash.

Nice idea. I think that would work out quite well.

The main question for me would be where to store such a table,
which comes back to my remark above about more storing a more
efficient efficient form of the action.

> > +		if (score >= best_score) {
> > +			best_bucket = bucket;
> > +			best_score = score;
> > +		}
> > +		i++;
> > +	}
> > +
> > +	acts_list = bucket_actions(best_bucket);
> > +
> > +	/* A select group action is always the final action so
> > +	 * there is no need to clone the skb in case of side effects.
> > +	 * Instead just take a reference to it which will be released
> > +	 * by do_execute_actions(). */
> > +	skb_get(skb);
> > +
> > +	return do_execute_actions(dp, skb, nla_data(acts_list),
> > +				  nla_len(acts_list));
> 
> Do we need a recursion limit here?

I believe that is already handled by the depth check that occurs
when the actions are copied.

  reply	other threads:[~2014-09-24  6:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-18  1:55 [PATCH/RFC repost 0/8] Open vSwtich ODP Select Group Action Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 1/8] odp: select group action attributes Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 2/8] netlink: Allow suppression of warnings for duplicate attributes Simon Horman
     [not found]   ` <1411005311-11752-3-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2014-09-26 23:55     ` Ben Pfaff
2014-10-09  1:18       ` [ovs-dev] " Simon Horman
2014-10-10 15:31         ` Ben Pfaff
2014-09-18  1:55 ` [PATCH/RFC repost 3/8] odp-util: formatting of datapath select group action Simon Horman
     [not found]   ` <1411005311-11752-4-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2014-09-19 13:44     ` Thomas Graf
2014-09-24  4:55       ` Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 4/8] datapath: execution of " Simon Horman
     [not found]   ` <1411005311-11752-5-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2014-09-19 14:05     ` Thomas Graf
2014-09-24  6:01       ` Simon Horman [this message]
2014-09-24  8:19         ` Thomas Graf
2014-09-25  4:43           ` Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 5/8] datapath: Move last_action() helper to datapath.h Simon Horman
     [not found]   ` <1411005311-11752-6-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2014-09-19 14:06     ` Thomas Graf
2014-09-24  6:00       ` Simon Horman
     [not found]         ` <20140924060013.GB13314-IxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2014-09-24  8:20           ` Thomas Graf
2014-09-25  4:42             ` Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 6/8] datapath: validation of select group action Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 7/8] ofproto: translate datapath " Simon Horman
     [not found]   ` <1411005311-11752-8-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2014-09-26 23:57     ` Ben Pfaff
2014-10-09  1:14       ` [ovs-dev] " Simon Horman
2014-10-13 20:46         ` Ben Pfaff
2014-10-14  4:54           ` Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 8/8] hack: ofproto: enable odp select action Simon Horman

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=20140924060107.GC13314@vergenet.net \
    --to=simon.horman@netronome.com \
    --cc=dev@openvswitch.org \
    --cc=jesse@nicira.com \
    --cc=netdev@vger.kernel.org \
    --cc=pshelar@nicira.com \
    --cc=tgraf@suug.ch \
    /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.