I was wondering what the correct way of issuing an asynchronous read operation on a pa开发者_运维技巧ge that has been swapped out is. And once this is done is there a way to execute a callback that happens so that I can execute some logic with that page?
madvise(start_address, length, MADV_WILLNEED)
will do that.
A callback does not really exist, though you can poll a snapshot of the status with the mincore
syscall, if you want.
Note that the opposite hint MADV_DONTNEED
does not do what you think, nor does msync
. The documentation is lying.
There is no non-broken-by-design way to start asynchronous writeback under Linux (although the documentation says so). You can choose between no-op, throwing pages away, synchronous writeback, or asynchronous writeback with purging the cache.
精彩评论