On Fri, Aug 18, 2017 at 11:54 AM, Mel Gorman wrote: > > One option to mitigate (but not eliminate) the problem is to record when > the page lock is contended and pass in TNF_PAGE_CONTENDED (new flag) to > task_numa_fault(). Well, finding it contended is fairly easy - just look at the page wait queue, and if it's not empty, assume it's due to contention. I also wonder if we could be even *more* hacky, and in the whole __migration_entry_wait() path, change the logic from: - wait on page lock before retrying the fault to - yield() which is hacky, but there's a rationale for it: (a) avoid the crazy long wait queues ;) (b) we know that migration is *supposed* to be CPU-bound (not IO bound), so yielding the CPU and retrying may just be the right thing to do. It's possible that we could just do a hybrid approach, and introduce a "wait_on_page_lock_or_yield()", that does a sleeping wait if the wait-queue is short, and a yield otherwise, but it might be worth just testing the truly stupid patch. Because that code sequence doesn't actually depend on "wait_on_page_lock()" for _correctness_ anyway, afaik. Anybody who does "migration_entry_wait()" _has_ to retry anyway, since the page table contents may have changed by waiting. So I'm not proud of the attached patch, and I don't think it's really acceptable as-is, but maybe it's worth testing? And maybe it's arguably no worse than what we have now? Comments? (Yeah, if we take this approach, we might even just say "screw the spinlock - just do ACCESS_ONCE() and do a yield() if it looks like a migration entry") Linus