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. From mboxrd@z Thu Jan 1 00:00:00 1970 Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 04 Nov 2014 17:00:43 +0100 (CET) Received: from mga11.intel.com ([192.55.52.93]:25779 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S27012586AbaKDQAfcsjF1 (ORCPT ); Tue, 4 Nov 2014 17:00:35 +0100 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 04 Nov 2014 08:00:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="411230156" Received: from unknown (HELO [10.255.13.105]) ([10.255.13.105]) by FMSMGA003.fm.intel.com with ESMTP; 04 Nov 2014 07:51:59 -0800 Message-ID: <5458F819.2010503@intel.com> Date: Tue, 04 Nov 2014 08:00:25 -0800 From: Dave Hansen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 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 Subject: Re: [PATCH v9 11/12] x86, mpx: cleanup unused bound tables 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: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 43868 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: dave.hansen@intel.com Precedence: bulk List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: linux-mips X-List-ID: linux-mips List-subscribe: List-owner: List-post: List-archive: X-list: linux-mips 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. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f180.google.com (mail-pd0-f180.google.com [209.85.192.180]) by kanga.kvack.org (Postfix) with ESMTP id DD1F36B0075 for ; Tue, 4 Nov 2014 11:01:04 -0500 (EST) Received: by mail-pd0-f180.google.com with SMTP id ft15so13755618pdb.25 for ; Tue, 04 Nov 2014 08:01:04 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTP id qn7si650047pbc.63.2014.11.04.08.01.02 for ; Tue, 04 Nov 2014 08:01:03 -0800 (PST) Message-ID: <5458F819.2010503@intel.com> Date: Tue, 04 Nov 2014 08:00:25 -0800 From: Dave Hansen MIME-Version: 1.0 Subject: Re: [PATCH v9 11/12] x86, mpx: cleanup unused bound tables 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: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: 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. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org