Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LU-6285 libcfs: get rid of deprecated cpumask function usage
[fs/lustre-release.git]
/
libcfs
/
libcfs
/
linux
/
linux-cpu.c
diff --git
a/libcfs/libcfs/linux/linux-cpu.c
b/libcfs/libcfs/linux/linux-cpu.c
index
6e879d4
..
cfc53f1
100644
(file)
--- a/
libcfs/libcfs/linux/linux-cpu.c
+++ b/
libcfs/libcfs/linux/linux-cpu.c
@@
-96,7
+96,7
@@
cfs_cpu_core_nsiblings(int cpu)
mutex_lock(&cpt_data.cpt_mutex);
cfs_cpu_core_siblings(cpu, cpt_data.cpt_cpumask);
mutex_lock(&cpt_data.cpt_mutex);
cfs_cpu_core_siblings(cpu, cpt_data.cpt_cpumask);
- num = cpu
s_weight(*
cpt_data.cpt_cpumask);
+ num = cpu
mask_weight(
cpt_data.cpt_cpumask);
mutex_unlock(&cpt_data.cpt_mutex);
mutex_unlock(&cpt_data.cpt_mutex);
@@
-118,7
+118,7
@@
cfs_cpu_ht_nsiblings(int cpu)
{
int num;
{
int num;
- num = cpu
s_weight(*
topology_thread_cpumask(cpu));
+ num = cpu
mask_weight(
topology_thread_cpumask(cpu));
return num;
}
return num;
}
@@
-245,7
+245,7
@@
cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
}
tmp += rc;
}
tmp += rc;
- for_each_cpu
_mask(j, *
cptab->ctb_parts[i].cpt_cpumask) {
+ for_each_cpu
(j,
cptab->ctb_parts[i].cpt_cpumask) {
rc = snprintf(tmp, len, "%d ", j);
len -= rc;
if (len <= 0) {
rc = snprintf(tmp, len, "%d ", j);
len -= rc;
if (len <= 0) {
@@
-281,8
+281,8
@@
cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
return cpt == CFS_CPT_ANY ?
LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
return cpt == CFS_CPT_ANY ?
- cpu
s_weight(*
cptab->ctb_cpumask) :
- cpu
s_weight(*
cptab->ctb_parts[cpt].cpt_cpumask);
+ cpu
mask_weight(
cptab->ctb_cpumask) :
+ cpu
mask_weight(
cptab->ctb_parts[cpt].cpt_cpumask);
}
EXPORT_SYMBOL(cfs_cpt_weight);
}
EXPORT_SYMBOL(cfs_cpt_weight);
@@
-292,8
+292,10
@@
cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
return cpt == CFS_CPT_ANY ?
LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
return cpt == CFS_CPT_ANY ?
- any_online_cpu(*cptab->ctb_cpumask) != NR_CPUS :
- any_online_cpu(*cptab->ctb_parts[cpt].cpt_cpumask) != NR_CPUS;
+ cpumask_any_and(cptab->ctb_cpumask,
+ cpu_online_mask) < nr_cpu_ids :
+ cpumask_any_and(cptab->ctb_parts[cpt].cpt_cpumask,
+ cpu_online_mask) < nr_cpu_ids;
}
EXPORT_SYMBOL(cfs_cpt_online);
}
EXPORT_SYMBOL(cfs_cpt_online);
@@
-324,7
+326,7
@@
cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
LASSERT(cpt >= 0 && cpt < cptab->ctb_nparts);
LASSERT(cpt >= 0 && cpt < cptab->ctb_nparts);
- if (cpu < 0 || cpu >=
NR_CPUS
|| !cpu_online(cpu)) {
+ if (cpu < 0 || cpu >=
nr_cpu_ids
|| !cpu_online(cpu)) {
CDEBUG(D_INFO, "CPU %d is invalid or it's offline\n", cpu);
return 0;
}
CDEBUG(D_INFO, "CPU %d is invalid or it's offline\n", cpu);
return 0;
}
@@
-337,11
+339,11
@@
cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
cptab->ctb_cpu2cpt[cpu] = cpt;
cptab->ctb_cpu2cpt[cpu] = cpt;
- LASSERT(!cpu
_isset(cpu, *
cptab->ctb_cpumask));
- LASSERT(!cpu
_isset(cpu, *
cptab->ctb_parts[cpt].cpt_cpumask));
+ LASSERT(!cpu
mask_test_cpu(cpu,
cptab->ctb_cpumask));
+ LASSERT(!cpu
mask_test_cpu(cpu,
cptab->ctb_parts[cpt].cpt_cpumask));
- cpu
_set(cpu, *
cptab->ctb_cpumask);
- cpu
_set(cpu, *
cptab->ctb_parts[cpt].cpt_cpumask);
+ cpu
mask_set_cpu(cpu,
cptab->ctb_cpumask);
+ cpu
mask_set_cpu(cpu,
cptab->ctb_parts[cpt].cpt_cpumask);
node = cpu_to_node(cpu);
node = cpu_to_node(cpu);
@@
-365,7
+367,7
@@
cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
- if (cpu < 0 || cpu >=
NR_CPUS
) {
+ if (cpu < 0 || cpu >=
nr_cpu_ids
) {
CDEBUG(D_INFO, "Invalid CPU id %d\n", cpu);
return;
}
CDEBUG(D_INFO, "Invalid CPU id %d\n", cpu);
return;
}
@@
-385,11
+387,11
@@
cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
return;
}
return;
}
- LASSERT(cpu
_isset(cpu, *
cptab->ctb_parts[cpt].cpt_cpumask));
- LASSERT(cpu
_isset(cpu, *
cptab->ctb_cpumask));
+ LASSERT(cpu
mask_test_cpu(cpu,
cptab->ctb_parts[cpt].cpt_cpumask));
+ LASSERT(cpu
mask_test_cpu(cpu,
cptab->ctb_cpumask));
- cpu
_clear(cpu, *
cptab->ctb_parts[cpt].cpt_cpumask);
- cpu
_clear(cpu, *
cptab->ctb_cpumask);
+ cpu
mask_clear_cpu(cpu,
cptab->ctb_parts[cpt].cpt_cpumask);
+ cpu
mask_clear_cpu(cpu,
cptab->ctb_cpumask);
cptab->ctb_cpu2cpt[cpu] = -1;
node = cpu_to_node(cpu);
cptab->ctb_cpu2cpt[cpu] = -1;
node = cpu_to_node(cpu);
@@
-397,22
+399,22
@@
cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
LASSERT(node_isset(node, *cptab->ctb_parts[cpt].cpt_nodemask));
LASSERT(node_isset(node, *cptab->ctb_nodemask));
LASSERT(node_isset(node, *cptab->ctb_parts[cpt].cpt_nodemask));
LASSERT(node_isset(node, *cptab->ctb_nodemask));
- for_each_cpu
_mask(i, *
cptab->ctb_parts[cpt].cpt_cpumask) {
+ for_each_cpu
(i,
cptab->ctb_parts[cpt].cpt_cpumask) {
/* this CPT has other CPU belonging to this node? */
if (cpu_to_node(i) == node)
break;
}
/* this CPT has other CPU belonging to this node? */
if (cpu_to_node(i) == node)
break;
}
- if (i
== NR_CPUS
)
+ if (i
>= nr_cpu_ids
)
node_clear(node, *cptab->ctb_parts[cpt].cpt_nodemask);
node_clear(node, *cptab->ctb_parts[cpt].cpt_nodemask);
- for_each_cpu
_mask(i, *
cptab->ctb_cpumask) {
+ for_each_cpu
(i,
cptab->ctb_cpumask) {
/* this CPT-table has other CPU belonging to this node? */
if (cpu_to_node(i) == node)
break;
}
/* this CPT-table has other CPU belonging to this node? */
if (cpu_to_node(i) == node)
break;
}
- if (i
== NR_CPUS
)
+ if (i
>= nr_cpu_ids
)
node_clear(node, *cptab->ctb_nodemask);
return;
node_clear(node, *cptab->ctb_nodemask);
return;
@@
-424,13
+426,14
@@
cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
{
int i;
{
int i;
- if (cpus_weight(*mask) == 0 || any_online_cpu(*mask) == NR_CPUS) {
+ if (cpumask_weight(mask) == 0 ||
+ cpumask_any_and(mask, cpu_online_mask) >= nr_cpu_ids) {
CDEBUG(D_INFO, "No online CPU is found in the CPU mask "
"for CPU partition %d\n", cpt);
return 0;
}
CDEBUG(D_INFO, "No online CPU is found in the CPU mask "
"for CPU partition %d\n", cpt);
return 0;
}
- for_each_cpu
_mask(i, *
mask) {
+ for_each_cpu
(i,
mask) {
if (!cfs_cpt_set_cpu(cptab, cpt, i))
return 0;
}
if (!cfs_cpt_set_cpu(cptab, cpt, i))
return 0;
}
@@
-444,7
+447,7
@@
cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
{
int i;
{
int i;
- for_each_cpu
_mask(i, *
mask)
+ for_each_cpu
(i,
mask)
cfs_cpt_unset_cpu(cptab, cpt, i);
}
EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
cfs_cpt_unset_cpu(cptab, cpt, i);
}
EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
@@
-534,7
+537,7
@@
cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
}
for (; cpt <= last; cpt++) {
}
for (; cpt <= last; cpt++) {
- for_each_cpu
_mask(i, *
cptab->ctb_parts[cpt].cpt_cpumask)
+ for_each_cpu
(i,
cptab->ctb_parts[cpt].cpt_cpumask)
cfs_cpt_unset_cpu(cptab, cpt, i);
}
}
cfs_cpt_unset_cpu(cptab, cpt, i);
}
}
@@
-595,7
+598,7
@@
EXPORT_SYMBOL(cfs_cpt_current);
int
cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu)
{
int
cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu)
{
- LASSERT(cpu >= 0 && cpu <
NR_CPUS
);
+ LASSERT(cpu >= 0 && cpu <
nr_cpu_ids
);
return cptab->ctb_cpu2cpt[cpu];
}
return cptab->ctb_cpu2cpt[cpu];
}
@@
-619,7
+622,7
@@
cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
nodemask = cptab->ctb_parts[cpt].cpt_nodemask;
}
nodemask = cptab->ctb_parts[cpt].cpt_nodemask;
}
- if (
any_online_cpu(*cpumask) == NR_CPUS
) {
+ if (
cpumask_any_and(cpumask, cpu_online_mask) >= nr_cpu_ids
) {
CERROR("No online CPU found in CPU partition %d, did someone "
"do CPU hotplug on system? You might need to reload "
"Lustre modules to keep system working well.\n", cpt);
CERROR("No online CPU found in CPU partition %d, did someone "
"do CPU hotplug on system? You might need to reload "
"Lustre modules to keep system working well.\n", cpt);
@@
-627,7
+630,7
@@
cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
}
for_each_online_cpu(i) {
}
for_each_online_cpu(i) {
- if (cpu
_isset(i, *
cpumask))
+ if (cpu
mask_test_cpu(i,
cpumask))
continue;
rc = set_cpus_allowed_ptr(current, cpumask);
continue;
rc = set_cpus_allowed_ptr(current, cpumask);
@@
-658,14
+661,14
@@
cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
LASSERT(number > 0);
LASSERT(number > 0);
- if (number >= cpu
s_weight(*
node)) {
- while (!cpu
s_empty(*
node)) {
- cpu =
first_cpu(*
node);
+ if (number >= cpu
mask_weight(
node)) {
+ while (!cpu
mask_empty(
node)) {
+ cpu =
cpumask_first(
node);
rc = cfs_cpt_set_cpu(cptab, cpt, cpu);
if (!rc)
return -EINVAL;
rc = cfs_cpt_set_cpu(cptab, cpt, cpu);
if (!rc)
return -EINVAL;
- cpu
_clear(cpu, *
node);
+ cpu
mask_clear_cpu(cpu,
node);
}
return 0;
}
}
return 0;
}
@@
-678,27
+681,27
@@
cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
goto out;
}
goto out;
}
- while (!cpu
s_empty(*
node)) {
- cpu =
first_cpu(*
node);
+ while (!cpu
mask_empty(
node)) {
+ cpu =
cpumask_first(
node);
/* get cpumask for cores in the same socket */
cfs_cpu_core_siblings(cpu, socket);
/* get cpumask for cores in the same socket */
cfs_cpu_core_siblings(cpu, socket);
- cpu
s_and(*socket, *socket, *
node);
+ cpu
mask_and(socket, socket,
node);
- LASSERT(!cpu
s_empty(*
socket));
+ LASSERT(!cpu
mask_empty(
socket));
- while (!cpu
s_empty(*
socket)) {
+ while (!cpu
mask_empty(
socket)) {
int i;
/* get cpumask for hts in the same core */
cfs_cpu_ht_siblings(cpu, core);
int i;
/* get cpumask for hts in the same core */
cfs_cpu_ht_siblings(cpu, core);
- cpu
s_and(*core, *core, *
node);
+ cpu
mask_and(core, core,
node);
- LASSERT(!cpu
s_empty(*
core));
+ LASSERT(!cpu
mask_empty(
core));
- for_each_cpu
_mask(i, *
core) {
- cpu
_clear(i, *
socket);
- cpu
_clear(i, *
node);
+ for_each_cpu
(i,
core) {
+ cpu
mask_clear_cpu(i,
socket);
+ cpu
mask_clear_cpu(i,
node);
rc = cfs_cpt_set_cpu(cptab, cpt, i);
if (!rc) {
rc = cfs_cpt_set_cpu(cptab, cpt, i);
if (!rc) {
@@
-709,7
+712,7
@@
cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
if (--number == 0)
goto out;
}
if (--number == 0)
goto out;
}
- cpu =
first_cpu(*
socket);
+ cpu =
cpumask_first(
socket);
}
}
}
}
@@
-813,7
+816,7
@@
cfs_cpt_table_create(int ncpt)
for_each_online_node(i) {
cfs_node_to_cpumask(i, mask);
for_each_online_node(i) {
cfs_node_to_cpumask(i, mask);
- while (!cpu
s_empty(*
mask)) {
+ while (!cpu
mask_empty(
mask)) {
struct cfs_cpu_partition *part;
int n;
struct cfs_cpu_partition *part;
int n;
@@
-826,25
+829,25
@@
cfs_cpt_table_create(int ncpt)
part = &cptab->ctb_parts[cpt];
part = &cptab->ctb_parts[cpt];
- n = num - cpu
s_weight(*
part->cpt_cpumask);
+ n = num - cpu
mask_weight(
part->cpt_cpumask);
LASSERT(n > 0);
rc = cfs_cpt_choose_ncpus(cptab, cpt, mask, n);
if (rc < 0)
goto failed;
LASSERT(n > 0);
rc = cfs_cpt_choose_ncpus(cptab, cpt, mask, n);
if (rc < 0)
goto failed;
- LASSERT(num >= cpu
s_weight(*
part->cpt_cpumask));
- if (num == cpu
s_weight(*
part->cpt_cpumask))
+ LASSERT(num >= cpu
mask_weight(
part->cpt_cpumask));
+ if (num == cpu
mask_weight(
part->cpt_cpumask))
cpt++;
}
}
if (cpt != ncpt ||
cpt++;
}
}
if (cpt != ncpt ||
- num != cpu
s_weight(*
cptab->ctb_parts[ncpt - 1].cpt_cpumask)) {
+ num != cpu
mask_weight(
cptab->ctb_parts[ncpt - 1].cpt_cpumask)) {
CERROR("Expect %d(%d) CPU partitions but got %d(%d), "
"CPU hotplug/unplug while setting?\n",
cptab->ctb_nparts, num, cpt,
CERROR("Expect %d(%d) CPU partitions but got %d(%d), "
"CPU hotplug/unplug while setting?\n",
cptab->ctb_nparts, num, cpt,
- cpu
s_weight(*
cptab->ctb_parts[ncpt - 1].cpt_cpumask));
+ cpu
mask_weight(
cptab->ctb_parts[ncpt - 1].cpt_cpumask));
goto failed;
}
goto failed;
}
@@
-1040,7
+1043,8
@@
cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu)
mutex_lock(&cpt_data.cpt_mutex);
/* if all HTs in a core are offline, it may break affinity */
cfs_cpu_ht_siblings(cpu, cpt_data.cpt_cpumask);
mutex_lock(&cpt_data.cpt_mutex);
/* if all HTs in a core are offline, it may break affinity */
cfs_cpu_ht_siblings(cpu, cpt_data.cpt_cpumask);
- warn = any_online_cpu(*cpt_data.cpt_cpumask) >= nr_cpu_ids;
+ warn = cpumask_any_and(cpt_data.cpt_cpumask,
+ cpu_online_mask) >= nr_cpu_ids;
mutex_unlock(&cpt_data.cpt_mutex);
CDEBUG(warn ? D_WARNING : D_INFO,
"Lustre: can't support CPU plug-out well now, "
mutex_unlock(&cpt_data.cpt_mutex);
CDEBUG(warn ? D_WARNING : D_INFO,
"Lustre: can't support CPU plug-out well now, "