From: Giuseppe C. <pep...@gm...> - 2008-02-01 10:46:11
|
Hi, > I have to read UDP packets from sk_buff to my module in kernel space and > the udp stack uses copy_to_user() to do my task. I'm wondering if using > dma for mem-to-mem copy can improve data transfer performance instead of > using copy_to_user()??? Often to take the best performance by using a DMA engine, e.g. in a network driver, the zero-copy mechanism is used because It essentially avoids memcpy. Abut how to implement the zero-copy mechanism you ought to start looking at the network device drivers within the kernel source tree. >If yes, could someone gives me some hints to go with it. I'm currently >working on ST7109 and stlinux 2.6.17.14 <http://2.6.17.14><http://2.6.17.14/>. I have tried >the guide at > http://www.stlinux.com/docs/manual/distribution/fdma_legacy.php<http://www.stlinux.com/docs/manual/distribution/fdma_legacy.php>but not >succeeded, kernel crashed with the following error: Concerning the 7109; it has an embedded MAC (core by Synopsys) with a own DMA (no FDMA). You could directly browse the driver source (called stmmac within the STLinux kernels) where zero-copy is fully implemented. For more information also visit: http://stlinux.com/docs/manual/distribution/distribution_guide5.php and STLinux Bugzilla. |
From: Stuart M. <stu...@st...> - 2008-02-01 12:21:28
|
Folks Giuseppe Cavallaro wrote: >> I have to read UDP packets from sk_buff to my module in kernel space and >> the udp stack uses copy_to_user() to do my task. I'm wondering if using >> dma for mem-to-mem copy can improve data transfer performance instead of >> using copy_to_user()??? > > Often to take the best performance by using a DMA engine, e.g. in a network > driver, > the zero-copy mechanism is used because It essentially avoids memcpy. > Abut how to implement the zero-copy mechanism you ought to start looking at > the network device > drivers within the kernel source tree. Note that there are generally two 'copies' involved in receiving data. The first is where the data is written into the network stack's packet buffer, the second is where the data is copied into the user's buffer. (This is ignoring the checksum step, which ideally is merged with one of the other copies). Giuseppe is referring to removing the first, which involves the DMA engine in the NIC writing the data directly into the sk_buff. Ha Nguyen was asking about the second, which is very hard to remove while still retaining the standard socket API. Stuart |
From: Ha N. <han...@gm...> - 2008-02-01 15:40:07
|
On Feb 1, 2008 1:21 PM, Stuart MENEFY <stu...@st...> wrote: > Folks > > Giuseppe Cavallaro wrote: > >> I have to read UDP packets from sk_buff to my module in kernel space and > >> the udp stack uses copy_to_user() to do my task. I'm wondering if using > >> dma for mem-to-mem copy can improve data transfer performance instead of > >> using copy_to_user()??? > > > > Often to take the best performance by using a DMA engine, e.g. in a network > > driver, > > the zero-copy mechanism is used because It essentially avoids memcpy. > > Abut how to implement the zero-copy mechanism you ought to start looking at > > the network device > > drivers within the kernel source tree. > > Note that there are generally two 'copies' involved in receiving data. > The first is where the data is written into the network stack's packet > buffer, the second is where the data is copied into the user's buffer. > (This is ignoring the checksum step, which ideally is merged with one of > the other copies). > > Giuseppe is referring to removing the first, which involves the DMA engine > in the NIC writing the data directly into the sk_buff. Ha Nguyen was asking > about the second, which is very hard to remove while still retaining the > standard socket API. Exactly, I already configured the MAC for zero-copy. Based on Stuart's input, dmaengine should do my work when it is available. I'm curious to see if how it improves network performance... Thanks guys for your feedbacks! /ha |
From: Giuseppe C. <pep...@gm...> - 2008-02-01 18:58:43
|
Ciao Stuart, thanks for the clarification! To Ha Nguyen: sorry if I posted too details about the zero-copy ;-) At any rate, concerning the network drivers optimization you could also look at: TSO,UFO,GSO, I/OAT, LSA,(Linux Socket Acceleration) etc. Maybe, you will find useful this link: http://www.linux-foundation.org/en/Net Cheers Peppe Ha Nguyen wrote: > On Feb 1, 2008 1:21 PM, Stuart MENEFY <stu...@st...> wrote: > >> Folks >> >> Giuseppe Cavallaro wrote: >> >>>> I have to read UDP packets from sk_buff to my module in kernel space and >>>> the udp stack uses copy_to_user() to do my task. I'm wondering if using >>>> dma for mem-to-mem copy can improve data transfer performance instead of >>>> using copy_to_user()??? >>>> >>> Often to take the best performance by using a DMA engine, e.g. in a network >>> driver, >>> the zero-copy mechanism is used because It essentially avoids memcpy. >>> Abut how to implement the zero-copy mechanism you ought to start looking at >>> the network device >>> drivers within the kernel source tree. >>> >> Note that there are generally two 'copies' involved in receiving data. >> The first is where the data is written into the network stack's packet >> buffer, the second is where the data is copied into the user's buffer. >> (This is ignoring the checksum step, which ideally is merged with one of >> the other copies). >> >> Giuseppe is referring to removing the first, which involves the DMA engine >> in the NIC writing the data directly into the sk_buff. Ha Nguyen was asking >> about the second, which is very hard to remove while still retaining the >> standard socket API. >> > > Exactly, I already configured the MAC for zero-copy. Based on Stuart's > input, dmaengine should do my work when it is available. I'm curious > to see if how it improves network performance... > > Thanks guys for your feedbacks! > > /ha > |