Hey Ben, Could you help review this patch?
Kind Regards, Alex Wang, On Wed, Aug 7, 2013 at 3:51 PM, Alex Wang <[email protected]> wrote: > This commit adds a new column "n-worker-threads" to ovsdb Open_vSwitch > TABLE. This is used to set the maximum number of worker threads that > can be created. The upper bound of this value is either (number of > online cores - 2) or 1 (if number is less than 3). > > Signed-off-by: Alex Wang <[email protected]> > --- > > v1 -> v2: > > - fix a grammatical mistake. > > --- > ofproto/ofproto.c | 16 ++++++++++++++++ > ofproto/ofproto.h | 3 +++ > vswitchd/bridge.c | 4 ++++ > vswitchd/vswitch.xml | 9 +++++++++ > 4 files changed, 32 insertions(+) > > diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c > index 0625ccf..6989263 100644 > --- a/ofproto/ofproto.c > +++ b/ofproto/ofproto.c > @@ -21,6 +21,7 @@ > #include <inttypes.h> > #include <stdbool.h> > #include <stdlib.h> > +#include <unistd.h> > #include "bitmap.h" > #include "byte-order.h" > #include "classifier.h" > @@ -224,6 +225,7 @@ static size_t n_ofproto_classes; > static size_t allocated_ofproto_classes; > > unsigned flow_eviction_threshold = > OFPROTO_FLOW_EVICTION_THRESHOLD_DEFAULT; > +unsigned n_worker_threads = OFPROTO_N_WORKER_THREADS_DEFAULT; > enum ofproto_flow_miss_model flow_miss_model = OFPROTO_HANDLE_MISS_AUTO; > > /* Map from datapath name to struct ofproto, for use by unixctl commands. > */ > @@ -622,6 +624,20 @@ ofproto_set_mac_table_config(struct ofproto *ofproto, > unsigned idle_time, > } > } > > +/* Sets maximum number of worker threads allowed. The upper limit is > + * (number of online cores - 2) or 1 (if the number is less than 3). */ > +void > +ofproto_set_n_worker_threads(unsigned limit) > +{ > + unsigned max_online_cores = sysconf(_SC_NPROCESSORS_ONLN); > + > + if (limit > max_online_cores - 2) { > + n_worker_threads = MAX(1, max_online_cores - 2); > + } else { > + n_worker_threads = limit; > + } > +} > + > void > ofproto_set_dp_desc(struct ofproto *p, const char *dp_desc) > { > diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h > index 1bde385..73fb101 100644 > --- a/ofproto/ofproto.h > +++ b/ofproto/ofproto.h > @@ -215,6 +215,8 @@ int ofproto_port_dump_done(struct ofproto_port_dump *); > #define OFPROTO_FLOW_EVICTION_THRESHOLD_DEFAULT 2500 > #define OFPROTO_FLOW_EVICTION_THRESHOLD_MIN 100 > > +#define OFPROTO_N_WORKER_THREADS_DEFAULT 1 > + > /* How flow misses should be handled in ofproto-dpif */ > enum ofproto_flow_miss_model { > OFPROTO_HANDLE_MISS_AUTO, /* Based on flow eviction > threshold. */ > @@ -247,6 +249,7 @@ void ofproto_set_flow_miss_model(unsigned model); > void ofproto_set_forward_bpdu(struct ofproto *, bool forward_bpdu); > void ofproto_set_mac_table_config(struct ofproto *, unsigned idle_time, > size_t max_entries); > +void ofproto_set_n_worker_threads(unsigned limit); > void ofproto_set_dp_desc(struct ofproto *, const char *dp_desc); > int ofproto_set_snoops(struct ofproto *, const struct sset *snoops); > int ofproto_set_netflow(struct ofproto *, > diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c > index abbda56..cfb633d 100644 > --- a/vswitchd/bridge.c > +++ b/vswitchd/bridge.c > @@ -502,6 +502,10 @@ bridge_reconfigure(const struct ovsrec_open_vswitch > *ovs_cfg) > smap_get_int(&ovs_cfg->other_config, "flow-eviction-threshold", > OFPROTO_FLOW_EVICTION_THRESHOLD_DEFAULT)); > > + ofproto_set_n_worker_threads( > + smap_get_int(&ovs_cfg->other_config, "n-worker-threads", > + OFPROTO_N_WORKER_THREADS_DEFAULT)); > + > bridge_configure_flow_miss_model(smap_get(&ovs_cfg->other_config, > "force-miss-model")); > > diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml > index b89d58c..d58a9ba 100644 > --- a/vswitchd/vswitch.xml > +++ b/vswitchd/vswitch.xml > @@ -158,6 +158,15 @@ > </dl> > </p> > </column> > + > + <column name="other_config" key="n-worker-threads" > + type='{"type": "integer", "minInteger": 1}'> > + <p> > + Specifies the maximum number of worker threads that can be > created. > + The upper limit is (number of online core - 2) or 1 if there are > + fewer than 3 online cores. > + </p> > + </column> > </group> > > <group title="Status"> > -- > 1.7.9.5 > >
_______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
