diff mbox

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

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

Commit Message

Sagi Grimberg March 8, 2017, 8:10 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

Christoph Hellwig March 8, 2017, 9:36 p.m. UTC | #1
On Wed, Mar 08, 2017 at 10:10:01PM +0200, Sagi Grimberg wrote:
> The caller might not want this overhead.
> 
> Signed-off-by: Sagi Grimberg <sagi@grimberg.me>

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>
--
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
Bart Van Assche March 8, 2017, 10:09 p.m. UTC | #2
On Wed, 2017-03-08 at 22:10 +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..c98d15ce2880 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(IB_POLL_BATCH, budget - completed),
> +			cq->wc)) > 0) {
>  		for (i = 0; i < n; i++) {
>  			struct ib_wc *wc = &cq->wc[i];
>  

This breaks the SRP initiator driver since that driver can pass -1 as budget.

Bart.--
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
Christoph Hellwig March 8, 2017, 10:12 p.m. UTC | #3
On Wed, Mar 08, 2017 at 10:09:08PM +0000, Bart Van Assche wrote:
> > -	while ((n = ib_poll_cq(cq, IB_POLL_BATCH, cq->wc)) > 0) {
> > +	while ((n = ib_poll_cq(cq, min(IB_POLL_BATCH, budget - completed),
> > +			cq->wc)) > 0) {
> >  		for (i = 0; i < n; i++) {
> >  			struct ib_wc *wc = &cq->wc[i];
> >  
> 
> This breaks the SRP initiator driver since that driver can pass -1 as budget.

Good point, we'd need to special case that.
--
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
Bart Van Assche March 8, 2017, 10:14 p.m. UTC | #4
On Wed, 2017-03-08 at 23:12 +0100, hch@lst.de wrote:
> On Wed, Mar 08, 2017 at 10:09:08PM +0000, Bart Van Assche wrote:
> > > -	while ((n = ib_poll_cq(cq, IB_POLL_BATCH, cq->wc)) > 0) {
> > > +	while ((n = ib_poll_cq(cq, min(IB_POLL_BATCH, budget - completed),
> > > +			cq->wc)) > 0) {
> > >  		for (i = 0; i < n; i++) {
> > >  			struct ib_wc *wc = &cq->wc[i];
> > >  
> > 
> > This breaks the SRP initiator driver since that driver can pass -1 as budget.
> 
> Good point, we'd need to special case that.

How about using min_t(u32, IB_POLL_BATCH, budget - completed)?

Bart.--
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
Sagi Grimberg March 8, 2017, 10:59 p.m. UTC | #5
>>>> -	while ((n = ib_poll_cq(cq, IB_POLL_BATCH, cq->wc)) > 0) {
>>>> +	while ((n = ib_poll_cq(cq, min(IB_POLL_BATCH, budget - completed),
>>>> +			cq->wc)) > 0) {
>>>>  		for (i = 0; i < n; i++) {
>>>>  			struct ib_wc *wc = &cq->wc[i];
>>>>
>>>
>>> This breaks the SRP initiator driver since that driver can pass -1 as budget.
>>
>> Good point, we'd need to special case that.
>
> How about using min_t(u32, IB_POLL_BATCH, budget - completed)?

Yep, I'll do that, thanks Bart.
--
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
diff mbox

Patch

diff --git a/drivers/infiniband/core/cq.c b/drivers/infiniband/core/cq.c
index 2746d2eb3d52..c98d15ce2880 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(IB_POLL_BATCH, budget - completed),
+			cq->wc)) > 0) {
 		for (i = 0; i < n; i++) {
 			struct ib_wc *wc = &cq->wc[i];