diff mbox

[v3] IB/cq: Don't process more than the given budget

Message ID 1489683420-28005-1-git-send-email-sagi@grimberg.me (mailing list archive)
State Accepted
Headers show

Commit Message

Sagi Grimberg March 16, 2017, 4:57 p.m. UTC
The caller might not want this overhead.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 drivers/infiniband/core/cq.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Yuval Shaia March 21, 2017, 8:42 a.m. UTC | #1
On Thu, Mar 16, 2017 at 06:57:00PM +0200, Sagi Grimberg wrote:
> The caller might not want this overhead.
> 
> Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
> Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
> ---
>  drivers/infiniband/core/cq.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/core/cq.c b/drivers/infiniband/core/cq.c
> index e95510117a6d..b9c4cefe90c1 100644
> --- a/drivers/infiniband/core/cq.c
> +++ b/drivers/infiniband/core/cq.c
> @@ -29,7 +29,13 @@ static int __ib_process_cq(struct ib_cq *cq, int budget)
>  {
>  	int i, n, completed = 0;
>  
> -	while ((n = ib_poll_cq(cq, IB_POLL_BATCH, cq->wc)) > 0) {
> +	/*
> +	 * budget might be (-1) if the caller does not
> +	 * want to bound this call, thus we need unsigned
> +	 * minimum here.
> +	 */
> +	while ((n = ib_poll_cq(cq, min_t(u32, IB_POLL_BATCH,
> +			budget - completed), cq->wc)) > 0) {
>  		for (i = 0; i < n; i++) {
>  			struct ib_wc *wc = &cq->wc[i];

Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>

>  
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Doug Ledford March 25, 2017, 2:20 a.m. UTC | #2
On Thu, 2017-03-16 at 18:57 +0200, Sagi Grimberg wrote:
> The caller might not want this overhead.
> 
> Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
> Signed-off-by: Sagi Grimberg <sagi@grimberg.me>

Thanks, applied for -rc.
diff mbox

Patch

diff --git a/drivers/infiniband/core/cq.c b/drivers/infiniband/core/cq.c
index e95510117a6d..b9c4cefe90c1 100644
--- a/drivers/infiniband/core/cq.c
+++ b/drivers/infiniband/core/cq.c
@@ -29,7 +29,13 @@  static int __ib_process_cq(struct ib_cq *cq, int budget)
 {
 	int i, n, completed = 0;
 
-	while ((n = ib_poll_cq(cq, IB_POLL_BATCH, cq->wc)) > 0) {
+	/*
+	 * budget might be (-1) if the caller does not
+	 * want to bound this call, thus we need unsigned
+	 * minimum here.
+	 */
+	while ((n = ib_poll_cq(cq, min_t(u32, IB_POLL_BATCH,
+			budget - completed), cq->wc)) > 0) {
 		for (i = 0; i < n; i++) {
 			struct ib_wc *wc = &cq->wc[i];