Re: [PATCH 2/2] Release mmap_sem when page fault blocks on disk transfer.

From: Rik van Riel
Date: Fri Oct 01 2010 - 10:07:26 EST


On 10/01/2010 01:04 AM, Michel Lespinasse wrote:
This change reduces mmap_sem hold times that are caused by waiting for
disk transfers when accessing file mapped VMAs. It introduces the
VM_FAULT_RELEASED flag, which indicates that the call site holds mmap_lock
and wishes for it to be released if blocking on a pending disk transfer.
In that case, filemap_fault() returns the VM_FAULT_RELEASED status bit
and do_page_fault() will then re-acquire mmap_sem and retry the page fault.
It is expected that the retry will hit the same page which will now be cached,
and thus it will complete with a low mmap_sem hold time.

The concept makes sense. A nitpick, though...

+ if (release_flag) { /* Did not go through a retry */
+ if (fault& VM_FAULT_MAJOR) {
+ tsk->maj_flt++;
+ perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, 0,
+ regs, address);
+ } else {
+ tsk->min_flt++;
+ perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, 0,
+ regs, address);
+ }
+ if (fault& VM_FAULT_RELEASED) {
+ /*
+ * handle_mm_fault() found that the desired page was
+ * locked. We asked for it to release mmap_sem in that
+ * case, so as to avoid holding it for too long.
+ * Retry starting at the mmap_sem acquire, this time
+ * without FAULT_FLAG_RETRY so that we avoid any
+ * risk of starvation.
+ */
+ release_flag = 0;
+ goto retry;
+ }

Do we really want to count a minor page fault when we
got VM_FAULT_RELEASED?

--
All rights reversed
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/