Re: [PATCH 1/1] IB/rxe: use kvmalloc instead of kmalloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Nov 18, 2018 at 09:37:09PM +0800, Yanjun Zhu wrote:
> 
> On 2018/11/18 21:35, Yuval Shaia wrote:
> > On Sun, Nov 18, 2018 at 08:21:24AM -0500, Yanjun Zhu wrote:
> > > Attempt to allocate physically contiguous memory, but upon
> > > failure, fall back to non-contiguous (vmalloc) allocation.
> > > 
> > > Signed-off-by: Zhu Yanjun <yanjun.zhu@xxxxxxxxxx>
> > > ---
> > >   drivers/infiniband/sw/rxe/rxe_cq.c    | 2 +-
> > >   drivers/infiniband/sw/rxe/rxe_qp.c    | 4 ++--
> > >   drivers/infiniband/sw/rxe/rxe_queue.c | 6 +++---
> > >   drivers/infiniband/sw/rxe/rxe_srq.c   | 2 +-
> > >   4 files changed, 7 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/drivers/infiniband/sw/rxe/rxe_cq.c b/drivers/infiniband/sw/rxe/rxe_cq.c
> > > index a57276f2cb84..b85ca024fa58 100644
> > > --- a/drivers/infiniband/sw/rxe/rxe_cq.c
> > > +++ b/drivers/infiniband/sw/rxe/rxe_cq.c
> > > @@ -98,7 +98,7 @@ int rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe,
> > >   			   cq->queue->buf, cq->queue->buf_size, &cq->queue->ip);
> > >   	if (err) {
> > >   		vfree(cq->queue->buf);
> > > -		kfree(cq->queue);
> > > +		kvfree(cq->queue);
> > But queue is created with kmalloc, what am i missing here?
> 
> Now I use kvmalloc to create queue.
> 
> Zhu Yanjun

I see, my bad, i was misled by commit message.

Anyway, I do not see here an attempt to allocated with kmalloc and switch
to kvmalloc on failure, i see that you just decided to use kvmalloc
*instead* of kmalloc, right?

> 
> 
> > 
> > Is this patch based on some other patch that is not yet in for-next?
> > 
> > >   		return err;
> > >   	}
> > > diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c
> > > index b9710907dac2..fd233f93ac1d 100644
> > > --- a/drivers/infiniband/sw/rxe/rxe_qp.c
> > > +++ b/drivers/infiniband/sw/rxe/rxe_qp.c
> > > @@ -259,7 +259,7 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp,
> > >   	if (err) {
> > >   		vfree(qp->sq.queue->buf);
> > > -		kfree(qp->sq.queue);
> > > +		kvfree(qp->sq.queue);
> > >   		return err;
> > >   	}
> > > @@ -312,7 +312,7 @@ static int rxe_qp_init_resp(struct rxe_dev *rxe, struct rxe_qp *qp,
> > >   				   &qp->rq.queue->ip);
> > >   		if (err) {
> > >   			vfree(qp->rq.queue->buf);
> > > -			kfree(qp->rq.queue);
> > > +			kvfree(qp->rq.queue);
> > >   			return err;
> > >   		}
> > >   	}
> > > diff --git a/drivers/infiniband/sw/rxe/rxe_queue.c b/drivers/infiniband/sw/rxe/rxe_queue.c
> > > index f84ab4469261..e811a655b286 100644
> > > --- a/drivers/infiniband/sw/rxe/rxe_queue.c
> > > +++ b/drivers/infiniband/sw/rxe/rxe_queue.c
> > > @@ -91,7 +91,7 @@ struct rxe_queue *rxe_queue_init(struct rxe_dev *rxe,
> > >   	if (*num_elem < 0)
> > >   		goto err1;
> > > -	q = kmalloc(sizeof(*q), GFP_KERNEL);
> > > +	q = kvmalloc(sizeof(*q), GFP_KERNEL);

Where is the "fall back" logic?

> > >   	if (!q)
> > >   		goto err1;
> > > @@ -174,7 +174,7 @@ int rxe_queue_resize(struct rxe_queue *q,
> > >   			   new_q->buf_size, &new_q->ip);
> > >   	if (err) {
> > >   		vfree(new_q->buf);
> > > -		kfree(new_q);
> > > +		kvfree(new_q);
> > >   		goto err1;
> > >   	}
> > > @@ -208,5 +208,5 @@ void rxe_queue_cleanup(struct rxe_queue *q)
> > >   	else
> > >   		vfree(q->buf);
> > > -	kfree(q);
> > > +	kvfree(q);
> > >   }
> > > diff --git a/drivers/infiniband/sw/rxe/rxe_srq.c b/drivers/infiniband/sw/rxe/rxe_srq.c
> > > index c41a5fee81f7..c9969d157b87 100644
> > > --- a/drivers/infiniband/sw/rxe/rxe_srq.c
> > > +++ b/drivers/infiniband/sw/rxe/rxe_srq.c
> > > @@ -132,7 +132,7 @@ int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq,
> > >   			   q->buf_size, &q->ip);
> > >   	if (err) {
> > >   		vfree(q->buf);
> > > -		kfree(q);
> > > +		kvfree(q);
> > >   		return err;
> > >   	}
> > > -- 
> > > 2.17.1
> > > 



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux