projects
/
userspace-rcu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use get_cpu_call_rcu_data() for get_call_rcu_data()
[userspace-rcu.git]
/
urcu-call-rcu-impl.h
diff --git
a/urcu-call-rcu-impl.h
b/urcu-call-rcu-impl.h
index b9e57cd60a2ba731a2030cd36c9b9b6c211c416e..1fbce98e27cda467c9419e297275f01ad8e535fa 100644
(file)
--- a/
urcu-call-rcu-impl.h
+++ b/
urcu-call-rcu-impl.h
@@
-215,6
+215,11
@@
static void *call_rcu_thread(void *arg)
exit(-1);
}
exit(-1);
}
+ /*
+ * If callbacks take a read-side lock, we need to be registered.
+ */
+ rcu_register_thread();
+
thread_call_rcu_data = crdp;
if (!rt) {
uatomic_dec(&crdp->futex);
thread_call_rcu_data = crdp;
if (!rt) {
uatomic_dec(&crdp->futex);
@@
-247,6
+252,7
@@
static void *call_rcu_thread(void *arg)
}
if (uatomic_read(&crdp->flags) & URCU_CALL_RCU_STOP)
break;
}
if (uatomic_read(&crdp->flags) & URCU_CALL_RCU_STOP)
break;
+ rcu_thread_offline();
if (!rt) {
if (&crdp->cbs.head
== _CMM_LOAD_SHARED(crdp->cbs.tail)) {
if (!rt) {
if (&crdp->cbs.head
== _CMM_LOAD_SHARED(crdp->cbs.tail)) {
@@
-264,6
+270,7
@@
static void *call_rcu_thread(void *arg)
} else {
poll(NULL, 0, 10);
}
} else {
poll(NULL, 0, 10);
}
+ rcu_thread_online();
}
if (!rt) {
/*
}
if (!rt) {
/*
@@
-273,6
+280,7
@@
static void *call_rcu_thread(void *arg)
uatomic_set(&crdp->futex, 0);
}
uatomic_or(&crdp->flags, URCU_CALL_RCU_STOPPED);
uatomic_set(&crdp->futex, 0);
}
uatomic_or(&crdp->flags, URCU_CALL_RCU_STOPPED);
+ rcu_unregister_thread();
return NULL;
}
return NULL;
}
@@
-375,9
+383,10
@@
struct call_rcu_data *create_call_rcu_data(unsigned long flags,
int set_cpu_call_rcu_data(int cpu, struct call_rcu_data *crdp)
{
int set_cpu_call_rcu_data(int cpu, struct call_rcu_data *crdp)
{
- int warned = 0;
+
static
int warned = 0;
call_rcu_lock(&call_rcu_mutex);
call_rcu_lock(&call_rcu_mutex);
+ alloc_cpu_call_rcu_data();
if (cpu < 0 || maxcpus <= cpu) {
if (!warned) {
fprintf(stderr, "[error] liburcu: set CPU # out of range\n");
if (cpu < 0 || maxcpus <= cpu) {
if (!warned) {
fprintf(stderr, "[error] liburcu: set CPU # out of range\n");
@@
-387,7
+396,6
@@
int set_cpu_call_rcu_data(int cpu, struct call_rcu_data *crdp)
errno = EINVAL;
return -EINVAL;
}
errno = EINVAL;
return -EINVAL;
}
- alloc_cpu_call_rcu_data();
call_rcu_unlock(&call_rcu_mutex);
if (per_cpu_call_rcu_data == NULL) {
errno = ENOMEM;
call_rcu_unlock(&call_rcu_mutex);
if (per_cpu_call_rcu_data == NULL) {
errno = ENOMEM;
@@
-427,22
+435,17
@@
struct call_rcu_data *get_default_call_rcu_data(void)
*/
struct call_rcu_data *get_call_rcu_data(void)
{
*/
struct call_rcu_data *get_call_rcu_data(void)
{
- int curcpu;
- static int warned = 0;
+ struct call_rcu_data *crd;
if (thread_call_rcu_data != NULL)
return thread_call_rcu_data;
if (thread_call_rcu_data != NULL)
return thread_call_rcu_data;
- if (maxcpus <= 0)
- return get_default_call_rcu_data();
- curcpu = sched_getcpu();
- if (!warned && (curcpu < 0 || maxcpus <= curcpu)) {
- fprintf(stderr, "[error] liburcu: gcrd CPU # out of range\n");
- warned = 1;
+
+ if (maxcpus > 0) {
+ crd = get_cpu_call_rcu_data(sched_getcpu());
+ if (crd)
+ return crd;
}
}
- if (curcpu >= 0 && maxcpus > curcpu &&
- per_cpu_call_rcu_data != NULL &&
- per_cpu_call_rcu_data[curcpu] != NULL)
- return per_cpu_call_rcu_data[curcpu];
+
return get_default_call_rcu_data();
}
return get_default_call_rcu_data();
}
@@
-474,7
+477,9
@@
void set_thread_call_rcu_data(struct call_rcu_data *crdp)
/*
* Create a separate call_rcu thread for each CPU. This does not
* replace a pre-existing call_rcu thread -- use the set_cpu_call_rcu_data()
/*
* Create a separate call_rcu thread for each CPU. This does not
* replace a pre-existing call_rcu thread -- use the set_cpu_call_rcu_data()
- * function if you want that behavior.
+ * function if you want that behavior. Should be paired with
+ * free_all_cpu_call_rcu_data() to teardown these call_rcu worker
+ * threads.
*/
int create_all_cpu_call_rcu_data(unsigned long flags)
*/
int create_all_cpu_call_rcu_data(unsigned long flags)
This page took
0.023984 seconds
and
4
git commands to generate.