summaryrefslogtreecommitdiff
path: root/kern
diff options
context:
space:
mode:
authorRemy Noel <mocramis@gmail.com>2018-04-18 21:11:16 +0200
committerRemy Noel <mocramis@gmail.com>2018-04-18 21:11:16 +0200
commit6b3df26a8822b08f87a2aab5085d4e51c5168583 (patch)
tree66a15c26244ed0cdaee173ae931b899761cb69cd /kern
parent7f1d6dcb4317647a3fc06f7d95f751142d7c6f16 (diff)
parent3640f94ee392b19de48360d2d026a7f581447049 (diff)
Merge branch 'master' into perfmon
Diffstat (limited to 'kern')
-rw-r--r--kern/Kconfig14
-rw-r--r--kern/atomic.h31
-rw-r--r--kern/hlist.h30
-rw-r--r--kern/list.h24
-rw-r--r--kern/log2.h6
-rw-r--r--kern/rbtree.h94
-rw-r--r--kern/rcu.c6
-rw-r--r--kern/shell.h10
-rw-r--r--kern/slist.h36
9 files changed, 127 insertions, 124 deletions
diff --git a/kern/Kconfig b/kern/Kconfig
index 3101b7f..5e0e5eb 100644
--- a/kern/Kconfig
+++ b/kern/Kconfig
@@ -63,6 +63,20 @@ config MUTEX_PLAIN
endchoice
+config RCU_WINDOW_CHECK_INTERVAL
+ int "Interval between RCU window checks"
+ range 1 100
+ default 10
+ ---help---
+ Time (in milliseconds) between two RCU window checks.
+
+ The RCU system keeps memory used by read-side critical sections
+ until it is safe to release it, which can only be determined when
+ checking windows. As a result, checking windows more frequently
+ may help lower latencies on synchronous RCU waits, and in turn,
+ the amount of memory pending release, at the cost of increased
+ CPU overhead.
+
config SHELL
bool "Embedded shell"
default n
diff --git a/kern/atomic.h b/kern/atomic.h
index e106dac..5d99da9 100644
--- a/kern/atomic.h
+++ b/kern/atomic.h
@@ -31,20 +31,9 @@
/*
* Supported memory orders.
- *
- * Note that the consume order is aliased to relaxed. This assumes that
- * all supported processors respect data dependencies. The rationale is
- * that the definition for the consume order is confusing enough that
- * most compilers alias it to acquire, which forces the generation of
- * memory barrier instructions even when they're not really needed.
- * Since there is currently no processor where using consume or relaxed
- * would produce different code, it is safe to establish that alias.
- * It serves as explicit documentation for code review, and will easily
- * be replaced with the true consume order once compiler support becomes
- * efficient and reliable.
*/
#define ATOMIC_RELAXED __ATOMIC_RELAXED
-#define ATOMIC_CONSUME __ATOMIC_RELAXED
+#define ATOMIC_CONSUME __ATOMIC_CONSUME
#define ATOMIC_ACQUIRE __ATOMIC_ACQUIRE
#define ATOMIC_RELEASE __ATOMIC_RELEASE
#define ATOMIC_ACQ_REL __ATOMIC_ACQ_REL
@@ -89,15 +78,15 @@
* value, some compilers seem to have trouble when all parameters don't
* have the same type.
*/
-#define atomic_cas(ptr, oval, nval, mo) \
-MACRO_BEGIN \
- typeof(*(ptr)) oval___, nval___; \
- \
- oval___ = (oval); \
- nval___ = (nval); \
- __atomic_compare_exchange_n(ptr, &oval___, nval___, false, \
- mo, ATOMIC_RELAXED); \
- oval___; \
+#define atomic_cas(ptr, oval, nval, mo) \
+MACRO_BEGIN \
+ typeof(*(ptr)) oval_, nval_; \
+ \
+ oval_ = (oval); \
+ nval_ = (nval); \
+ __atomic_compare_exchange_n(ptr, &oval_, nval_, false, \
+ mo, ATOMIC_RELAXED); \
+ oval_; \
MACRO_END
/*
diff --git a/kern/hlist.h b/kern/hlist.h
index 61fad4f..739ea83 100644
--- a/kern/hlist.h
+++ b/kern/hlist.h
@@ -200,23 +200,23 @@ hlist_remove(struct hlist_node *node)
*/
#define hlist_first_entry(list, type, member) \
MACRO_BEGIN \
- struct hlist_node *first___; \
+ struct hlist_node *first_; \
\
- first___ = (list)->first; \
- hlist_end(first___) ? NULL : hlist_entry(first___, type, member); \
+ first_ = (list)->first; \
+ hlist_end(first_) ? NULL : hlist_entry(first_, type, member); \
MACRO_END
/*
* Get the entry next to the given entry.
*/
-#define hlist_next_entry(entry, member) \
+#define hlist_next_entry(entry, member) \
MACRO_BEGIN \
- struct hlist_node *next___; \
+ struct hlist_node *next_; \
\
- next___ = (entry)->member.next; \
- hlist_end(next___) \
+ next_ = (entry)->member.next; \
+ hlist_end(next_) \
? NULL \
- : hlist_entry(next___, typeof(*entry), member); \
+ : hlist_entry(next_, typeof(*entry), member); \
MACRO_END
/*
@@ -355,10 +355,10 @@ hlist_rcu_remove(struct hlist_node *node)
*/
#define hlist_rcu_first_entry(list, type, member) \
MACRO_BEGIN \
- struct hlist_node *first___; \
+ struct hlist_node *first_; \
\
- first___ = hlist_rcu_first(list); \
- hlist_end(first___) ? NULL : hlist_entry(first___, type, member); \
+ first_ = hlist_rcu_first(list); \
+ hlist_end(first_) ? NULL : hlist_entry(first_, type, member); \
MACRO_END
/*
@@ -366,12 +366,12 @@ MACRO_END
*/
#define hlist_rcu_next_entry(entry, member) \
MACRO_BEGIN \
- struct hlist_node *next___; \
+ struct hlist_node *next_; \
\
- next___ = hlist_rcu_next(&entry->member); \
- hlist_end(next___) \
+ next_ = hlist_rcu_next(&entry->member); \
+ hlist_end(next_) \
? NULL \
- : hlist_entry(next___, typeof(*entry), member); \
+ : hlist_entry(next_, typeof(*entry), member); \
MACRO_END
/*
diff --git a/kern/list.h b/kern/list.h
index 8163176..2ba7f09 100644
--- a/kern/list.h
+++ b/kern/list.h
@@ -480,14 +480,14 @@ list_rcu_remove(struct list *node)
*/
#define list_rcu_first_entry(head, type, member) \
MACRO_BEGIN \
- struct list *list___; \
- struct list *first___; \
+ struct list *list_; \
+ struct list *first_; \
\
- list___ = (head); \
- first___ = list_rcu_first(list___); \
- list_end(list___, first___) \
+ list_ = (head); \
+ first_ = list_rcu_first(list_); \
+ list_end(list_, first_) \
? NULL \
- : list_entry(first___, type, member); \
+ : list_entry(first_, type, member); \
MACRO_END
/*
@@ -499,14 +499,14 @@ MACRO_END
*/
#define list_rcu_next_entry(head, entry, member) \
MACRO_BEGIN \
- struct list *list___; \
- struct list *next___; \
+ struct list *list_; \
+ struct list *next_; \
\
- list___ = (head); \
- next___ = list_rcu_next(&entry->member); \
- list_end(list___, next___) \
+ list_ = (head); \
+ next_ = list_rcu_next(&entry->member); \
+ list_end(list_, next_) \
? NULL \
- : list_entry(next___, typeof(*entry), member); \
+ : list_entry(next_, typeof(*entry), member); \
MACRO_END
/*
diff --git a/kern/log2.h b/kern/log2.h
index 1799b82..c59753f 100644
--- a/kern/log2.h
+++ b/kern/log2.h
@@ -18,8 +18,8 @@
* Integer base 2 logarithm operations.
*/
-#ifndef _KERN_LOG2_H
-#define _KERN_LOG2_H
+#ifndef KERN_LOG2_H
+#define KERN_LOG2_H
#include <assert.h>
#include <limits.h>
@@ -51,4 +51,4 @@ log2_order(unsigned long size)
return log2(size - 1) + 1;
}
-#endif /* _KERN_LOG2_H */
+#endif /* KERN_LOG2_H */
diff --git a/kern/rbtree.h b/kern/rbtree.h
index 7ec83fe..1eafebb 100644
--- a/kern/rbtree.h
+++ b/kern/rbtree.h
@@ -120,22 +120,22 @@ rbtree_empty(const struct rbtree *tree)
*/
#define rbtree_lookup(tree, key, cmp_fn) \
MACRO_BEGIN \
- struct rbtree_node *cur___; \
- int diff___; \
+ struct rbtree_node *cur_; \
+ int diff_; \
\
- cur___ = (tree)->root; \
+ cur_ = (tree)->root; \
\
- while (cur___ != NULL) { \
- diff___ = cmp_fn(key, cur___); \
+ while (cur_ != NULL) { \
+ diff_ = cmp_fn(key, cur_); \
\
- if (diff___ == 0) { \
+ if (diff_ == 0) { \
break; \
} \
\
- cur___ = cur___->children[rbtree_d2i(diff___)]; \
+ cur_ = cur_->children[rbtree_d2i(diff_)]; \
} \
\
- cur___; \
+ cur_; \
MACRO_END
/*
@@ -150,30 +150,30 @@ MACRO_END
*/
#define rbtree_lookup_nearest(tree, key, cmp_fn, dir) \
MACRO_BEGIN \
- struct rbtree_node *cur___, *prev___; \
- int diff___, index___; \
+ struct rbtree_node *cur_, *prev_; \
+ int diff_, index_; \
\
- prev___ = NULL; \
- index___ = -1; \
- cur___ = (tree)->root; \
+ prev_ = NULL; \
+ index_ = -1; \
+ cur_ = (tree)->root; \
\
- while (cur___ != NULL) { \
- diff___ = cmp_fn(key, cur___); \
+ while (cur_ != NULL) { \
+ diff_ = cmp_fn(key, cur_); \
\
- if (diff___ == 0) { \
+ if (diff_ == 0) { \
break; \
} \
\
- prev___ = cur___; \
- index___ = rbtree_d2i(diff___); \
- cur___ = cur___->children[index___]; \
+ prev_ = cur_; \
+ index_ = rbtree_d2i(diff_); \
+ cur_ = cur_->children[index_]; \
} \
\
- if (cur___ == NULL) { \
- cur___ = rbtree_nearest(prev___, index___, dir); \
+ if (cur_ == NULL) { \
+ cur_ = rbtree_nearest(prev_, index_, dir); \
} \
\
- cur___; \
+ cur_; \
MACRO_END
/*
@@ -194,22 +194,22 @@ MACRO_END
*/
#define rbtree_insert(tree, node, cmp_fn) \
MACRO_BEGIN \
- struct rbtree_node *cur___, *prev___; \
- int diff___, index___; \
+ struct rbtree_node *cur_, *prev_; \
+ int diff_, index_; \
\
- prev___ = NULL; \
- index___ = -1; \
- cur___ = (tree)->root; \
+ prev_ = NULL; \
+ index_ = -1; \
+ cur_ = (tree)->root; \
\
- while (cur___ != NULL) { \
- diff___ = cmp_fn(node, cur___); \
- assert(diff___ != 0); \
- prev___ = cur___; \
- index___ = rbtree_d2i(diff___); \
- cur___ = cur___->children[index___]; \
+ while (cur_ != NULL) { \
+ diff_ = cmp_fn(node, cur_); \
+ assert(diff_ != 0); \
+ prev_ = cur_; \
+ index_ = rbtree_d2i(diff_); \
+ cur_ = cur_->children[index_]; \
} \
\
- rbtree_insert_rebalance(tree, prev___, index___, node); \
+ rbtree_insert_rebalance(tree, prev_, index_, node); \
MACRO_END
/*
@@ -225,27 +225,27 @@ MACRO_END
*/
#define rbtree_lookup_slot(tree, key, cmp_fn, slot) \
MACRO_BEGIN \
- struct rbtree_node *cur___, *prev___; \
- int diff___, index___; \
+ struct rbtree_node *cur_, *prev_; \
+ int diff_, index_; \
\
- prev___ = NULL; \
- index___ = 0; \
- cur___ = (tree)->root; \
+ prev_ = NULL; \
+ index_ = 0; \
+ cur_ = (tree)->root; \
\
- while (cur___ != NULL) { \
- diff___ = cmp_fn(key, cur___); \
+ while (cur_ != NULL) { \
+ diff_ = cmp_fn(key, cur_); \
\
- if (diff___ == 0) { \
+ if (diff_ == 0) { \
break; \
} \
\
- prev___ = cur___; \
- index___ = rbtree_d2i(diff___); \
- cur___ = cur___->children[index___]; \
+ prev_ = cur_; \
+ index_ = rbtree_d2i(diff_); \
+ cur_ = cur_->children[index_]; \
} \
\
- (slot) = rbtree_slot(prev___, index___); \
- cur___; \
+ (slot) = rbtree_slot(prev_, index_); \
+ cur_; \
MACRO_END
/*
diff --git a/kern/rcu.c b/kern/rcu.c
index 1903dcf..834a99b 100644
--- a/kern/rcu.c
+++ b/kern/rcu.c
@@ -105,12 +105,12 @@
#define RCU_WINDOW_ID_INIT_VALUE ((unsigned int)-500)
/*
- * Interval between window checking.
+ * Interval (in milliseconds) between window checking.
*
* When windows are checked, a flip occurs if the previous window isn't
* active any more.
*/
-#define RCU_WINDOW_CHECK_INTERVAL_MS 10
+#define RCU_WINDOW_CHECK_INTERVAL CONFIG_RCU_WINDOW_CHECK_INTERVAL
/*
* Grace period states.
@@ -376,7 +376,7 @@ rcu_data_schedule_timer(struct rcu_data *data, uint64_t now)
{
uint64_t ticks;
- ticks = clock_ticks_from_ms(RCU_WINDOW_CHECK_INTERVAL_MS);
+ ticks = clock_ticks_from_ms(RCU_WINDOW_CHECK_INTERVAL);
timer_schedule(&data->timer, now + ticks);
}
diff --git a/kern/shell.h b/kern/shell.h
index db055e7..0526019 100644
--- a/kern/shell.h
+++ b/kern/shell.h
@@ -32,12 +32,12 @@
#define SHELL_REGISTER_CMDS(cmds) \
MACRO_BEGIN \
- size_t i___; \
- int error___; \
+ size_t i_; \
+ int error_; \
\
- for (i___ = 0; i___ < ARRAY_SIZE(cmds); i___++) { \
- error___ = shell_cmd_register(&(cmds)[i___]); \
- error_check(error___, __func__); \
+ for (i_ = 0; i_ < ARRAY_SIZE(cmds); i_++) { \
+ error_ = shell_cmd_register(&(cmds)[i_]); \
+ error_check(error_, __func__); \
} \
MACRO_END
diff --git a/kern/slist.h b/kern/slist.h
index 424cdb2..8fd0a21 100644
--- a/kern/slist.h
+++ b/kern/slist.h
@@ -226,10 +226,10 @@ slist_remove(struct slist *list, struct slist_node *prev)
*/
#define slist_first_entry(list, type, member) \
MACRO_BEGIN \
- struct slist_node *first___; \
+ struct slist_node *first_; \
\
- first___ = (list)->first; \
- slist_end(first___) ? NULL : slist_entry(first___, type, member); \
+ first_ = (list)->first; \
+ slist_end(first_) ? NULL : slist_entry(first_, type, member); \
MACRO_END
/*
@@ -237,23 +237,23 @@ MACRO_END
*/
#define slist_last_entry(list, type, member) \
MACRO_BEGIN \
- struct slist_node *last___; \
+ struct slist_node *last_; \
\
- last___ = (list)->last; \
- slist_end(last___) ? NULL : slist_entry(last___, type, member); \
+ last_ = (list)->last; \
+ slist_end(last_) ? NULL : slist_entry(last_, type, member); \
MACRO_END
/*
* Get the entry next to the given entry.
*/
-#define slist_next_entry(entry, member) \
+#define slist_next_entry(entry, member) \
MACRO_BEGIN \
- struct slist_node *next___; \
+ struct slist_node *next_; \
\
- next___ = (entry)->member.next; \
- slist_end(next___) \
+ next_ = (entry)->member.next; \
+ slist_end(next_) \
? NULL \
- : slist_entry(next___, typeof(*entry), member); \
+ : slist_entry(next_, typeof(*entry), member); \
MACRO_END
/*
@@ -409,10 +409,10 @@ slist_rcu_remove(struct slist *list, struct slist_node *prev)
*/
#define slist_rcu_first_entry(list, type, member) \
MACRO_BEGIN \
- struct slist_node *first___; \
+ struct slist_node *first_; \
\
- first___ = slist_rcu_first(list); \
- slist_end(first___) ? NULL : slist_entry(first___, type, member); \
+ first_ = slist_rcu_first(list); \
+ slist_end(first_) ? NULL : slist_entry(first_, type, member); \
MACRO_END
/*
@@ -420,12 +420,12 @@ MACRO_END
*/
#define slist_rcu_next_entry(entry, member) \
MACRO_BEGIN \
- struct slist_node *next___; \
+ struct slist_node *next_; \
\
- next___ = slist_rcu_next(&entry->member); \
- slist_end(next___) \
+ next_ = slist_rcu_next(&entry->member); \
+ slist_end(next_) \
? NULL \
- : slist_entry(next___, typeof(*entry), member); \
+ : slist_entry(next_, typeof(*entry), member); \
MACRO_END
/*