1

I'm playing with this code on Linux 2.6.16.46:

io.aio_fildes = open(name, O_CREAT | O_TRUNC | O_WRONLY | O_SYNC, 00300);

io.aio_buf = buffer;
io.aio_nbytes = size;
io.aio_sigevent = sigev;
io.aio_lio_opcode = LIO_WRITE;

aio_write( &io );

This should use the memory pointed by buffer for the IO operation. Still, I see the number of dirty pages go up as if I was writing to cache. Why is that?

On the build machine, there's no O_DIRECT support in open(). But since I'm not using write(), should that still be a problem?

I'm pretty sure there's direct IO support on the target.

n-alexander
  • 14,663
  • 12
  • 42
  • 43
  • Because the aio implementation is not as good as it should be? I'm not posting this as an answer because my knowledge about aio is pretty old and i haven't checked if the improved it in the last years. Five years ago it was just a API compatibility wrapper but no feature improvement. – Lothar Aug 20 '10 at 16:47
  • well. On the target machine that is 2.6.27.19 direct IO is supported in the kernel at least. But it does not have a compiler. On the build machine open() does not accept O_DIRECT. Does that mean I have an old library? – n-alexander Aug 20 '10 at 16:58

1 Answers1

1

figured this out. Direct/buffered IO is one thing, sync/async is another. To have async writes avoid cache one still needs to give O_DIRECT to the open() call, even if write() is not used.

There will likely be compiler errors at first - read man 2 open carefully.

n-alexander
  • 14,663
  • 12
  • 42
  • 43