Re: [PATCH 1/7] sunrpc: Factor out rpc_xprt allocation

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

 



On Sep 28, 2010, at 12:51 PM, Pavel Emelyanov wrote:

>>> +struct rpc_xprt *xprt_alloc(int size, int max_req)
>>> +{
>>> +	struct rpc_xprt *xprt;
>>> +
>>> +	xprt = kzalloc(size, GFP_KERNEL);
>>> +	if (xprt == NULL)
>>> +		goto out;
>>> +
>>> +	xprt->max_reqs = max_req;
>>> +	xprt->slot = kcalloc(max_req, sizeof(struct rpc_rqst), GFP_KERNEL);
>>> +	if (xprt->slot == NULL)
>>> +		goto out_free;
>>> +
>>> +	return xprt;
>>> +
>>> +out_free:
>>> +	kfree(xprt);
>>> +out:
>>> +	return NULL;
>>> +}
>>> +EXPORT_SYMBOL_GPL(xprt_alloc);
>> 
>> If xprt_alloc is a generic function, used by different transport capabilities, 
>> then it belongs in net/sunrpc/xprt.c, not in a transport-specific source file
>> like xprtsock.c .
> 
> Will do.
> 
>> Also, would it makes sense to allocate these via a single kcalloc request, or
>> would that possibly result in a high-order (ie non-zero) allocation in some cases?
> 
> The kcalloc is used to allocate n elements of an equal size, but the first
> element in this hypothetical allocation will be of another size...

You can compute the needed total allocation size by hand, and then use kzalloc.  Just a thought.

Again, not a requirement, but might be an interesting optimization.

-- 
chuck[dot]lever[at]oracle[dot]com




--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux