diff mbox

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

Message ID 1489014358-13638-1-git-send-email-sagi@grimberg.me (mailing list archive)
State Superseded
Headers show

Commit Message

Sagi Grimberg March 8, 2017, 11:05 p.m. UTC
The caller might not want this overhead.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 drivers/infiniband/core/cq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Leon Romanovsky March 12, 2017, 7:25 p.m. UTC | #1
On Thu, Mar 09, 2017 at 01:05:58AM +0200, Sagi Grimberg wrote:
> The caller might not want this overhead.
>
> Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
> ---
>  drivers/infiniband/core/cq.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/core/cq.c b/drivers/infiniband/core/cq.c
> index 2746d2eb3d52..21d1a38af489 100644
> --- a/drivers/infiniband/core/cq.c
> +++ b/drivers/infiniband/core/cq.c
> @@ -29,7 +29,8 @@ 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) {
> +	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];
>

I agree with Bart, comment is welcome.
Not everyone will remember that budget can be -1 and (budget - completed) can be -1.

Anyway,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
diff mbox

Patch

diff --git a/drivers/infiniband/core/cq.c b/drivers/infiniband/core/cq.c
index 2746d2eb3d52..21d1a38af489 100644
--- a/drivers/infiniband/core/cq.c
+++ b/drivers/infiniband/core/cq.c
@@ -29,7 +29,8 @@  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) {
+	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];