diff options
author | Motohiro KOSAKI <kosaki.motohiro@jp.fujitsu.com> | 2011-05-18 21:04:42 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2011-07-18 14:56:18 -0400 |
commit | 57631811728d12ad9b0e96ed3eccb486124a5605 (patch) | |
tree | e5ecab401a54d5f1882469fcac26cc85caded44c /drivers/infiniband | |
parent | 620917de59eeb934b9f8cf35cc2d95c1ac8ed0fc (diff) |
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: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Mike Marciniszyn <mike.marciniszyn@qlogic.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_file_ops.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c index ee79a2d97b14..8697eca14356 100644 --- a/drivers/infiniband/hw/ipath/ipath_file_ops.c +++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/highmem.h> | 40 | #include <linux/highmem.h> |
41 | #include <linux/io.h> | 41 | #include <linux/io.h> |
42 | #include <linux/jiffies.h> | 42 | #include <linux/jiffies.h> |
43 | #include <linux/cpu.h> | ||
43 | #include <asm/pgtable.h> | 44 | #include <asm/pgtable.h> |
44 | 45 | ||
45 | #include "ipath_kernel.h" | 46 | #include "ipath_kernel.h" |
@@ -1684,17 +1685,19 @@ static int find_best_unit(struct file *fp, | |||
1684 | * information. There may be some issues with dual core numbering | 1685 | * information. There may be some issues with dual core numbering |
1685 | * as well. This needs more work prior to release. | 1686 | * as well. This needs more work prior to release. |
1686 | */ | 1687 | */ |
1687 | if (!cpumask_empty(¤t->cpus_allowed) && | 1688 | if (!cpumask_empty(tsk_cpus_allowed(current)) && |
1688 | !cpumask_full(¤t->cpus_allowed)) { | 1689 | !cpumask_full(tsk_cpus_allowed(current))) { |
1689 | int ncpus = num_online_cpus(), curcpu = -1, nset = 0; | 1690 | int ncpus = num_online_cpus(), curcpu = -1, nset = 0; |
1690 | for (i = 0; i < ncpus; i++) | 1691 | get_online_cpus(); |
1691 | if (cpumask_test_cpu(i, ¤t->cpus_allowed)) { | 1692 | for_each_online_cpu(i) |
1693 | if (cpumask_test_cpu(i, tsk_cpus_allowed(current))) { | ||
1692 | ipath_cdbg(PROC, "%s[%u] affinity set for " | 1694 | ipath_cdbg(PROC, "%s[%u] affinity set for " |
1693 | "cpu %d/%d\n", current->comm, | 1695 | "cpu %d/%d\n", current->comm, |
1694 | current->pid, i, ncpus); | 1696 | current->pid, i, ncpus); |
1695 | curcpu = i; | 1697 | curcpu = i; |
1696 | nset++; | 1698 | nset++; |
1697 | } | 1699 | } |
1700 | put_online_cpus(); | ||
1698 | if (curcpu != -1 && nset != ncpus) { | 1701 | if (curcpu != -1 && nset != ncpus) { |
1699 | if (npresent) { | 1702 | if (npresent) { |
1700 | prefunit = curcpu / (ncpus / npresent); | 1703 | prefunit = curcpu / (ncpus / npresent); |