From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753820AbdBMPfV (ORCPT ); Mon, 13 Feb 2017 10:35:21 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:40341 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753788AbdBMPfP (ORCPT ); Mon, 13 Feb 2017 10:35:15 -0500 Date: Mon, 13 Feb 2017 16:35:10 +0100 (CET) From: Thomas Gleixner To: Dmitry Safonov cc: linux-kernel@vger.kernel.org, 0x7f454c46@gmail.com, Ingo Molnar , "H. Peter Anvin" , Andy Lutomirski , Borislav Petkov , x86@kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv4 2/5] x86/mm: introduce mmap{,_legacy}_base In-Reply-To: Message-ID: References: <20170130120432.6716-1-dsafonov@virtuozzo.com> <20170130120432.6716-3-dsafonov@virtuozzo.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 13 Feb 2017, Dmitry Safonov wrote: > On 02/11/2017 05:13 PM, Thomas Gleixner wrote: > > > -static unsigned long mmap_base(unsigned long rnd) > > > +static unsigned long mmap_base(unsigned long rnd, unsigned long > > > task_size) > > > { > > > unsigned long gap = rlimit(RLIMIT_STACK); > > unsigned long gap_min, gap_max; > > > > /* Add comment what this means */ > > gap_min = SIZE_128M + stack_maxrandom_size(task_size); > > /* Explain that ' /6 * 5' magic */ > > gap_max = (task_size / 6) * 5; > > So, I can't find about those limits on a gap size: > They were introduced by commit 8913d55b6c58 ("i386 virtual memory > layout rework"). > All I could find is that 128Mb limit was more limit on virtual adress > space than on a memory available those days. > And 5/6 of task_size looks like heuristic value. > So I'm not sure, what to write in comments: > that rlimit on stack can't be bigger than 5/6 of task_size? > That looks obvious from the code. So just leave it alone. 5/6 is pulled from thin air and 128M probably as well. I hoped there would be some reasonable explanation .... Thanks, tglx From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk0-f72.google.com (mail-vk0-f72.google.com [209.85.213.72]) by kanga.kvack.org (Postfix) with ESMTP id 480CA6B0388 for ; Mon, 13 Feb 2017 10:35:22 -0500 (EST) Received: by mail-vk0-f72.google.com with SMTP id n125so67806441vke.0 for ; Mon, 13 Feb 2017 07:35:22 -0800 (PST) Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id w17si5985506wmw.22.2017.02.13.07.35.21 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 13 Feb 2017 07:35:21 -0800 (PST) Date: Mon, 13 Feb 2017 16:35:10 +0100 (CET) From: Thomas Gleixner Subject: Re: [PATCHv4 2/5] x86/mm: introduce mmap{,_legacy}_base In-Reply-To: Message-ID: References: <20170130120432.6716-1-dsafonov@virtuozzo.com> <20170130120432.6716-3-dsafonov@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Dmitry Safonov Cc: linux-kernel@vger.kernel.org, 0x7f454c46@gmail.com, Ingo Molnar , "H. Peter Anvin" , Andy Lutomirski , Borislav Petkov , x86@kernel.org, linux-mm@kvack.org On Mon, 13 Feb 2017, Dmitry Safonov wrote: > On 02/11/2017 05:13 PM, Thomas Gleixner wrote: > > > -static unsigned long mmap_base(unsigned long rnd) > > > +static unsigned long mmap_base(unsigned long rnd, unsigned long > > > task_size) > > > { > > > unsigned long gap = rlimit(RLIMIT_STACK); > > unsigned long gap_min, gap_max; > > > > /* Add comment what this means */ > > gap_min = SIZE_128M + stack_maxrandom_size(task_size); > > /* Explain that ' /6 * 5' magic */ > > gap_max = (task_size / 6) * 5; > > So, I can't find about those limits on a gap size: > They were introduced by commit 8913d55b6c58 ("i386 virtual memory > layout rework"). > All I could find is that 128Mb limit was more limit on virtual adress > space than on a memory available those days. > And 5/6 of task_size looks like heuristic value. > So I'm not sure, what to write in comments: > that rlimit on stack can't be bigger than 5/6 of task_size? > That looks obvious from the code. So just leave it alone. 5/6 is pulled from thin air and 128M probably as well. I hoped there would be some reasonable explanation .... Thanks, tglx -- 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