projects
/
userspace-rcu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix: sysconf(_SC_NPROCESSORS_CONF) can be less than max cpu id
[userspace-rcu.git]
/
src
/
urcu-call-rcu-impl.h
diff --git
a/src/urcu-call-rcu-impl.h
b/src/urcu-call-rcu-impl.h
index 136337290ce07be59e524d971b320e4b8fc28912..0c252c12133ed4f3fa1cf7edede849455178569d 100644
(file)
--- a/
src/urcu-call-rcu-impl.h
+++ b/
src/urcu-call-rcu-impl.h
@@
-44,6
+44,7
@@
#include <urcu/ref.h>
#include "urcu-die.h"
#include "urcu-utils.h"
#include <urcu/ref.h>
#include "urcu-die.h"
#include "urcu-utils.h"
+#include "compat-smp.h"
#define SET_AFFINITY_CHECK_PERIOD (1U << 8) /* 256 */
#define SET_AFFINITY_CHECK_PERIOD_MASK (SET_AFFINITY_CHECK_PERIOD - 1)
#define SET_AFFINITY_CHECK_PERIOD (1U << 8) /* 256 */
#define SET_AFFINITY_CHECK_PERIOD_MASK (SET_AFFINITY_CHECK_PERIOD - 1)
@@
-120,11
+121,11
@@
static unsigned long registered_rculfhash_atfork_refcount;
*/
static struct call_rcu_data **per_cpu_call_rcu_data;
*/
static struct call_rcu_data **per_cpu_call_rcu_data;
-static long
maxcpus
;
+static long
cpus_array_len
;
-static void
maxcpus
_reset(void)
+static void
cpus_array_len
_reset(void)
{
{
-
maxcpus
= 0;
+
cpus_array_len
= 0;
}
/* Allocate the array if it has not already been allocated. */
}
/* Allocate the array if it has not already been allocated. */
@@
-134,15
+135,15
@@
static void alloc_cpu_call_rcu_data(void)
struct call_rcu_data **p;
static int warned = 0;
struct call_rcu_data **p;
static int warned = 0;
- if (
maxcpus
!= 0)
+ if (
cpus_array_len
!= 0)
return;
return;
-
maxcpus = sysconf(_SC_NPROCESSORS_CONF
);
- if (
maxcpus
<= 0) {
+
cpus_array_len = get_possible_cpus_array_len(
);
+ if (
cpus_array_len
<= 0) {
return;
}
return;
}
- p = malloc(
maxcpus
* sizeof(*per_cpu_call_rcu_data));
+ p = malloc(
cpus_array_len
* sizeof(*per_cpu_call_rcu_data));
if (p != NULL) {
if (p != NULL) {
- memset(p, '\0',
maxcpus
* sizeof(*per_cpu_call_rcu_data));
+ memset(p, '\0',
cpus_array_len
* sizeof(*per_cpu_call_rcu_data));
rcu_set_pointer(&per_cpu_call_rcu_data, p);
} else {
if (!warned) {
rcu_set_pointer(&per_cpu_call_rcu_data, p);
} else {
if (!warned) {
@@
-160,9
+161,9
@@
static void alloc_cpu_call_rcu_data(void)
* constant.
*/
static struct call_rcu_data **per_cpu_call_rcu_data = NULL;
* constant.
*/
static struct call_rcu_data **per_cpu_call_rcu_data = NULL;
-static const long
maxcpus
= -1;
+static const long
cpus_array_len
= -1;
-static void
maxcpus
_reset(void)
+static void
cpus_array_len
_reset(void)
{
}
{
}
@@
-470,11
+471,11
@@
struct call_rcu_data *get_cpu_call_rcu_data(int cpu)
pcpu_crdp = rcu_dereference(per_cpu_call_rcu_data);
if (pcpu_crdp == NULL)
return NULL;
pcpu_crdp = rcu_dereference(per_cpu_call_rcu_data);
if (pcpu_crdp == NULL)
return NULL;
- if (!warned &&
maxcpus > 0 && (cpu < 0 || maxcpus
<= cpu)) {
+ if (!warned &&
cpus_array_len > 0 && (cpu < 0 || cpus_array_len
<= cpu)) {
fprintf(stderr, "[error] liburcu: get CPU # out of range\n");
warned = 1;
}
fprintf(stderr, "[error] liburcu: get CPU # out of range\n");
warned = 1;
}
- if (cpu < 0 ||
maxcpus
<= cpu)
+ if (cpu < 0 ||
cpus_array_len
<= cpu)
return NULL;
return rcu_dereference(pcpu_crdp[cpu]);
}
return NULL;
return rcu_dereference(pcpu_crdp[cpu]);
}
@@
-532,7
+533,7
@@
int set_cpu_call_rcu_data(int cpu, struct call_rcu_data *crdp)
call_rcu_lock(&call_rcu_mutex);
alloc_cpu_call_rcu_data();
call_rcu_lock(&call_rcu_mutex);
alloc_cpu_call_rcu_data();
- if (cpu < 0 ||
maxcpus
<= cpu) {
+ if (cpu < 0 ||
cpus_array_len
<= cpu) {
if (!warned) {
fprintf(stderr, "[error] liburcu: set CPU # out of range\n");
warned = 1;
if (!warned) {
fprintf(stderr, "[error] liburcu: set CPU # out of range\n");
warned = 1;
@@
-597,7
+598,7
@@
struct call_rcu_data *get_call_rcu_data(void)
if (URCU_TLS(thread_call_rcu_data) != NULL)
return URCU_TLS(thread_call_rcu_data);
if (URCU_TLS(thread_call_rcu_data) != NULL)
return URCU_TLS(thread_call_rcu_data);
- if (
maxcpus
> 0) {
+ if (
cpus_array_len
> 0) {
crd = get_cpu_call_rcu_data(urcu_sched_getcpu());
if (crd)
return crd;
crd = get_cpu_call_rcu_data(urcu_sched_getcpu());
if (crd)
return crd;
@@
-648,7
+649,7
@@
int create_all_cpu_call_rcu_data(unsigned long flags)
call_rcu_lock(&call_rcu_mutex);
alloc_cpu_call_rcu_data();
call_rcu_unlock(&call_rcu_mutex);
call_rcu_lock(&call_rcu_mutex);
alloc_cpu_call_rcu_data();
call_rcu_unlock(&call_rcu_mutex);
- if (
maxcpus
<= 0) {
+ if (
cpus_array_len
<= 0) {
errno = EINVAL;
return -EINVAL;
}
errno = EINVAL;
return -EINVAL;
}
@@
-656,7
+657,7
@@
int create_all_cpu_call_rcu_data(unsigned long flags)
errno = ENOMEM;
return -ENOMEM;
}
errno = ENOMEM;
return -ENOMEM;
}
- for (i = 0; i <
maxcpus
; i++) {
+ for (i = 0; i <
cpus_array_len
; i++) {
call_rcu_lock(&call_rcu_mutex);
if (get_cpu_call_rcu_data(i)) {
call_rcu_unlock(&call_rcu_mutex);
call_rcu_lock(&call_rcu_mutex);
if (get_cpu_call_rcu_data(i)) {
call_rcu_unlock(&call_rcu_mutex);
@@
-796,10
+797,10
@@
void free_all_cpu_call_rcu_data(void)
struct call_rcu_data **crdp;
static int warned = 0;
struct call_rcu_data **crdp;
static int warned = 0;
- if (
maxcpus
<= 0)
+ if (
cpus_array_len
<= 0)
return;
return;
- crdp = malloc(sizeof(*crdp) *
maxcpus
);
+ crdp = malloc(sizeof(*crdp) *
cpus_array_len
);
if (!crdp) {
if (!warned) {
fprintf(stderr, "[error] liburcu: unable to allocate per-CPU pointer array\n");
if (!crdp) {
if (!warned) {
fprintf(stderr, "[error] liburcu: unable to allocate per-CPU pointer array\n");
@@
-808,7
+809,7
@@
void free_all_cpu_call_rcu_data(void)
return;
}
return;
}
- for (cpu = 0; cpu <
maxcpus
; cpu++) {
+ for (cpu = 0; cpu <
cpus_array_len
; cpu++) {
crdp[cpu] = get_cpu_call_rcu_data(cpu);
if (crdp[cpu] == NULL)
continue;
crdp[cpu] = get_cpu_call_rcu_data(cpu);
if (crdp[cpu] == NULL)
continue;
@@
-819,7
+820,7
@@
void free_all_cpu_call_rcu_data(void)
* call_rcu_data to become quiescent.
*/
synchronize_rcu();
* call_rcu_data to become quiescent.
*/
synchronize_rcu();
- for (cpu = 0; cpu <
maxcpus
; cpu++) {
+ for (cpu = 0; cpu <
cpus_array_len
; cpu++) {
if (crdp[cpu] == NULL)
continue;
call_rcu_data_free(crdp[cpu]);
if (crdp[cpu] == NULL)
continue;
call_rcu_data_free(crdp[cpu]);
@@
-997,7
+998,7
@@
void call_rcu_after_fork_child(void)
(void)get_default_call_rcu_data();
/* Cleanup call_rcu_data pointers before use */
(void)get_default_call_rcu_data();
/* Cleanup call_rcu_data pointers before use */
-
maxcpus
_reset();
+
cpus_array_len
_reset();
free(per_cpu_call_rcu_data);
rcu_set_pointer(&per_cpu_call_rcu_data, NULL);
URCU_TLS(thread_call_rcu_data) = NULL;
free(per_cpu_call_rcu_data);
rcu_set_pointer(&per_cpu_call_rcu_data, NULL);
URCU_TLS(thread_call_rcu_data) = NULL;
This page took
0.025316 seconds
and
4
git commands to generate.