Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753798Ab3JJDOx (ORCPT ); Wed, 9 Oct 2013 23:14:53 -0400 Received: from mail-vb0-f52.google.com ([209.85.212.52]:40814 "EHLO mail-vb0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752100Ab3JJDOw (ORCPT ); Wed, 9 Oct 2013 23:14:52 -0400 MIME-Version: 1.0 In-Reply-To: <20131009072838.GY3081@twins.programming.kicks-ass.net> References: <1380753493.11046.82.camel@schen9-DESK> <20131003073212.GC5775@gmail.com> <1381186674.11046.105.camel@schen9-DESK> <20131009061551.GD7664@gmail.com> <20131009072838.GY3081@twins.programming.kicks-ass.net> Date: Wed, 9 Oct 2013 20:14:51 -0700 X-Google-Sender-Auth: im7pU3fwU8xq0ke7VWKvLN0CWsU Message-ID: Subject: Re: [PATCH v8 0/9] rwsem performance optimizations From: Linus Torvalds To: Peter Zijlstra Cc: Ingo Molnar , Tim Chen , Ingo Molnar , Andrew Morton , Andrea Arcangeli , Alex Shi , Andi Kleen , Michel Lespinasse , Davidlohr Bueso , Matthew R Wilcox , Dave Hansen , Rik van Riel , Peter Hurley , "Paul E.McKenney" , Jason Low , Waiman Long , Linux Kernel Mailing List , linux-mm Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1650 Lines: 42 On Wed, Oct 9, 2013 at 12:28 AM, Peter Zijlstra wrote: > > The workload that I got the report from was a virus scanner, it would > spawn nr_cpus threads and {mmap file, scan content, munmap} through your > filesystem. So I suspect we could make the mmap_sem write area *much* smaller for the normal cases. Look at do_mmap_pgoff(), for example: it is run entirely under mmap_sem, but 99% of what it does doesn't actually need the lock. The part that really needs the lock is addr = get_unmapped_area(file, addr, len, pgoff, flags); addr = mmap_region(file, addr, len, vm_flags, pgoff); but we hold it over all the other stuff too. In fact, even if we moved the mmap_sem down into do_mmap(), and moved code around a bit to only hold it over those functions, it would still cover unnecessarily much. For example, while merging is common, not merging is pretty common too, and we do that vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); allocation under the lock. We could easily do things like preallocate it outside the lock. Right now mmap_sem covers pretty much the whole system call (we do do some security checks outside of it). I think the main issue is that nobody has ever cared deeply enough to see how far this could be pushed. I suspect there is some low-hanging fruit for anybody who is willing to handle the pain.. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/