* [PATCH] infiniband, ipath: convert old cpumask api into new one
@ 2011-05-19 1:04 ` KOSAKI Motohiro
0 siblings, 0 replies; 4+ messages in thread
From: KOSAKI Motohiro @ 2011-05-19 1:04 UTC (permalink / raw)
To: roland-DgEjT+Ai2ygdnm+yROfE0A, sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
infinipath-h88ZbnxC6KDQT0dZR+AlfA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: kosaki.motohiro-+CUm20s59erQFUHtdCDX3A
Adapt new api. we plan to remove old one later. Almost change are
trivial. but there is one real fix. 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().
Cc: Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Hal Rosenstock <hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Ralph Campbell <infinipath-h88ZbnxC6KDQT0dZR+AlfA@public.gmane.org>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
---
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 bdf4422..aab5d89 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -40,6 +40,7 @@
#include <linux/highmem.h>
#include <linux/io.h>
#include <linux/jiffies.h>
+#include <linux/cpu.h>
#include <asm/pgtable.h>
#include "ipath_kernel.h"
@@ -1684,17 +1685,19 @@ static int find_best_unit(struct file *fp,
* information. There may be some issues with dual core numbering
* as well. This needs more work prior to release.
*/
- if (!cpumask_empty(¤t->cpus_allowed) &&
- !cpumask_full(¤t->cpus_allowed)) {
+ if (!cpumask_empty(tsk_cpus_allowed(current)) &&
+ !cpumask_full(tsk_cpus_allowed(current))) {
int ncpus = num_online_cpus(), curcpu = -1, nset = 0;
- for (i = 0; i < ncpus; i++)
- if (cpumask_test_cpu(i, ¤t->cpus_allowed)) {
+ get_online_cpus();
+ for_each_online_cpu(i)
+ if (cpumask_test_cpu(i, tsk_cpus_allowed(current))) {
ipath_cdbg(PROC, "%s[%u] affinity set for "
"cpu %d/%d\n", current->comm,
current->pid, i, ncpus);
curcpu = i;
nset++;
}
+ put_online_cpus();
if (curcpu != -1 && nset != ncpus) {
if (npresent) {
prefunit = curcpu / (ncpus / npresent);
--
1.7.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH] infiniband, ipath: convert old cpumask api into new one
@ 2011-05-19 1:04 ` KOSAKI Motohiro
0 siblings, 0 replies; 4+ messages in thread
From: KOSAKI Motohiro @ 2011-05-19 1:04 UTC (permalink / raw)
To: roland, sean.hefty, hal.rosenstock, linux-rdma, infinipath,
linux-kernel
Cc: kosaki.motohiro
Adapt new api. we plan to remove old one later. Almost change are
trivial. but there is one real fix. 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().
Cc: Roland Dreier <roland@kernel.org>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: linux-rdma@vger.kernel.org
Cc: Ralph Campbell <infinipath@qlogic.com>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
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 bdf4422..aab5d89 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -40,6 +40,7 @@
#include <linux/highmem.h>
#include <linux/io.h>
#include <linux/jiffies.h>
+#include <linux/cpu.h>
#include <asm/pgtable.h>
#include "ipath_kernel.h"
@@ -1684,17 +1685,19 @@ static int find_best_unit(struct file *fp,
* information. There may be some issues with dual core numbering
* as well. This needs more work prior to release.
*/
- if (!cpumask_empty(¤t->cpus_allowed) &&
- !cpumask_full(¤t->cpus_allowed)) {
+ if (!cpumask_empty(tsk_cpus_allowed(current)) &&
+ !cpumask_full(tsk_cpus_allowed(current))) {
int ncpus = num_online_cpus(), curcpu = -1, nset = 0;
- for (i = 0; i < ncpus; i++)
- if (cpumask_test_cpu(i, ¤t->cpus_allowed)) {
+ get_online_cpus();
+ for_each_online_cpu(i)
+ if (cpumask_test_cpu(i, tsk_cpus_allowed(current))) {
ipath_cdbg(PROC, "%s[%u] affinity set for "
"cpu %d/%d\n", current->comm,
current->pid, i, ncpus);
curcpu = i;
nset++;
}
+ put_online_cpus();
if (curcpu != -1 && nset != ncpus) {
if (npresent) {
prefunit = curcpu / (ncpus / npresent);
--
1.7.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread[parent not found: <4DD46CAA.9030609-+CUm20s59erQFUHtdCDX3A@public.gmane.org>]
* RE: [PATCH] infiniband, ipath: convert old cpumask api into new one
2011-05-19 1:04 ` KOSAKI Motohiro
@ 2011-05-31 21:10 ` Mike Marciniszyn
-1 siblings, 0 replies; 4+ messages in thread
From: Mike Marciniszyn @ 2011-05-31 21:10 UTC (permalink / raw)
To: KOSAKI Motohiro, roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> Subject: [PATCH] infiniband, ipath: convert old cpumask api into new
> one
>
> Adapt new api. we plan to remove old one later. Almost change are
> trivial. but there is one real fix. following code is unsafe.
>
> int ncpus = num_online_cpus()
> for (i = 0; i < ncpus; i++) {
> ..
> }
>
Thanks for the patch!
Acked-by: Mike Marciniszyn <mike.marciniszyn-h88ZbnxC6KDQT0dZR+AlfA@public.gmane.org>
This message and any attached documents contain information from QLogic Corporation or its wholly-owned subsidiaries that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH] infiniband, ipath: convert old cpumask api into new one
@ 2011-05-31 21:10 ` Mike Marciniszyn
0 siblings, 0 replies; 4+ messages in thread
From: Mike Marciniszyn @ 2011-05-31 21:10 UTC (permalink / raw)
To: KOSAKI Motohiro, roland@kernel.org, sean.hefty@intel.com,
hal.rosenstock@gmail.com, linux-rdma@vger.kernel.org,
Dept_Infinipath, linux-kernel
> Subject: [PATCH] infiniband, ipath: convert old cpumask api into new
> one
>
> Adapt new api. we plan to remove old one later. Almost change are
> trivial. but there is one real fix. following code is unsafe.
>
> int ncpus = num_online_cpus()
> for (i = 0; i < ncpus; i++) {
> ..
> }
>
Thanks for the patch!
Acked-by: Mike Marciniszyn <mike.marciniszyn@qlogic.com>
This message and any attached documents contain information from QLogic Corporation or its wholly-owned subsidiaries that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-05-31 21:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-19 1:04 [PATCH] infiniband, ipath: convert old cpumask api into new one KOSAKI Motohiro
2011-05-19 1:04 ` KOSAKI Motohiro
[not found] ` <4DD46CAA.9030609-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2011-05-31 21:10 ` Mike Marciniszyn
2011-05-31 21:10 ` Mike Marciniszyn
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.