From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932403AbdBVNFD (ORCPT ); Wed, 22 Feb 2017 08:05:03 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35726 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932205AbdBVNE4 (ORCPT ); Wed, 22 Feb 2017 08:04:56 -0500 Date: Wed, 22 Feb 2017 16:04:51 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: Linus Torvalds , "Kirill A. Shutemov" , Andrew Morton , the arch/x86 maintainers , Thomas Gleixner , Ingo Molnar , Arnd Bergmann , "H. Peter Anvin" , Andi Kleen , linux-mm , Linux Kernel Mailing List , Catalin Marinas , Linux API Subject: Re: [PATCHv3 33/33] mm, x86: introduce PR_SET_MAX_VADDR and PR_GET_MAX_VADDR Message-ID: <20170222130451.GA23555@node.shutemov.name> References: <20170217141328.164563-1-kirill.shutemov@linux.intel.com> <20170217141328.164563-34-kirill.shutemov@linux.intel.com> <20170218092133.GA17471@node.shutemov.name> <20170220131515.GA9502@node.shutemov.name> <0d05ac45-a139-6f8e-f98b-71876fbb509d@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0d05ac45-a139-6f8e-f98b-71876fbb509d@intel.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 21, 2017 at 12:46:55PM -0800, Dave Hansen wrote: > Let me make sure I'm grokking what you're trying to do here. > > On 02/20/2017 05:15 AM, Kirill A. Shutemov wrote: > > +/* MPX cannot handle addresses above 47-bits yet. */ > > +unsigned long mpx_unmapped_area_check(unsigned long addr, unsigned long len, > > + unsigned long flags) > > +{ > > + if (!kernel_managing_mpx_tables(current->mm)) > > + return addr; > > + if (addr + len <= DEFAULT_MAP_WINDOW) > > + return addr; > > At this point, we know MPX management is on and the hint is for memory > above DEFAULT_MAP_WINDOW? Right. > > + if (flags & MAP_FIXED) > > + return -ENOMEM; > > ... and if it's a MAP_FIXED request, fail it. Yep. > > + if (len > DEFAULT_MAP_WINDOW) > > + return -ENOMEM; > > What is this case for? If addr+len wraps? If len is too big to fit into DEFAULT_MAP_WINDOW there's no point in resetting hint address as we know we can't satisfy it -- fail early. > > > + /* Look for unmap area within DEFAULT_MAP_WINDOW */ > > + return 0; > > +} > > Otherwise, blow away the hint, which we know is high and needs to > be discarded? Right. -- Kirill A. Shutemov From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Kirill A. Shutemov" Subject: Re: [PATCHv3 33/33] mm, x86: introduce PR_SET_MAX_VADDR and PR_GET_MAX_VADDR Date: Wed, 22 Feb 2017 16:04:51 +0300 Message-ID: <20170222130451.GA23555@node.shutemov.name> References: <20170217141328.164563-1-kirill.shutemov@linux.intel.com> <20170217141328.164563-34-kirill.shutemov@linux.intel.com> <20170218092133.GA17471@node.shutemov.name> <20170220131515.GA9502@node.shutemov.name> <0d05ac45-a139-6f8e-f98b-71876fbb509d@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <0d05ac45-a139-6f8e-f98b-71876fbb509d-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Dave Hansen Cc: Linus Torvalds , "Kirill A. Shutemov" , Andrew Morton , the arch/x86 maintainers , Thomas Gleixner , Ingo Molnar , Arnd Bergmann , "H. Peter Anvin" , Andi Kleen , linux-mm , Linux Kernel Mailing List , Catalin Marinas , Linux API List-Id: linux-api@vger.kernel.org On Tue, Feb 21, 2017 at 12:46:55PM -0800, Dave Hansen wrote: > Let me make sure I'm grokking what you're trying to do here. > > On 02/20/2017 05:15 AM, Kirill A. Shutemov wrote: > > +/* MPX cannot handle addresses above 47-bits yet. */ > > +unsigned long mpx_unmapped_area_check(unsigned long addr, unsigned long len, > > + unsigned long flags) > > +{ > > + if (!kernel_managing_mpx_tables(current->mm)) > > + return addr; > > + if (addr + len <= DEFAULT_MAP_WINDOW) > > + return addr; > > At this point, we know MPX management is on and the hint is for memory > above DEFAULT_MAP_WINDOW? Right. > > + if (flags & MAP_FIXED) > > + return -ENOMEM; > > ... and if it's a MAP_FIXED request, fail it. Yep. > > + if (len > DEFAULT_MAP_WINDOW) > > + return -ENOMEM; > > What is this case for? If addr+len wraps? If len is too big to fit into DEFAULT_MAP_WINDOW there's no point in resetting hint address as we know we can't satisfy it -- fail early. > > > + /* Look for unmap area within DEFAULT_MAP_WINDOW */ > > + return 0; > > +} > > Otherwise, blow away the hint, which we know is high and needs to > be discarded? Right. -- Kirill A. Shutemov From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f197.google.com (mail-wr0-f197.google.com [209.85.128.197]) by kanga.kvack.org (Postfix) with ESMTP id E84326B0389 for ; Wed, 22 Feb 2017 08:04:56 -0500 (EST) Received: by mail-wr0-f197.google.com with SMTP id 89so749397wrr.2 for ; Wed, 22 Feb 2017 05:04:56 -0800 (PST) Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com. [2a00:1450:400c:c09::242]) by mx.google.com with ESMTPS id y62si2084956wmb.48.2017.02.22.05.04.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Feb 2017 05:04:55 -0800 (PST) Received: by mail-wm0-x242.google.com with SMTP id i186so357543wmf.1 for ; Wed, 22 Feb 2017 05:04:55 -0800 (PST) Date: Wed, 22 Feb 2017 16:04:51 +0300 From: "Kirill A. Shutemov" Subject: Re: [PATCHv3 33/33] mm, x86: introduce PR_SET_MAX_VADDR and PR_GET_MAX_VADDR Message-ID: <20170222130451.GA23555@node.shutemov.name> References: <20170217141328.164563-1-kirill.shutemov@linux.intel.com> <20170217141328.164563-34-kirill.shutemov@linux.intel.com> <20170218092133.GA17471@node.shutemov.name> <20170220131515.GA9502@node.shutemov.name> <0d05ac45-a139-6f8e-f98b-71876fbb509d@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0d05ac45-a139-6f8e-f98b-71876fbb509d@intel.com> Sender: owner-linux-mm@kvack.org List-ID: To: Dave Hansen Cc: Linus Torvalds , "Kirill A. Shutemov" , Andrew Morton , the arch/x86 maintainers , Thomas Gleixner , Ingo Molnar , Arnd Bergmann , "H. Peter Anvin" , Andi Kleen , linux-mm , Linux Kernel Mailing List , Catalin Marinas , Linux API On Tue, Feb 21, 2017 at 12:46:55PM -0800, Dave Hansen wrote: > Let me make sure I'm grokking what you're trying to do here. > > On 02/20/2017 05:15 AM, Kirill A. Shutemov wrote: > > +/* MPX cannot handle addresses above 47-bits yet. */ > > +unsigned long mpx_unmapped_area_check(unsigned long addr, unsigned long len, > > + unsigned long flags) > > +{ > > + if (!kernel_managing_mpx_tables(current->mm)) > > + return addr; > > + if (addr + len <= DEFAULT_MAP_WINDOW) > > + return addr; > > At this point, we know MPX management is on and the hint is for memory > above DEFAULT_MAP_WINDOW? Right. > > + if (flags & MAP_FIXED) > > + return -ENOMEM; > > ... and if it's a MAP_FIXED request, fail it. Yep. > > + if (len > DEFAULT_MAP_WINDOW) > > + return -ENOMEM; > > What is this case for? If addr+len wraps? If len is too big to fit into DEFAULT_MAP_WINDOW there's no point in resetting hint address as we know we can't satisfy it -- fail early. > > > + /* Look for unmap area within DEFAULT_MAP_WINDOW */ > > + return 0; > > +} > > Otherwise, blow away the hint, which we know is high and needs to > be discarded? Right. -- Kirill A. Shutemov -- 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