Signed-off-by: Daniele Di Proietto <ddiproie...@vmware.com> --- lib/ovs-thread.c | 48 ------------------------------------------------ lib/ovs-thread.h | 32 -------------------------------- 2 files changed, 80 deletions(-)
diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c index ac014f5..83ade11 100644 --- a/lib/ovs-thread.c +++ b/lib/ovs-thread.c @@ -457,54 +457,6 @@ may_fork(void) return !must_not_fork; } -/* ovsthread_stats. */ - -void -ovsthread_stats_init(struct ovsthread_stats *stats) -{ - int i; - - ovs_mutex_init(&stats->mutex); - for (i = 0; i < ARRAY_SIZE(stats->buckets); i++) { - stats->buckets[i] = NULL; - } -} - -void -ovsthread_stats_destroy(struct ovsthread_stats *stats) -{ - ovs_mutex_destroy(&stats->mutex); -} - -void * -ovsthread_stats_bucket_get(struct ovsthread_stats *stats, - void *(*new_bucket)(void)) -{ - unsigned int idx = ovsthread_id_self() & (ARRAY_SIZE(stats->buckets) - 1); - void *bucket = stats->buckets[idx]; - if (!bucket) { - ovs_mutex_lock(&stats->mutex); - bucket = stats->buckets[idx]; - if (!bucket) { - bucket = stats->buckets[idx] = new_bucket(); - } - ovs_mutex_unlock(&stats->mutex); - } - return bucket; -} - -size_t -ovs_thread_stats_next_bucket(const struct ovsthread_stats *stats, size_t i) -{ - for (; i < ARRAY_SIZE(stats->buckets); i++) { - if (stats->buckets[i]) { - break; - } - } - return i; -} - - /* Parses /proc/cpuinfo for the total number of physical cores on this system * across all CPU packages, not counting hyper-threads. * diff --git a/lib/ovs-thread.h b/lib/ovs-thread.h index 42808b9..2576e3e 100644 --- a/lib/ovs-thread.h +++ b/lib/ovs-thread.h @@ -585,38 +585,6 @@ ovsthread_id_self(void) return *ovsthread_id_get(); } -/* Simulated global counter. - * - * Incrementing such a counter is meant to be cheaper than incrementing a - * global counter protected by a lock. It is probably more expensive than - * incrementing a truly thread-local variable, but such a variable has no - * straightforward way to get the sum. - * - * - * Thread-safety - * ============= - * - * Fully thread-safe. */ - -struct ovsthread_stats { - struct ovs_mutex mutex; - void *volatile buckets[16]; -}; - -void ovsthread_stats_init(struct ovsthread_stats *); -void ovsthread_stats_destroy(struct ovsthread_stats *); - -void *ovsthread_stats_bucket_get(struct ovsthread_stats *, - void *(*new_bucket)(void)); - -#define OVSTHREAD_STATS_FOR_EACH_BUCKET(BUCKET, IDX, STATS) \ - for ((IDX) = ovs_thread_stats_next_bucket(STATS, 0); \ - ((IDX) < ARRAY_SIZE((STATS)->buckets) \ - ? ((BUCKET) = (STATS)->buckets[IDX], true) \ - : false); \ - (IDX) = ovs_thread_stats_next_bucket(STATS, (IDX) + 1)) -size_t ovs_thread_stats_next_bucket(const struct ovsthread_stats *, size_t); - bool single_threaded(void); void assert_single_threaded_at(const char *where); -- 2.1.0.rc1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev