]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/frrcu.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / frrcu.c
index 54626f909d2a4ccb372f52d2b4cbdbefa5002ed3..c7cc655e09ceb9339cc5493e973234d2985de209 100644 (file)
@@ -1,17 +1,6 @@
+// SPDX-License-Identifier: ISC
 /*
  * Copyright (c) 2017-19  David Lamparter, for NetDEF, Inc.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
 /* implementation notes:  this is an epoch-based RCU implementation.  rcu_seq
 #include "seqlock.h"
 #include "atomlist.h"
 
-DEFINE_MTYPE_STATIC(LIB, RCU_THREAD,    "RCU thread")
+DEFINE_MTYPE_STATIC(LIB, RCU_THREAD,    "RCU thread");
+DEFINE_MTYPE_STATIC(LIB, RCU_NEXT,      "RCU sequence barrier");
 
-DECLARE_ATOMLIST(rcu_heads, struct rcu_head, head)
+DECLARE_ATOMLIST(rcu_heads, struct rcu_head, head);
 
-PREDECL_ATOMLIST(rcu_threads)
+PREDECL_ATOMLIST(rcu_threads);
 struct rcu_thread {
        struct rcu_threads_item head;
 
@@ -69,7 +59,7 @@ struct rcu_thread {
        /* only accessed by thread itself, not atomic */
        unsigned depth;
 };
-DECLARE_ATOMLIST(rcu_threads, struct rcu_thread, head)
+DECLARE_ATOMLIST(rcu_threads, struct rcu_thread, head);
 
 static const struct rcu_action rcua_next  = { .type = RCUA_NEXT };
 static const struct rcu_action rcua_end   = { .type = RCUA_END };
@@ -225,7 +215,7 @@ static void rcu_bump(void)
 {
        struct rcu_next *rn;
 
-       rn = XMALLOC(MTYPE_RCU_THREAD, sizeof(*rn));
+       rn = XMALLOC(MTYPE_RCU_NEXT, sizeof(*rn));
 
        /* note: each RCUA_NEXT item corresponds to exactly one seqno bump.
         * This means we don't need to communicate which seqno is which
@@ -268,7 +258,7 @@ static void rcu_bump(void)
         * "last item is being deleted - start over" case, and then we may end
         * up accessing old RCU queue items that are already free'd.
         */
-       rcu_free_internal(MTYPE_RCU_THREAD, rn, head_free);
+       rcu_free_internal(MTYPE_RCU_NEXT, rn, head_free);
 
        /* Only allow the RCU sweeper to run after these 2 items are queued.
         *