From: Davidlohr Bueso Date: Thu, 22 May 2014 00:42:45 +0000 (+1000) Subject: mm,vmacache: optimize overflow system-wide flushing X-Git-Tag: next-20140530~2^2~376 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e7785c2fa049c9f40a743f231513d8475b96441c;p=karo-tx-linux.git mm,vmacache: optimize overflow system-wide flushing For single threaded workloads, we can avoid flushing and iterating through the entire list of tasks, making the whole function a lot faster, requiring only a single atomic read for the mm_users. Signed-off-by: Davidlohr Bueso Suggested-by: Oleg Nesterov Cc: Aswin Chandramouleeswaran Signed-off-by: Andrew Morton --- diff --git a/mm/vmacache.c b/mm/vmacache.c index 658ed3b3e38d..9f25af825dec 100644 --- a/mm/vmacache.c +++ b/mm/vmacache.c @@ -17,6 +17,16 @@ void vmacache_flush_all(struct mm_struct *mm) { struct task_struct *g, *p; + /* + * Single threaded tasks need not iterate the entire + * list of process. We can avoid the flushing as well + * since the mm's seqnum was increased and don't have + * to worry about other threads' seqnum. Current's + * flush will occur upon the next lookup. + */ + if (atomic_read(&mm->mm_users) == 1) + return; + rcu_read_lock(); for_each_process_thread(g, p) { /*