Fajun Chen wrote: > On 11/17/07, Mark Lord wrote: .. >> What you probably intended to do instead, was to use mmap to just allocate >> some page-aligned RAM, not to actually mmap'd any on-disk data. Right? >> >> Here's how that's done: >> >> read_buffer = (U8 *)mmap(NULL, buf_sz, PROT_READ | PROT_WRITE, >> MAP_SHARED|MAP_ANONYMOUS, -1, 0); >> > What I intended to do is to write data into disc or read data from > disc via SG_IO as requested by my user-space application. I don't want > any automatically scheduled kernel task to sync data with disc. .. Right. Then you definitely do NOT want to mmap your device, because that's exactly what would otherwise happen, by design! > I've experimented with memory mapping using MAP_ANONYMOUS as you > suggested, the good news is that it does free up the cpu load and my > system is much more responsive with the change. .. Yes, that's what we expected to see. > The bad news is that > the data read back from disc (PIO or DMA read) seems to be invisible > to user-space application. For instance, read buffer is all zeros > after Identify Device command. Is this expected side effect of > MAP_ANONYMOUS option? .. No, that would be a side effect of some other bug in the code. Here (attached) is a working program that performs (PACKET)IDENTIFY DEVICE commands, using a mmap() buffer to receive the data. Cheers