Received: by 10.192.165.156 with SMTP id m28csp1165573imm; Wed, 11 Apr 2018 13:42:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx49f++dCjNmAEJX73HitBYSHe6OKvjzVRa/hGdYY/+h30ZjeRnsne+fv1Uyvy+oFXfmEJNn2 X-Received: by 10.98.237.18 with SMTP id u18mr5270346pfh.78.1523479361937; Wed, 11 Apr 2018 13:42:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523479361; cv=none; d=google.com; s=arc-20160816; b=c2FtXenOUHaofiHc/k4rchH0xi/Nj3S8SVamLlj8FEVoLK7SgsdebBZ8qlFpBTs/lL 3l8j0PHZUPtn5B8ZdeP8XqMjAhyIzegGLeq8kM+74BPo6LIKQafNpjlGDQgYnodGfuEN y+RVsnKr1I9SdEJJD7jcjv0/q2ng/7OhMZe4q3Q6VD5aK4O7AnemUBlRWhDK/K8V7Epo ZRLhqi2BK3cBrWrnWpqJ5l8nYOb5+fztYYSZTfQCiWdFa0d1wtU6/63LdayAWOgqKAjR YsPz0+fep3kJwfXA/zfxZse328oGZ3W/oco2xaohgTjFfzStk/Tk31f0ezj5H+3SW8HY By5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=7dRo9wwyY9JZ3CIu+C/QZ8AaoGHmFUsSVdaOvSQLMj4=; b=NvKI0Rvr1qZGxZDzu/4Uaq6pTYjHB6rLgz+9ZXymtj0HgDnBiwwE6vBUj6GKalJ+3T 4l7K7bVB0dBLoPI9CGPMevXPxLVGjmZRuc/NWPoKSA4ZEBqJPxaQfF7fg5Xhhkost9TU GuijYvEo1mpsBZiIPtha8n9QyEEFOdP92ofhj87SvG6R3jb2Iirz2EYb650FzLQULuBm xGwPvEW+qS4Pl676A82wYz+wQ/zCpqWJLdYPfYr0ayZ5x9EWEHtqa6ii9mtj8Or4+Vjk jzsQYvN3iIBmz8t14eMhJh4Bv/0BoNv/gqVm9bYgD4VA3EP23YTirZGq3elojXtOKlRR zKDg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i132si1186257pgc.509.2018.04.11.13.42.04; Wed, 11 Apr 2018 13:42:41 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932577AbeDKUg0 (ORCPT + 99 others); Wed, 11 Apr 2018 16:36:26 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:7662 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755724AbeDKUgX (ORCPT ); Wed, 11 Apr 2018 16:36:23 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com id ; Wed, 11 Apr 2018 13:36:09 -0700 Received: from HQMAIL107.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 11 Apr 2018 13:36:22 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 11 Apr 2018 13:36:22 -0700 Received: from [10.110.48.28] (10.110.48.28) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 11 Apr 2018 20:36:22 +0000 Subject: Re: [PATCH] mmap.2: document new MAP_FIXED_NOREPLACE flag To: Jann Horn , Michal Hocko CC: Michael Kerrisk , Andrew Morton , Linux-MM , LKML , Linux API , Michal Hocko References: <20180411120452.1736-1-mhocko@kernel.org> X-Nvconfidentiality: public From: John Hubbard Message-ID: <827ead33-5d93-7696-9c5e-1cd04f772476@nvidia.com> Date: Wed, 11 Apr 2018 13:36:21 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.110.48.28] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/11/2018 08:37 AM, Jann Horn wrote: > On Wed, Apr 11, 2018 at 2:04 PM, wrote: >> From: Michal Hocko >> >> 4.17+ kernels offer a new MAP_FIXED_NOREPLACE flag which allows the caller to >> atomicaly probe for a given address range. >> >> [wording heavily updated by John Hubbard ] >> Signed-off-by: Michal Hocko >> --- >> Hi, >> Andrew's sent the MAP_FIXED_NOREPLACE to Linus for the upcoming merge >> window. So here we go with the man page update. >> >> man2/mmap.2 | 27 +++++++++++++++++++++++++++ >> 1 file changed, 27 insertions(+) >> >> diff --git a/man2/mmap.2 b/man2/mmap.2 >> index ea64eb8f0dcc..f702f3e4eba2 100644 >> --- a/man2/mmap.2 >> +++ b/man2/mmap.2 >> @@ -261,6 +261,27 @@ Examples include >> and the PAM libraries >> .UR http://www.linux-pam.org >> .UE . >> +Newer kernels >> +(Linux 4.17 and later) have a >> +.B MAP_FIXED_NOREPLACE >> +option that avoids the corruption problem; if available, MAP_FIXED_NOREPLACE >> +should be preferred over MAP_FIXED. > > This still looks wrong to me. There are legitimate uses for MAP_FIXED, > and for most users of MAP_FIXED that I'm aware of, MAP_FIXED_NOREPLACE > wouldn't work while MAP_FIXED works perfectly well. > > MAP_FIXED is for when you have already reserved the targeted memory > area using another VMA; MAP_FIXED_NOREPLACE is for when you haven't. That's a nice summary, I hope it shows up in your upcoming patch. I recall that we went back and forth, trying to find a balance of explaining this feature, without providing overly-elaborate examples (which I tend toward). > Please don't make it sound as if MAP_FIXED is always wrong. > Agreed. thanks, -- John Hubbard NVIDIA