Fwd: vmalloc question

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

 







On 1/24/07, Mulyadi Santosa < mulyadi.santosa@xxxxxxxxx> wrote:
Hi Rohit
> Can we give vmalloced buffers to tcp_recvmsg() to get data from the
> network
> stack? Does the tcp_recv routine use this buffer passed to it for DMA?
>
> or
>
> Can we give vmalloced buffers to sock_recvmsg() to get data from the
> network
> stack? sock_recvmsg() calls sock->ops->recvmsg()which uses this buffer
> ....
> the recvmsg call here is call to tcp_recvmsg() ? Does the tcp_recv
> routine
> use this buffer passed to it for DMA?
>
This is purely coming from my logic. If you use vmalloc(), then what you
get is just virtually contigous memory blocks, not necessarily
physically contigous memory block. And AFAIK, DMA doesn't like such
thing, unless DMA is capable to do something like scatter gather data
transfer or vector based data read (like readv() does).

I am not so sure about this.
We need physically contiguous memory for DMA because it references memory by its  starting and ending  physical  address.

Also, AFAIK too, vmalloc() is necessary if you need such a large memory
block. So, do you really need that big?

yes, i have to allocte such a big buffer. I can't shorten the size of the buffer :(.

What i really wanted to ask is, does tcp_recvmsg() does any DMA operation with the buffer passed to it?
regards,

Mulyadi

Well, it seems that i got my answer ....
we have our tcp_recvmsg function as
int tcp_recvmsg(struct sock *sk, struct msghdr *msg, int len, int nonblock, int flags, int *addr_len);

my query  was that ...  can the buffer passed as iovec in struct msghdr used for DMA operation?
And the answer is no it is not!!!

tcp_recvmsg calls skb_copy_datagram_iovec(skb, offset, msg->msg_iov, used); which in turn calls
int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len) to copy data from the network stack (kernel buffers) to the iovec buffers .. which the kernel treats as a user buffer ... and uses copy_to_user(copy_to_user) call to do the actual copy operation.

So, i guess we can use vmalloc'ed memory buffers for getting data from the network stack.

regards,
-rohit



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux