* [PATCH 1/4] IB/ipath: use for_each_set_bit and for_each_set_bit_from
@ 2012-04-03 8:47 Akinobu Mita
2012-04-03 8:47 ` [PATCH 2/4] IB/qib: " Akinobu Mita
0 siblings, 1 reply; 2+ messages in thread
From: Akinobu Mita @ 2012-04-03 8:47 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b
Cc: Akinobu Mita, Roland Dreier, Sean Hefty, Hal Rosenstock,
Mike Marciniszyn, linux-rdma-u79uwXL29TY76Z2rM5mHXA
Use for_each_set_bit() and for_each_set_bit_from() to iterate over all
the set bit in a memory region.
Signed-off-by: Akinobu Mita <akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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: Mike Marciniszyn <infinipath-h88ZbnxC6KDQT0dZR+AlfA@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
drivers/infiniband/hw/ipath/ipath_file_ops.c | 17 +++--------------
drivers/infiniband/hw/ipath/ipath_intr.c | 5 ++---
2 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 736d9ed..f74079e 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -438,10 +438,7 @@ static int ipath_tid_update(struct ipath_portdata *pd, struct file *fp,
if (limit > tidcnt)
/* just in case size changes in future */
limit = tidcnt;
- tid = find_first_bit((const unsigned long *)tidmap, limit);
- for (; tid < limit; tid++) {
- if (!test_bit(tid, tidmap))
- continue;
+ for_each_set_bit(tid, tidmap, limit) {
if (dd->ipath_pageshadow[porttid + tid]) {
ipath_cdbg(VERBOSE, "Freeing TID %u\n",
tid);
@@ -548,16 +545,8 @@ static int ipath_tid_free(struct ipath_portdata *pd, unsigned subport,
ipath_cdbg(VERBOSE, "Port%u free %u tids; first bit (max=%d) "
"set is %d, porttid %u\n", pd->port_port, ti->tidcnt,
limit, tid, porttid);
- for (cnt = 0; tid < limit; tid++) {
- /*
- * small optimization; if we detect a run of 3 or so without
- * any set, use find_first_bit again. That's mainly to
- * accelerate the case where we wrapped, so we have some at
- * the beginning, and some at the end, and a big gap
- * in the middle.
- */
- if (!test_bit(tid, tidmap))
- continue;
+ cnt = 0;
+ for_each_set_bit_from(tid, tidmap, limit) {
cnt++;
if (dd->ipath_pageshadow[porttid + tid]) {
struct page *p;
diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c
index c0a03ac..ee8d0d7 100644
--- a/drivers/infiniband/hw/ipath/ipath_intr.c
+++ b/drivers/infiniband/hw/ipath/ipath_intr.c
@@ -79,9 +79,8 @@ void ipath_disarm_senderrbufs(struct ipath_devdata *dd)
printk("\n");
}
- for (i = 0; i < piobcnt; i++)
- if (test_bit(i, sbuf))
- ipath_disarm_piobufs(dd, i, 1);
+ for_each_set_bit(i, sbuf, piobcnt)
+ ipath_disarm_piobufs(dd, i, 1);
/* ignore armlaunch errs for a bit */
dd->ipath_lastcancel = jiffies+3;
}
--
1.7.4.4
--
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] 2+ messages in thread
* [PATCH 2/4] IB/qib: use for_each_set_bit and for_each_set_bit_from
2012-04-03 8:47 [PATCH 1/4] IB/ipath: use for_each_set_bit and for_each_set_bit_from Akinobu Mita
@ 2012-04-03 8:47 ` Akinobu Mita
0 siblings, 0 replies; 2+ messages in thread
From: Akinobu Mita @ 2012-04-03 8:47 UTC (permalink / raw)
To: linux-kernel, akpm
Cc: Akinobu Mita, Roland Dreier, Sean Hefty, Hal Rosenstock,
Mike Marciniszyn, linux-rdma
Use for_each_set_bit() and for_each_set_bit_from() to iterate over all
the set bit in a memory region.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Roland Dreier <roland@kernel.org>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: Mike Marciniszyn <infinipath@qlogic.com>
Cc: linux-rdma@vger.kernel.org
---
drivers/infiniband/hw/qib/qib_file_ops.c | 22 ++++------------------
drivers/infiniband/hw/qib/qib_tx.c | 14 +++++---------
2 files changed, 9 insertions(+), 27 deletions(-)
diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c
index a740324..7c901d9 100644
--- a/drivers/infiniband/hw/qib/qib_file_ops.c
+++ b/drivers/infiniband/hw/qib/qib_file_ops.c
@@ -399,10 +399,7 @@ cleanup:
if (limit > tidcnt)
/* just in case size changes in future */
limit = tidcnt;
- tid = find_first_bit((const unsigned long *)tidmap, limit);
- for (; tid < limit; tid++) {
- if (!test_bit(tid, tidmap))
- continue;
+ for_each_set_bit(tid, tidmap, limit) {
if (dd->pageshadow[ctxttid + tid]) {
dma_addr_t phys;
@@ -504,17 +501,8 @@ static int qib_tid_free(struct qib_ctxtdata *rcd, unsigned subctxt,
if (limit > tidcnt)
/* just in case size changes in future */
limit = tidcnt;
- tid = find_first_bit(tidmap, limit);
- for (cnt = 0; tid < limit; tid++) {
- /*
- * small optimization; if we detect a run of 3 or so without
- * any set, use find_first_bit again. That's mainly to
- * accelerate the case where we wrapped, so we have some at
- * the beginning, and some at the end, and a big gap
- * in the middle.
- */
- if (!test_bit(tid, tidmap))
- continue;
+ cnt = 0;
+ for_each_set_bit(tid, tidmap, limit) {
cnt++;
if (dd->pageshadow[ctxttid + tid]) {
struct page *p;
@@ -1948,9 +1936,7 @@ static int qib_user_event_ack(struct qib_ctxtdata *rcd, int subctxt,
{
int ret = 0, i;
- for (i = 0; i <= _QIB_MAX_EVENT_BIT; i++) {
- if (!test_bit(i, &events))
- continue;
+ for_each_set_bit(i, &events, _QIB_MAX_EVENT_BIT + 1) {
if (i == _QIB_EVENT_DISARM_BUFS_BIT) {
(void)qib_disarm_piobufs_ifneeded(rcd);
ret = disarm_req_delay(rcd);
diff --git a/drivers/infiniband/hw/qib/qib_tx.c b/drivers/infiniband/hw/qib/qib_tx.c
index 1bf626c..93d236a 100644
--- a/drivers/infiniband/hw/qib/qib_tx.c
+++ b/drivers/infiniband/hw/qib/qib_tx.c
@@ -82,7 +82,6 @@ int qib_disarm_piobufs_ifneeded(struct qib_ctxtdata *rcd)
struct qib_devdata *dd = rcd->dd;
unsigned i;
unsigned last;
- unsigned n = 0;
last = rcd->pio_base + rcd->piocnt;
/*
@@ -101,11 +100,10 @@ int qib_disarm_piobufs_ifneeded(struct qib_ctxtdata *rcd)
&rcd->user_event_mask[i]);
}
spin_lock_irq(&dd->pioavail_lock);
- for (i = rcd->pio_base; i < last; i++) {
- if (__test_and_clear_bit(i, dd->pio_need_disarm)) {
- n++;
- dd->f_sendctrl(rcd->ppd, QIB_SENDCTRL_DISARM_BUF(i));
- }
+ i = rcd->pio_base;
+ for_each_set_bit_from(i, dd->pio_need_disarm, last) {
+ __clear_bit(i, dd->pio_need_disarm);
+ dd->f_sendctrl(rcd->ppd, QIB_SENDCTRL_DISARM_BUF(i));
}
spin_unlock_irq(&dd->pioavail_lock);
return 0;
@@ -178,10 +176,8 @@ void qib_disarm_piobufs_set(struct qib_devdata *dd, unsigned long *mask,
for (i = 0; i < dd->num_pports; i++)
pppd[i] = NULL;
- for (i = 0; i < cnt; i++) {
+ for_each_set_bit(i, mask, cnt) {
int which;
- if (!test_bit(i, mask))
- continue;
/*
* If the buffer is owned by the DMA hardware,
* reset the DMA engine.
--
1.7.4.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-04-03 8:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-03 8:47 [PATCH 1/4] IB/ipath: use for_each_set_bit and for_each_set_bit_from Akinobu Mita
2012-04-03 8:47 ` [PATCH 2/4] IB/qib: " Akinobu Mita
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox