[ovs-dev] [urcu v2 09/15] ovs-atomic: Delete atomic, atomic_flag, ovs_refcount destroy functions.
Andy Zhou
azhou at nicira.com
Thu Mar 13 18:40:44 UTC 2014
Acked-by: Andy Zhou <azhou at nicira.com>
On Tue, Mar 11, 2014 at 1:56 PM, Ben Pfaff <blp at nicira.com> wrote:
> None of the atomic implementations need a destroy function anymore, so it's
> "more standard" and more convenient for users to get rid of them.
>
> Signed-off-by: Ben Pfaff <blp at nicira.com>
> ---
> lib/bfd.c | 3 +--
> lib/cfm.c | 6 +-----
> lib/dpif-linux.c | 3 +--
> lib/dpif-netdev.c | 5 -----
> lib/lacp.c | 3 +--
> lib/mac-learning.c | 3 +--
> lib/netdev.c | 1 -
> lib/netlink-socket.c | 1 -
> lib/ovs-atomic-c11.h | 12 ------------
> lib/ovs-atomic-clang.h | 1 -
> lib/ovs-atomic-flag-gcc4.7+.h | 14 +-------------
> lib/ovs-atomic-gcc4+.h | 13 -------------
> lib/ovs-atomic-gcc4.7+.h | 1 -
> lib/ovs-atomic-pthreads.h | 13 -------------
> lib/ovs-atomic.h | 30 +-----------------------------
> lib/stp.c | 3 +--
> ofproto/bond.c | 3 +--
> ofproto/netflow.c | 3 +--
> ofproto/ofproto-dpif-ipfix.c | 3 +--
> ofproto/ofproto-dpif-sflow.c | 1 -
> ofproto/ofproto-dpif-upcall.c | 3 ---
> ofproto/ofproto.c | 3 ---
> tests/test-atomic.c | 4 +---
> 23 files changed, 12 insertions(+), 120 deletions(-)
>
> diff --git a/lib/bfd.c b/lib/bfd.c
> index 5413105..9071442 100644
> --- a/lib/bfd.c
> +++ b/lib/bfd.c
> @@ -1,4 +1,4 @@
> -/* Copyright (c) 2013 Nicira, Inc.
> +/* Copyright (c) 2013, 2014 Nicira, Inc.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -470,7 +470,6 @@ bfd_unref(struct bfd *bfd) OVS_EXCLUDED(mutex)
> ovs_mutex_lock(&mutex);
> hmap_remove(all_bfds, &bfd->node);
> netdev_close(bfd->netdev);
> - ovs_refcount_destroy(&bfd->ref_cnt);
> free(bfd->name);
> free(bfd);
> ovs_mutex_unlock(&mutex);
> diff --git a/lib/cfm.c b/lib/cfm.c
> index 583df1d..38448ab 100644
> --- a/lib/cfm.c
> +++ b/lib/cfm.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2010, 2011, 2012, 2013 Nicira, Inc.
> + * Copyright (c) 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -372,10 +372,6 @@ cfm_unref(struct cfm *cfm) OVS_EXCLUDED(mutex)
> netdev_close(cfm->netdev);
> free(cfm->rmps_array);
>
> - atomic_destroy(&cfm->extended);
> - atomic_destroy(&cfm->check_tnl_key);
> - ovs_refcount_destroy(&cfm->ref_cnt);
> -
> free(cfm);
> }
>
> diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
> index c2579f6..6f21fc4 100644
> --- a/lib/dpif-linux.c
> +++ b/lib/dpif-linux.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
> + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -1120,7 +1120,6 @@ dpif_linux_flow_dump_done(const struct dpif *dpif
> OVS_UNUSED, void *iter_)
> unsigned int nl_status = nl_dump_done(&iter->dump);
>
> atomic_read(&iter->status, &dump_status);
> - atomic_destroy(&iter->status);
> free(iter);
> return dump_status ? dump_status : nl_status;
> }
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index 5897f8b..54b8f50 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -448,7 +448,6 @@ create_dp_netdev(const char *name, const struct
> dpif_class *class,
> *CONST_CAST(const struct dpif_class **, &dp->class) = class;
> *CONST_CAST(const char **, &dp->name) = xstrdup(name);
> ovs_refcount_init(&dp->ref_cnt);
> - atomic_flag_init(&dp->destroyed);
>
> ovs_mutex_init(&dp->flow_mutex);
> classifier_init(&dp->cls, NULL);
> @@ -558,8 +557,6 @@ dp_netdev_free(struct dp_netdev *dp)
> ovs_mutex_destroy(&dp->flow_mutex);
> seq_destroy(dp->port_seq);
> hmap_destroy(&dp->ports);
> - atomic_flag_destroy(&dp->destroyed);
> - ovs_refcount_destroy(&dp->ref_cnt);
> latch_destroy(&dp->exit_latch);
> free(CONST_CAST(char *, dp->name));
> free(dp);
> @@ -871,7 +868,6 @@ dp_netdev_flow_unref(struct dp_netdev_flow *flow)
> cls_rule_destroy(CONST_CAST(struct cls_rule *, &flow->cr));
> ovs_mutex_lock(&flow->mutex);
> dp_netdev_actions_unref(flow->actions);
> - ovs_refcount_destroy(&flow->ref_cnt);
> ovs_mutex_unlock(&flow->mutex);
> ovs_mutex_destroy(&flow->mutex);
> free(flow);
> @@ -1579,7 +1575,6 @@ void
> dp_netdev_actions_unref(struct dp_netdev_actions *actions)
> {
> if (actions && ovs_refcount_unref(&actions->ref_cnt) == 1) {
> - ovs_refcount_destroy(&actions->ref_cnt);
> free(actions->actions);
> free(actions);
> }
> diff --git a/lib/lacp.c b/lib/lacp.c
> index a3f72ed..cbe2259 100644
> --- a/lib/lacp.c
> +++ b/lib/lacp.c
> @@ -1,4 +1,4 @@
> -/* Copyright (c) 2011, 2012, 2013 Nicira, Inc.
> +/* Copyright (c) 2011, 2012, 2013, 2014 Nicira, Inc.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -249,7 +249,6 @@ lacp_unref(struct lacp *lacp) OVS_EXCLUDED(mutex)
> hmap_destroy(&lacp->slaves);
> list_remove(&lacp->node);
> free(lacp->name);
> - ovs_refcount_destroy(&lacp->ref_cnt);
> free(lacp);
> ovs_mutex_unlock(&mutex);
> }
> diff --git a/lib/mac-learning.c b/lib/mac-learning.c
> index 01a34f5..0854eb9 100644
> --- a/lib/mac-learning.c
> +++ b/lib/mac-learning.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
> + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -141,7 +141,6 @@ mac_learning_unref(struct mac_learning *ml)
>
> bitmap_free(ml->flood_vlans);
> ovs_rwlock_destroy(&ml->rwlock);
> - ovs_refcount_destroy(&ml->ref_cnt);
> free(ml);
> }
> }
> diff --git a/lib/netdev.c b/lib/netdev.c
> index 0567759..e9c8d8f 100644
> --- a/lib/netdev.c
> +++ b/lib/netdev.c
> @@ -225,7 +225,6 @@ netdev_unregister_provider(const char *type)
> atomic_read(&rc->ref_cnt, &ref_cnt);
> if (!ref_cnt) {
> hmap_remove(&netdev_classes, &rc->hmap_node);
> - atomic_destroy(&rc->ref_cnt);
> free(rc);
> error = 0;
> } else {
> diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c
> index 375772f..8c8d16b 100644
> --- a/lib/netlink-socket.c
> +++ b/lib/netlink-socket.c
> @@ -822,7 +822,6 @@ nl_dump_done(struct nl_dump *dump)
> ovs_assert(status);
> ofpbuf_uninit(&buf);
> }
> - atomic_destroy(&dump->status);
> nl_pool_release(dump->sock);
> seq_destroy(dump->status_seq);
> return status >> 1;
> diff --git a/lib/ovs-atomic-c11.h b/lib/ovs-atomic-c11.h
> index 946d412..66d421c 100644
> --- a/lib/ovs-atomic-c11.h
> +++ b/lib/ovs-atomic-c11.h
> @@ -52,15 +52,3 @@
> (*(ORIG) = atomic_fetch_xor_explicit(RMW, ARG, ORDER), (void) 0)
> #define atomic_and_explicit(RMW, ARG, ORIG, ORDER) \
> (*(ORIG) = atomic_fetch_and_explicit(RMW, ARG, ORDER), (void) 0)
> -
> -static inline void
> -atomic_flag_init(volatile atomic_flag *object OVS_UNUSED)
> -{
> - /* Nothing to do. */
> -}
> -
> -static inline void
> -atomic_flag_destroy(volatile atomic_flag *object OVS_UNUSED)
> -{
> - /* Nothing to do. */
> -}
> diff --git a/lib/ovs-atomic-clang.h b/lib/ovs-atomic-clang.h
> index 6792985..c83afab 100644
> --- a/lib/ovs-atomic-clang.h
> +++ b/lib/ovs-atomic-clang.h
> @@ -26,7 +26,6 @@
> #define ATOMIC_VAR_INIT(VALUE) (VALUE)
>
> #define atomic_init(OBJECT, VALUE) __c11_atomic_init(OBJECT, VALUE)
> -#define atomic_destroy(OBJECT) ((void) (OBJECT))
>
> /* Clang hard-codes these exact values internally but does not appear to
> * export any names for them. */
> diff --git a/lib/ovs-atomic-flag-gcc4.7+.h b/lib/ovs-atomic-flag-gcc4.7+.h
> index 385d0de..49cd5d2 100644
> --- a/lib/ovs-atomic-flag-gcc4.7+.h
> +++ b/lib/ovs-atomic-flag-gcc4.7+.h
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2013 Nicira, Inc.
> + * Copyright (c) 2013, 2014 Nicira, Inc.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -26,18 +26,6 @@ typedef struct {
> } atomic_flag;
> #define ATOMIC_FLAG_INIT { .b = false }
>
> -static inline void
> -atomic_flag_init(volatile atomic_flag *object OVS_UNUSED)
> -{
> - /* Nothing to do. */
> -}
> -
> -static inline void
> -atomic_flag_destroy(volatile atomic_flag *object OVS_UNUSED)
> -{
> - /* Nothing to do. */
> -}
> -
> static inline bool
> atomic_flag_test_and_set_explicit(volatile atomic_flag *object,
> memory_order order)
> diff --git a/lib/ovs-atomic-gcc4+.h b/lib/ovs-atomic-gcc4+.h
> index e237c20..2a1b278 100644
> --- a/lib/ovs-atomic-gcc4+.h
> +++ b/lib/ovs-atomic-gcc4+.h
> @@ -45,7 +45,6 @@ typedef enum {
>
> #define ATOMIC_VAR_INIT(VALUE) VALUE
> #define atomic_init(OBJECT, VALUE) (*(OBJECT) = (VALUE), (void) 0)
> -#define atomic_destroy(OBJECT) ((void) (OBJECT))
>
> static inline void
> atomic_thread_fence(memory_order order)
> @@ -146,18 +145,6 @@ typedef struct {
> } atomic_flag;
> #define ATOMIC_FLAG_INIT { false }
>
> -static inline void
> -atomic_flag_init(volatile atomic_flag *object OVS_UNUSED)
> -{
> - /* Nothing to do. */
> -}
> -
> -static inline void
> -atomic_flag_destroy(volatile atomic_flag *object OVS_UNUSED)
> -{
> - /* Nothing to do. */
> -}
> -
> static inline bool
> atomic_flag_test_and_set(volatile atomic_flag *object)
> {
> diff --git a/lib/ovs-atomic-gcc4.7+.h b/lib/ovs-atomic-gcc4.7+.h
> index 99c6b1f..f465e51 100644
> --- a/lib/ovs-atomic-gcc4.7+.h
> +++ b/lib/ovs-atomic-gcc4.7+.h
> @@ -32,7 +32,6 @@ typedef enum {
>
> #define ATOMIC_VAR_INIT(VALUE) (VALUE)
> #define atomic_init(OBJECT, VALUE) (*(OBJECT) = (VALUE), (void) 0)
> -#define atomic_destroy(OBJECT) ((void) (OBJECT))
>
> #define atomic_thread_fence __atomic_thread_fence
> #define atomic_signal_fence __atomic_signal_fence
> diff --git a/lib/ovs-atomic-pthreads.h b/lib/ovs-atomic-pthreads.h
> index b49d699..33270c6 100644
> --- a/lib/ovs-atomic-pthreads.h
> +++ b/lib/ovs-atomic-pthreads.h
> @@ -44,7 +44,6 @@ typedef enum {
>
> #define ATOMIC_VAR_INIT(VALUE) (VALUE)
> #define atomic_init(OBJECT, VALUE) (*(OBJECT) = (VALUE), (void) 0)
> -#define atomic_destroy(OBJECT) ((void) (OBJECT))
>
> static inline void
> atomic_thread_fence(memory_order order OVS_UNUSED)
> @@ -92,18 +91,6 @@ typedef struct {
> } atomic_flag;
> #define ATOMIC_FLAG_INIT { false }
>
> -static inline void
> -atomic_flag_init(volatile atomic_flag *flag OVS_UNUSED)
> -{
> - /* Nothing to do. */
> -}
> -
> -static inline void
> -atomic_flag_destroy(volatile atomic_flag *flag OVS_UNUSED)
> -{
> - /* Nothing to do. */
> -}
> -
> static inline bool
> atomic_flag_test_and_set(volatile atomic_flag *flag_)
> {
> diff --git a/lib/ovs-atomic.h b/lib/ovs-atomic.h
> index 62cd258..01ac8c4 100644
> --- a/lib/ovs-atomic.h
> +++ b/lib/ovs-atomic.h
> @@ -102,15 +102,6 @@
> * ...
> * atomic_init(&ai, 123);
> *
> - * C11 does not hav an destruction function for atomic types, but some
> - * implementations of the OVS atomics do need them. Thus, the following
> - * function is provided for destroying non-static atomic objects (A is any
> - * atomic type):
> - *
> - * void atomic_destroy(A *object);
> - *
> - * Destroys 'object'.
> - *
> *
> * Barriers
> * ========
> @@ -224,19 +215,7 @@
> * ATOMIC_FLAG_INIT is an initializer for atomic_flag. The initial state
> is
> * "clear".
> *
> - * C11 does not have an initialization or destruction function for
> atomic_flag,
> - * because implementations should not need one (one may simply
> - * atomic_flag_clear() an uninitialized atomic_flag), but some
> implementations
> - * of the OVS atomics do need them. Thus, the following two functions are
> - * provided for initializing and destroying non-static atomic_flags:
> - *
> - * void atomic_flag_init(volatile atomic_flag *object);
> - *
> - * Initializes 'object'. The initial state is "clear".
> - *
> - * void atomic_flag_destroy(volatile atomic_flag *object);
> - *
> - * Destroys 'object'.
> + * An atomic_flag may also be initialized at runtime with
> atomic_flag_clear().
> *
> *
> * Operations
> @@ -336,13 +315,6 @@ ovs_refcount_init(struct ovs_refcount *refcount)
> atomic_init(&refcount->count, 1);
> }
>
> -/* Destroys 'refcount'. */
> -static inline void
> -ovs_refcount_destroy(struct ovs_refcount *refcount)
> -{
> - atomic_destroy(&refcount->count);
> -}
> -
> /* Increments 'refcount'. */
> static inline void
> ovs_refcount_ref(struct ovs_refcount *refcount)
> diff --git a/lib/stp.c b/lib/stp.c
> index e4ddf3c..afe77d0 100644
> --- a/lib/stp.c
> +++ b/lib/stp.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
> + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -332,7 +332,6 @@ stp_unref(struct stp *stp)
> list_remove(&stp->node);
> ovs_mutex_unlock(&mutex);
> free(stp->name);
> - ovs_refcount_destroy(&stp->ref_cnt);
> free(stp);
> }
> }
> diff --git a/ofproto/bond.c b/ofproto/bond.c
> index c4cfa45..21201ee 100644
> --- a/ofproto/bond.c
> +++ b/ofproto/bond.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
> + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -236,7 +236,6 @@ bond_unref(struct bond *bond)
> ovs_mutex_destroy(&bond->mutex);
> free(bond->hash);
> free(bond->name);
> - ovs_refcount_destroy(&bond->ref_cnt);
> free(bond);
> }
>
> diff --git a/ofproto/netflow.c b/ofproto/netflow.c
> index 8259ced..8715950 100644
> --- a/ofproto/netflow.c
> +++ b/ofproto/netflow.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2008, 2009, 2010, 2011, 2013 Nicira, Inc.
> + * Copyright (c) 2008, 2009, 2010, 2011, 2013, 2014 Nicira, Inc.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -430,7 +430,6 @@ netflow_unref(struct netflow *nf)
> atomic_sub(&netflow_count, 1, &orig);
> collectors_destroy(nf->collectors);
> ofpbuf_uninit(&nf->packet);
> - ovs_refcount_destroy(&nf->ref_cnt);
> free(nf);
> }
> }
> diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
> index a529884..c8fb3d7 100644
> --- a/ofproto/ofproto-dpif-ipfix.c
> +++ b/ofproto/ofproto-dpif-ipfix.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2012, 2013 Nicira, Inc.
> + * Copyright (c) 2012, 2013, 2014 Nicira, Inc.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -699,7 +699,6 @@ dpif_ipfix_unref(struct dpif_ipfix *di)
> OVS_EXCLUDED(mutex)
> dpif_ipfix_clear(di);
> dpif_ipfix_bridge_exporter_destroy(&di->bridge_exporter);
> hmap_destroy(&di->flow_exporter_map);
> - ovs_refcount_destroy(&di->ref_cnt);
> free(di);
> ovs_mutex_unlock(&mutex);
> }
> diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c
> index ff07e70..eeff13f 100644
> --- a/ofproto/ofproto-dpif-sflow.c
> +++ b/ofproto/ofproto-dpif-sflow.c
> @@ -370,7 +370,6 @@ dpif_sflow_unref(struct dpif_sflow *ds)
> OVS_EXCLUDED(mutex)
> dpif_sflow_del_port__(ds, dsp);
> }
> hmap_destroy(&ds->ports);
> - ovs_refcount_destroy(&ds->ref_cnt);
> free(ds);
> }
> }
> diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
> index 7dbd7f7..39f47c7 100644
> --- a/ofproto/ofproto-dpif-upcall.c
> +++ b/ofproto/ofproto-dpif-upcall.c
> @@ -286,9 +286,6 @@ udpif_destroy(struct udpif *udpif)
> latch_destroy(&udpif->exit_latch);
> seq_destroy(udpif->reval_seq);
> seq_destroy(udpif->dump_seq);
> - atomic_destroy(&udpif->flow_limit);
> - atomic_destroy(&udpif->n_flows);
> - atomic_destroy(&udpif->n_flows_timestamp);
> ovs_mutex_destroy(&udpif->n_flows_mutex);
> free(udpif);
> }
> diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
> index 19e7091..d61e618 100644
> --- a/ofproto/ofproto.c
> +++ b/ofproto/ofproto.c
> @@ -2602,7 +2602,6 @@ ofproto_rule_destroy__(struct rule *rule)
> cls_rule_destroy(CONST_CAST(struct cls_rule *, &rule->cr));
> rule_actions_unref(rule->actions);
> ovs_mutex_destroy(&rule->mutex);
> - ovs_refcount_destroy(&rule->ref_count);
> rule->ofproto->ofproto_class->rule_dealloc(rule);
> }
>
> @@ -2643,7 +2642,6 @@ void
> rule_actions_unref(struct rule_actions *actions)
> {
> if (actions && ovs_refcount_unref(&actions->ref_count) == 1) {
> - ovs_refcount_destroy(&actions->ref_count);
> free(actions->ofpacts);
> free(actions);
> }
> @@ -6692,7 +6690,6 @@ oftable_destroy(struct oftable *table)
> oftable_disable_eviction(table);
> classifier_destroy(&table->cls);
> free(table->name);
> - atomic_destroy(&table->config);
> }
>
> /* Changes the name of 'table' to 'name'. If 'name' is NULL or the empty
> diff --git a/tests/test-atomic.c b/tests/test-atomic.c
> index bc00df1..887789b 100644
> --- a/tests/test-atomic.c
> +++ b/tests/test-atomic.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2013 Nicira, Inc.
> + * Copyright (c) 2013, 2014 Nicira, Inc.
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> @@ -59,8 +59,6 @@
> ovs_assert(orig == 2); \
> atomic_read(&x, &value); \
> ovs_assert(value == 8); \
> - \
> - atomic_destroy(&x); \
> }
>
> static void
> --
> 1.7.10.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20140313/5b33d4d6/attachment-0005.html>
More information about the dev
mailing list