Received: by 10.213.65.68 with SMTP id h4csp650212imn; Fri, 23 Mar 2018 12:31:52 -0700 (PDT) X-Google-Smtp-Source: AG47ELvR300CKl5yZtPRXMIkq0zakaAHn10wE0bA9SFDQ5Ky4SJHjVX5wunNpX8lqDpQwnfFVMTv X-Received: by 2002:a17:902:2006:: with SMTP id n6-v6mr30908934pla.150.1521833512153; Fri, 23 Mar 2018 12:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521833512; cv=none; d=google.com; s=arc-20160816; b=qgxqWWgPvce9f6pKwbXBEmnZerexqsH9jEaLAy9SLf8qYnntIKeuxO6UwbErcSwaL3 dJnBjt0GiJiSEFD9VB0uzetiX0D60cqMrLBzWhW+CtqkB+sgkboETsVBYasdRKSQz328 G+SZGEQi1WG1DnGcWGySgoQIrutPZA4UuubbhoG0VXlks3wzLCeYwnI/vNvoAJKxOowW 9BvNFtH7vUBatkeT3G8xP2jbvvpSjh2FvUMAQ+QPQvLG8DLYxwRwtQZCb2pRldMxlZVO RM2YDOnE6tWZ17abe9L02AB8oJZy4sxu290J2XEVlrZsHaeiQXFuWHhLkUGmwaIBNlRs +QDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=MirZhxLY8cA+YArmokNLxWyxSkmZVZH0lgxlZu/6dFA=; b=ZiOrRVuJk3gClRr120AwcCwpPbb1Zi9I7jAV2e5BQGE+g2a2OuYuyk1vIt3Sn1WUm9 2bdO+nHIBH1NSFlU0qWiD3FVyAQMipsrl6fn9bHI9T3jSyDSxRmdP/Bu3cUCZGeFASRv Pq+/DLmgg50G8CnwOJNfKNjVIRhvpMMddXoBfOuUA5pEXDvGv/v0KF/2R/uVfbsV2Ze6 9jWfaFz/px2GmBQQSandrwhrrcXyhaES56gR4SioWmgveXMig3wWJIwfL2U4ednEMK1s s6WSLS1lghooX+4AbYj47wNYaL1kFhlS1A35DswQKWutCZmwxwPmSg/icF+YT4reDqZC WUpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=taouZ44F; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7si4631172pfn.30.2018.03.23.12.31.38; Fri, 23 Mar 2018 12:31:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=taouZ44F; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752444AbeCWTao (ORCPT + 99 others); Fri, 23 Mar 2018 15:30:44 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37720 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752249AbeCWTai (ORCPT ); Fri, 23 Mar 2018 15:30:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=MirZhxLY8cA+YArmokNLxWyxSkmZVZH0lgxlZu/6dFA=; b=taouZ44FvD2h9umKYG/Nnncc+ qJjpjuIILm4EE5y7ejLGGtXP/82evZsLbURkP643owGFOqjxbr6/k/exMDD8fz59/8ClDahvbXhjb 0ya7N8Vuee91QbHhZMCSvzDGbzbHkHEYW49maR5+OqE4JOweki9nGGDSPl30nmdhgTNwBdP6q88AP RpKYXbA6lYGwKhB+lU3tIWbyaik/s5O7a8jFPas0N5HiWck/eTxaVTbl9y0zSvbs13GVGTPx4avJ8 8rzl3vXRTriwaZjjhSdPf3ODUDmAPNK59mZJi2wZGX2YNNCCF5jY3zV4E/e8sCbe9BRedz4MrPDIg y3/Ipeq0w==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1ezSNs-0007jM-OG; Fri, 23 Mar 2018 19:29:52 +0000 Date: Fri, 23 Mar 2018 12:29:52 -0700 From: Matthew Wilcox To: Rich Felker Cc: Ilya Smith , rth@twiddle.net, ink@jurassic.park.msu.ru, mattst88@gmail.com, vgupta@synopsys.com, linux@armlinux.org.uk, tony.luck@intel.com, fenghua.yu@intel.com, jhogan@kernel.org, ralf@linux-mips.org, jejb@parisc-linux.org, deller@gmx.de, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, ysato@users.sourceforge.jp, davem@davemloft.net, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, nyc@holomorphy.com, viro@zeniv.linux.org.uk, arnd@arndb.de, gregkh@linuxfoundation.org, deepa.kernel@gmail.com, mhocko@suse.com, hughd@google.com, kstewart@linuxfoundation.org, pombredanne@nexb.com, akpm@linux-foundation.org, steve.capper@arm.com, punit.agrawal@arm.com, paul.burton@mips.com, aneesh.kumar@linux.vnet.ibm.com, npiggin@gmail.com, keescook@chromium.org, bhsharma@redhat.com, riel@redhat.com, nitin.m.gupta@oracle.com, kirill.shutemov@linux.intel.com, dan.j.williams@intel.com, jack@suse.cz, ross.zwisler@linux.intel.com, jglisse@redhat.com, aarcange@redhat.com, oleg@redhat.com, linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-metag@vger.kernel.org, linux-mips@linux-mips.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH v2 0/2] Randomization of address chosen by mmap. Message-ID: <20180323192952.GB23763@bombadil.infradead.org> References: <1521736598-12812-1-git-send-email-blackzert@gmail.com> <20180323124806.GA5624@bombadil.infradead.org> <20180323180024.GB1436@brightrain.aerifal.cx> <20180323190618.GA23763@bombadil.infradead.org> <20180323191621.GC1436@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180323191621.GC1436@brightrain.aerifal.cx> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 23, 2018 at 03:16:21PM -0400, Rich Felker wrote: > > Huh, I thought libc was aware of this. Also, I'd expect a libc-based > > implementation to restrict itself to, eg, only loading libraries in > > the bottom 1GB to avoid applications who want to map huge things from > > running out of unfragmented address space. > > That seems like a rather arbitrary expectation and I'm not sure why > you'd expect it to result in less fragmentation rather than more. For > example if it started from 1GB and worked down, you'd immediately > reduce the contiguous free space from ~3GB to ~2GB, and if it started > from the bottom and worked up, brk would immediately become > unavailable, increasing mmap pressure elsewhere. By *not* limiting yourself to the bottom 1GB, you'll almost immediately fragment the address space even worse. Just looking at 'ls' as a hopefully-good example of a typical app, it maps: linux-vdso.so.1 (0x00007ffef5eef000) libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fb3657f5000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb36543b000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fb3651c9000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb364fc5000) /lib64/ld-linux-x86-64.so.2 (0x00007fb365c3f000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb364da7000) The VDSO wouldn't move, but look at the distribution of mapping 6 things into a 3GB address space in random locations. What are the odds you have a contiguous 1GB chunk of address space? If you restrict yourself to the bottom 1GB before running out of room and falling back to a sequential allocation, you'll prevent a lot of fragmentation.