From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Hansen Date: Tue, 04 Nov 2014 16:00:25 +0000 Subject: Re: [PATCH v9 11/12] x86, mpx: cleanup unused bound tables Message-Id: <5458F819.2010503@intel.com> List-Id: References: <1413088915-13428-1-git-send-email-qiaowei.ren@intel.com> <1413088915-13428-12-git-send-email-qiaowei.ren@intel.com> <544DB873.1010207@intel.com> <5457EB67.70904@intel.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Thomas Gleixner Cc: Ren Qiaowei , "H. Peter Anvin" , Ingo Molnar , x86@kernel.org, Linux-MM , linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linux-mips@linux-mips.org On 11/03/2014 01:29 PM, Thomas Gleixner wrote: > On Mon, 3 Nov 2014, Dave Hansen wrote: > That's not really true. You can evaluate that information with > mmap_sem held for read as well. Nothing can change the mappings until > you drop it. So you could do: > > down_write(mm->bd_sem); > down_read(mm->mmap_sem; > evaluate_size_of_shm_to_unmap(); > clear_bounds_directory_entries(); > up_read(mm->mmap_sem); > do_the_real_shm_unmap(); > up_write(mm->bd_sem); > > That should still be covered by the above scheme. Yep, that'll work. It just means rewriting the shmdt()/mremap() code to do a "dry run" of sorts. Do you have any concerns about adding another mutex to these paths? munmap() isn't as hot of a path as the allocation side, but it does worry me a bit that we're going to perturb some workloads. We might need to find a way to optimize out the bd_sem activity on processes that never used MPX.