Commit 57631811 authored by Motohiro KOSAKI's avatar Motohiro KOSAKI Committed by Roland Dreier

IB/ipath: Convert old cpumask api into new one

Adapt to new api.  We plan to remove old one later.  Almost all
changes are trivial, but there is one real fix: the following code is
unsafe:

	int ncpus = num_online_cpus()
	for (i = 0; i < ncpus; i++) {
		..
	}

because 1) we don't guarantee last bit of online cpus is equal to
num_online_cpus(). some arch assign sparse cpu number.  2) cpu
hotplugging may change cpu_online_mask at same time.  we need to pin
it by get_online_cpus().
Signed-off-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: default avatarMike Marciniszyn <mike.marciniszyn@qlogic.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent 620917de
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/cpu.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include "ipath_kernel.h" #include "ipath_kernel.h"
...@@ -1684,17 +1685,19 @@ static int find_best_unit(struct file *fp, ...@@ -1684,17 +1685,19 @@ static int find_best_unit(struct file *fp,
* information. There may be some issues with dual core numbering * information. There may be some issues with dual core numbering
* as well. This needs more work prior to release. * as well. This needs more work prior to release.
*/ */
if (!cpumask_empty(&current->cpus_allowed) && if (!cpumask_empty(tsk_cpus_allowed(current)) &&
!cpumask_full(&current->cpus_allowed)) { !cpumask_full(tsk_cpus_allowed(current))) {
int ncpus = num_online_cpus(), curcpu = -1, nset = 0; int ncpus = num_online_cpus(), curcpu = -1, nset = 0;
for (i = 0; i < ncpus; i++) get_online_cpus();
if (cpumask_test_cpu(i, &current->cpus_allowed)) { for_each_online_cpu(i)
if (cpumask_test_cpu(i, tsk_cpus_allowed(current))) {
ipath_cdbg(PROC, "%s[%u] affinity set for " ipath_cdbg(PROC, "%s[%u] affinity set for "
"cpu %d/%d\n", current->comm, "cpu %d/%d\n", current->comm,
current->pid, i, ncpus); current->pid, i, ncpus);
curcpu = i; curcpu = i;
nset++; nset++;
} }
put_online_cpus();
if (curcpu != -1 && nset != ncpus) { if (curcpu != -1 && nset != ncpus) {
if (npresent) { if (npresent) {
prefunit = curcpu / (ncpus / npresent); prefunit = curcpu / (ncpus / npresent);
......
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