From 94f37128144287d35274225f99da4927d3f41ab4 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Tue, 17 Mar 2020 17:20:43 -0400 Subject: [PATCH] ck_queue: remove load fences on iterators. These were always no-op on TSO. For non-TSO, we assume data dependent ordering. Next to data does not require ordering but data to next does. However, a re-ordering here is benign in that a stale load will observe an initialized NULL value. We would rather not pay the load cost for the common case. Write-side fences are unchanged. From discussions with markj@freebsd.org. --- include/ck_queue.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/ck_queue.h b/include/ck_queue.h index 990ab4b..fd38d8a 100644 --- a/include/ck_queue.h +++ b/include/ck_queue.h @@ -150,17 +150,17 @@ struct { \ #define CK_SLIST_FOREACH(var, head, field) \ for ((var) = CK_SLIST_FIRST((head)); \ - (var) && (ck_pr_fence_load(), 1); \ + (var); \ (var) = CK_SLIST_NEXT((var), field)) -#define CK_SLIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = CK_SLIST_FIRST(head); \ - (var) && (ck_pr_fence_load(), (tvar) = CK_SLIST_NEXT(var, field), 1);\ +#define CK_SLIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = CK_SLIST_FIRST(head); \ + (var) && ((tvar) = CK_SLIST_NEXT(var, field), 1); \ (var) = (tvar)) #define CK_SLIST_FOREACH_PREVPTR(var, varp, head, field) \ for ((varp) = &(head)->cslh_first; \ - ((var) = ck_pr_load_ptr(varp)) != NULL && (ck_pr_fence_load(), 1); \ + ((var) = ck_pr_load_ptr(varp)) != NULL; \ (varp) = &(var)->field.csle_next) #define CK_SLIST_INIT(head) do { \ @@ -259,12 +259,12 @@ struct { \ #define CK_STAILQ_FOREACH(var, head, field) \ for((var) = CK_STAILQ_FIRST((head)); \ - (var) && (ck_pr_fence_load(), 1); \ + (var); \ (var) = CK_STAILQ_NEXT((var), field)) #define CK_STAILQ_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = CK_STAILQ_FIRST((head)); \ - (var) && (ck_pr_fence_load(), (tvar) = \ + (var) && ((tvar) = \ CK_STAILQ_NEXT((var), field), 1); \ (var) = (tvar)) @@ -371,12 +371,12 @@ struct { \ #define CK_LIST_FOREACH(var, head, field) \ for ((var) = CK_LIST_FIRST((head)); \ - (var) && (ck_pr_fence_load(), 1); \ + (var); \ (var) = CK_LIST_NEXT((var), field)) #define CK_LIST_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = CK_LIST_FIRST((head)); \ - (var) && (ck_pr_fence_load(), (tvar) = CK_LIST_NEXT((var), field), 1);\ + (var) && ((tvar) = CK_LIST_NEXT((var), field), 1); \ (var) = (tvar)) #define CK_LIST_INIT(head) do { \