3 Feb 2012 20:37
Prefaulting for i/o buffers
Konstantin Belousov <kostikbel <at> gmail.com>
2012-02-03 19:37:19 GMT
2012-02-03 19:37:19 GMT
FreeBSD I/O infrastructure has well known issue with deadlock caused by vnode lock order reversal when buffers supplied to read(2) or write(2) syscalls are backed by mmaped file. I previously published the patches to convert i/o path to use VMIO, based on the Jeff Roberson proposal, see http://wiki.freebsd.org/VM6. As a side effect, the VM6 fixed the deadlock. Since that work is very intrusive and did not got any follow-up, it get stalled. Below is very lightweight patch which only goal is to fix deadlock in the least intrusive way. This is possible after FreeBSD got the vm_fault_quick_hold_pages(9) and vm_fault_disable_pagefaults(9) KPIs. http://people.freebsd.org/~kib/misc/vm1.3.patch Theory of operation is described in the patched sys/kern/vfs_vnops.c, see preamble comment for vn_io_fault(). The patch borrows the rangelocks implementation from VM6, which was discussed and improved together with Attilio Rao. I was not able to reproduce the deadlock in the targeted test running for several hours, while stock HEAD deadlocks in the first iteration. Below is the benchmark for the worst-case situation for the patched system, reading 1 byte from a file in a loop. The value is the time in seconds to execute read(2) for single byte and lseek back to the start of the file. The loop is executed 100,000,000 times. Machine has 3.4Ghz Core i7 2600K and used HEAD <at> 230866 with debugging options turned off.(Continue reading)
RSS Feed