Received: by 10.223.164.202 with SMTP id h10csp277947wrb; Tue, 14 Nov 2017 01:04:44 -0800 (PST) X-Google-Smtp-Source: AGs4zMbzJ7+tvzu/jGMycV0YldcsL4hl8Jm9QyJQaMlOhoPbX75t2UUMrzopMQ/+5g47nk5o0tb+ X-Received: by 10.84.133.15 with SMTP id 15mr10225717plf.367.1510650284580; Tue, 14 Nov 2017 01:04:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510650284; cv=none; d=google.com; s=arc-20160816; b=LpHOTM4jyYCn9RN0B3MlEx0t8g4H6m0yMvnVYCPByOHJnmZkeE1DvWgtidPDcrfIp/ TN+t4wosSGRBE8ktsTICzVfhjE/lzGPV4VG7W0/jRTxwhhrpNt1iwoSgdBz8KGfmXkWZ zEtXMnV8TXxcwL8M76cvxPTiD5sNDVoyNdIhvR+wNG0+tGuhh9rS3wGLSkl/Fg8Qag7F 345KczgEaqzg2j5p6USA+Z4bKetpta3Z2qcmwQNS7oaudvFAD2yOT+0CxlzM1mn2gkby xO9iXBbfwGwfJue7/sMfLBkr7bHGU3WrqYFJydaMaVJwMH8fNhX8f4Vd5Ica1rQZr3Yr XEaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:arc-authentication-results; bh=8a8fzR+ymBf5ZHpYo6/Dfj6DuCDxkkfzutAZ6oXQ2L0=; b=rBqfksSseJj2HXe4sam2AmgqybaY+QNx7Ei0OML8jW3wshpZY+tZV1ahyOj35TtDii /Lgzxiogp06fwZT8tZ44OeNDSrgOmKQ6PkjrVW7HYCkOoCRhesYd6cgxKX8ck2Mnq0pp Y+aq4aFNsf44iXA08nrt/PrBaAJdlEYAazDK57qL1tJltaujWjqXb86sgKrox3RrzU64 3+WROkoEmmeHRK5Lwi027KSIugYruJld7lSetPskPCOPkM7l4/EHri4ct+Tt8gi0sGo4 FUz1HLoWhCD5o1XD3yQXRViC7ikzXZfAfdhI8ufLnSTnT/0RAWRFgl36Z06PnqWveeDG YUrA== ARC-Authentication-Results: i=1; mx.google.com; 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 p5si15480547pgu.279.2017.11.14.01.04.32; Tue, 14 Nov 2017 01:04:44 -0800 (PST) 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; 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 S1753458AbdKNJCV (ORCPT + 88 others); Tue, 14 Nov 2017 04:02:21 -0500 Received: from ozlabs.org ([103.22.144.67]:38161 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752067AbdKNJCN (ORCPT ); Tue, 14 Nov 2017 04:02:13 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 3ybhN232lMz9sPs; Tue, 14 Nov 2017 20:02:10 +1100 (AEDT) From: Michael Ellerman To: Michal Hocko Cc: Joel Stanley , Stephen Rothwell , Andrew Morton , Linux-Next Mailing List , Linux Kernel Mailing List , Russell King , Benjamin Herrenschmidt , Abdul Haleem , Ralf Baechle , "James E.J. Bottomley" , Helge Deller , Yoshinori Sato , Rich Felker , "David S. Miller" , Chris Zankel , Max Filippov , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-mips@linux-mips.org, linux-parisc@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org Subject: Re: linux-next: Tree for Nov 7 In-Reply-To: <20171113151641.yfqrecpcxllpn5mq@dhcp22.suse.cz> References: <20171107162217.382cd754@canb.auug.org.au> <20171108142050.7w3yliulxjeco3b7@dhcp22.suse.cz> <20171110123054.5pnefm3mczsfv7bz@dhcp22.suse.cz> <20171113092006.cjw2njjukt6limvb@dhcp22.suse.cz> <20171113094203.aofz2e7kueitk55y@dhcp22.suse.cz> <87lgjawgx1.fsf@concordia.ellerman.id.au> <20171113120057.555mvrs4fjq5tyng@dhcp22.suse.cz> <20171113151641.yfqrecpcxllpn5mq@dhcp22.suse.cz> Date: Tue, 14 Nov 2017 20:02:09 +1100 Message-ID: <87efp1w7vy.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michal Hocko writes: > On Mon 13-11-17 13:00:57, Michal Hocko wrote: > [...] >> Yes, I have mentioned that in the previous email but the amount of code >> would be even larger. Basically every arch which reimplements >> arch_get_unmapped_area would have to special case new MAP_FIXED flag to >> do vma lookup. > > It turned out that this might be much more easier than I thought after > all. It seems we can really handle that in the common code. Ah nice. I should have read this before replying to your previous mail. > This would mean that we are exposing a new functionality to the userspace though. > Myabe this would be useful on its own though. Yes I think it would. At least jemalloc seems like it could use it: https://github.com/jemalloc/jemalloc/blob/9f455e2786685b443201c33119765c8093461174/src/pages.c#L65 And I have memories of some JIT code I read once which did a loop of mmap()s or something to try and get allocations below 4GB or some other limit - but I can't remember now what it was. > Just a quick draft (not > even compile tested) whether this makes sense in general. I would be > worried about unexpected behavior when somebody set other bit without a > good reason and we might fail with ENOMEM for such a call now. > > Elf loader would then use MAP_FIXED_SAFE rather than MAP_FIXED. > --- > diff --git a/arch/alpha/include/uapi/asm/mman.h b/arch/alpha/include/uapi/asm/mman.h > index 3b26cc62dadb..d021c21f9b01 100644 > --- a/arch/alpha/include/uapi/asm/mman.h > +++ b/arch/alpha/include/uapi/asm/mman.h > @@ -31,6 +31,9 @@ > #define MAP_STACK 0x80000 /* give out an address that is best suited for process/thread stacks */ > #define MAP_HUGETLB 0x100000 /* create a huge page mapping */ > > +#define MAP_KEEP_MAPPING 0x2000000 > +#define MAP_FIXED_SAFE MAP_FIXED|MAP_KEEP_MAPPING /* enforce MAP_FIXED without clobbering an existing mapping */ So bike-shedding a bit, but I think "SAFE" is too vague a name. Perhaps MAP_NO_CLOBBER - which has the single semantic of "do not clobber any existing mappings". It would be a flag on its own, so you could pass it with or without MAP_FIXED, but it would only change the behaviour when MAP_FIXED is specified also. cheers From 1584031156652656318@xxx Tue Nov 14 08:57:10 +0000 2017 X-GM-THRID: 1583423641769727671 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread