Commit c96d236f authored by Oleg Drokin's avatar Oleg Drokin Committed by Greg Kroah-Hartman

staging/lustre/libcfs: replace deprecated cpus_ calls with cpumask_

Rusty Russel advises that cpus_* functions are deprecated to work
on cpumasks and cpumask_* functions should be called instead,
otherwise problems with CPUMASK_OFFSTACK arise.
Signed-off-by: default avatarOleg Drokin <green@linuxhacker.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6301647b
...@@ -240,8 +240,8 @@ cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt) ...@@ -240,8 +240,8 @@ cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts)); LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
return cpt == CFS_CPT_ANY ? return cpt == CFS_CPT_ANY ?
cpus_weight(*cptab->ctb_cpumask) : cpumask_weight(cptab->ctb_cpumask) :
cpus_weight(*cptab->ctb_parts[cpt].cpt_cpumask); cpumask_weight(cptab->ctb_parts[cpt].cpt_cpumask);
} }
EXPORT_SYMBOL(cfs_cpt_weight); EXPORT_SYMBOL(cfs_cpt_weight);
...@@ -251,8 +251,8 @@ cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt) ...@@ -251,8 +251,8 @@ cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts)); LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
return cpt == CFS_CPT_ANY ? return cpt == CFS_CPT_ANY ?
any_online_cpu(*cptab->ctb_cpumask) != NR_CPUS : any_online_cpu(*cptab->ctb_cpumask) < nr_cpu_ids :
any_online_cpu(*cptab->ctb_parts[cpt].cpt_cpumask) != NR_CPUS; any_online_cpu(*cptab->ctb_parts[cpt].cpt_cpumask) < nr_cpu_ids;
} }
EXPORT_SYMBOL(cfs_cpt_online); EXPORT_SYMBOL(cfs_cpt_online);
...@@ -283,7 +283,7 @@ cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) ...@@ -283,7 +283,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); CDEBUG(D_INFO, "CPU %d is invalid or it's offline\n", cpu);
return 0; return 0;
} }
...@@ -296,11 +296,11 @@ cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) ...@@ -296,11 +296,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(!cpumask_test_cpu(cpu, cptab->ctb_cpumask));
LASSERT(!cpu_isset(cpu, *cptab->ctb_parts[cpt].cpt_cpumask)); LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask));
cpu_set(cpu, *cptab->ctb_cpumask); cpumask_set_cpu(cpu, cptab->ctb_cpumask);
cpu_set(cpu, *cptab->ctb_parts[cpt].cpt_cpumask); cpumask_set_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
node = cpu_to_node(cpu); node = cpu_to_node(cpu);
...@@ -324,7 +324,7 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) ...@@ -324,7 +324,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); CDEBUG(D_INFO, "Invalid CPU id %d\n", cpu);
return; return;
} }
...@@ -344,11 +344,11 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) ...@@ -344,11 +344,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(cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask));
LASSERT(cpu_isset(cpu, *cptab->ctb_cpumask)); LASSERT(cpumask_test_cpu(cpu, cptab->ctb_cpumask));
cpu_clear(cpu, *cptab->ctb_parts[cpt].cpt_cpumask); cpumask_clear_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
cpu_clear(cpu, *cptab->ctb_cpumask); cpumask_clear_cpu(cpu, cptab->ctb_cpumask);
cptab->ctb_cpu2cpt[cpu] = -1; cptab->ctb_cpu2cpt[cpu] = -1;
node = cpu_to_node(cpu); node = cpu_to_node(cpu);
...@@ -383,7 +383,7 @@ cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask) ...@@ -383,7 +383,7 @@ 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 || any_online_cpu(*mask) >= nr_cpu_ids) {
CDEBUG(D_INFO, "No online CPU is found in the CPU mask for CPU partition %d\n", CDEBUG(D_INFO, "No online CPU is found in the CPU mask for CPU partition %d\n",
cpt); cpt);
return 0; return 0;
...@@ -554,7 +554,7 @@ EXPORT_SYMBOL(cfs_cpt_current); ...@@ -554,7 +554,7 @@ EXPORT_SYMBOL(cfs_cpt_current);
int int
cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu) 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];
} }
...@@ -578,14 +578,14 @@ cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt) ...@@ -578,14 +578,14 @@ 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 (any_online_cpu(*cpumask) >= 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", 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); cpt);
return -EINVAL; return -EINVAL;
} }
for_each_online_cpu(i) { for_each_online_cpu(i) {
if (cpu_isset(i, *cpumask)) if (cpumask_test_cpu(i, cpumask))
continue; continue;
rc = set_cpus_allowed_ptr(current, cpumask); rc = set_cpus_allowed_ptr(current, cpumask);
...@@ -616,14 +616,14 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, ...@@ -616,14 +616,14 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
LASSERT(number > 0); LASSERT(number > 0);
if (number >= cpus_weight(*node)) { if (number >= cpumask_weight(node)) {
while (!cpus_empty(*node)) { while (!cpumask_empty(node)) {
cpu = first_cpu(*node); cpu = cpumask_first(node);
rc = cfs_cpt_set_cpu(cptab, cpt, cpu); rc = cfs_cpt_set_cpu(cptab, cpt, cpu);
if (!rc) if (!rc)
return -EINVAL; return -EINVAL;
cpu_clear(cpu, *node); cpumask_clear_cpu(cpu, node);
} }
return 0; return 0;
} }
...@@ -636,27 +636,27 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, ...@@ -636,27 +636,27 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
goto out; goto out;
} }
while (!cpus_empty(*node)) { while (!cpumask_empty(node)) {
cpu = first_cpu(*node); cpu = cpumask_first(node);
/* get cpumask for cores in the same socket */ /* get cpumask for cores in the same socket */
cfs_cpu_core_siblings(cpu, socket); cfs_cpu_core_siblings(cpu, socket);
cpus_and(*socket, *socket, *node); cpumask_and(socket, socket, node);
LASSERT(!cpus_empty(*socket)); LASSERT(!cpumask_empty(socket));
while (!cpus_empty(*socket)) { while (!cpumask_empty(socket)) {
int i; int i;
/* get cpumask for hts in the same core */ /* get cpumask for hts in the same core */
cfs_cpu_ht_siblings(cpu, core); cfs_cpu_ht_siblings(cpu, core);
cpus_and(*core, *core, *node); cpumask_and(core, core, node);
LASSERT(!cpus_empty(*core)); LASSERT(!cpumask_empty(core));
for_each_cpu_mask(i, *core) { for_each_cpu_mask(i, *core) {
cpu_clear(i, *socket); cpumask_clear_cpu(i, socket);
cpu_clear(i, *node); cpumask_clear_cpu(i, node);
rc = cfs_cpt_set_cpu(cptab, cpt, i); rc = cfs_cpt_set_cpu(cptab, cpt, i);
if (!rc) { if (!rc) {
...@@ -667,7 +667,7 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, ...@@ -667,7 +667,7 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
if (--number == 0) if (--number == 0)
goto out; goto out;
} }
cpu = first_cpu(*socket); cpu = cpumask_first(socket);
} }
} }
...@@ -767,7 +767,7 @@ cfs_cpt_table_create(int ncpt) ...@@ -767,7 +767,7 @@ cfs_cpt_table_create(int ncpt)
for_each_online_node(i) { for_each_online_node(i) {
cfs_node_to_cpumask(i, mask); cfs_node_to_cpumask(i, mask);
while (!cpus_empty(*mask)) { while (!cpumask_empty(mask)) {
struct cfs_cpu_partition *part; struct cfs_cpu_partition *part;
int n; int n;
...@@ -776,24 +776,24 @@ cfs_cpt_table_create(int ncpt) ...@@ -776,24 +776,24 @@ cfs_cpt_table_create(int ncpt)
part = &cptab->ctb_parts[cpt]; part = &cptab->ctb_parts[cpt];
n = num - cpus_weight(*part->cpt_cpumask); n = num - cpumask_weight(part->cpt_cpumask);
LASSERT(n > 0); LASSERT(n > 0);
rc = cfs_cpt_choose_ncpus(cptab, cpt, mask, n); rc = cfs_cpt_choose_ncpus(cptab, cpt, mask, n);
if (rc < 0) if (rc < 0)
goto failed; goto failed;
LASSERT(num >= cpus_weight(*part->cpt_cpumask)); LASSERT(num >= cpumask_weight(part->cpt_cpumask));
if (num == cpus_weight(*part->cpt_cpumask)) if (num == cpumask_weight(part->cpt_cpumask))
cpt++; cpt++;
} }
} }
if (cpt != ncpt || if (cpt != ncpt ||
num != cpus_weight(*cptab->ctb_parts[ncpt - 1].cpt_cpumask)) { num != cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask)) {
CERROR("Expect %d(%d) CPU partitions but got %d(%d), CPU hotplug/unplug while setting?\n", CERROR("Expect %d(%d) CPU partitions but got %d(%d), CPU hotplug/unplug while setting?\n",
cptab->ctb_nparts, num, cpt, cptab->ctb_nparts, num, cpt,
cpus_weight(*cptab->ctb_parts[ncpt - 1].cpt_cpumask)); cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask));
goto failed; goto failed;
} }
...@@ -845,7 +845,7 @@ cfs_cpt_table_create_pattern(char *pattern) ...@@ -845,7 +845,7 @@ cfs_cpt_table_create_pattern(char *pattern)
return NULL; return NULL;
} }
high = node ? MAX_NUMNODES - 1 : NR_CPUS - 1; high = node ? MAX_NUMNODES - 1 : nr_cpu_ids - 1;
cptab = cfs_cpt_table_alloc(ncpt); cptab = cfs_cpt_table_alloc(ncpt);
if (cptab == NULL) { if (cptab == NULL) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment