Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4071409pxk; Tue, 22 Sep 2020 09:33:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy86z41SMhRk7x1tNQRYgHw801sgpZswjk8wMmQ5idhmGSzdC83N1t2yh7N1t0DYWQ1Y6JK X-Received: by 2002:a05:6402:8:: with SMTP id d8mr4595063edu.15.1600792417824; Tue, 22 Sep 2020 09:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600792417; cv=none; d=google.com; s=arc-20160816; b=puG+Wki1G4xrI5UwKCA9rU0ETXJVaDIfgiTALCIa5Vt8/HZYC5k2DT8NU2V+p4q74t 4U3gZll/uEmDzx4L22jIz4N0MRWqsdb14dq+iaagkc4/EEGnf44iqSiBMVMVPbX+S171 +WnFRMk9r7DGE2Jgy1a4wfwX3mSuEwnNEJzaoYA20bkAf7PgoSbSfvVEEUGD7A8dTvMZ iZ5+GLFSzuccsXewZbRABSF0lJKwYijQ5TaNVxFrATf2XpzNpKF7W17iuCJFJHSiTu26 0OsLEP069BBMqs0J4qp0gWR8w9l0c+zI347E8UmbXLC2AS+TQnLgzZJzRbyELenKZRbh 3L7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DFpj/fnUMBVQLv0uLvE3QXIgKUcQAnB9yQv3L++wgJU=; b=b3gbcMs2v55/h4mJkSsR1p5IqLXUQQ2ei49ogGl48Eguo2+iZU81LGSSrq6ZSxdDg1 0nIZ8k3iv0SXmqJq+myaQN2Dc8Y2DWM0D5CkCfiazHka33/8jK0xELN03VG2s+XutQML nBp5K2i6SG4kpRRGGU7JmrpMhGeElrXttWByqI9QjgX7NW48lfyroqYSjiXWcsfoa/lA Kf9GWFsBQaG37Ew+OmBgZ+K15ZYjwDpLcYXTPFHkLcX95pe8vZrtlz+XjI88XC5T5hDX m5j+5XLjHQiPEh+PMSv9czTHEpZBZTOnDRjJO21zyk+eSv5Tgrl/EqAwgpDHbJ1LJnSj tKzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Ykybzvgs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i24si10663081edr.73.2020.09.22.09.33.12; Tue, 22 Sep 2020 09:33:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Ykybzvgs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726635AbgIVQba (ORCPT + 99 others); Tue, 22 Sep 2020 12:31:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726508AbgIVQb3 (ORCPT ); Tue, 22 Sep 2020 12:31:29 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CCE9C061755 for ; Tue, 22 Sep 2020 09:31:27 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id z19so18757179lfr.4 for ; Tue, 22 Sep 2020 09:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DFpj/fnUMBVQLv0uLvE3QXIgKUcQAnB9yQv3L++wgJU=; b=YkybzvgsCHqPgIFq6Rud8tyuaqdZr9vGTAyZxsIiWRVexRhWCRrS+v9oNSbrCu4xIR 8UcTYJaVaI/Gu3cfE/F1I43yvPFkhcJBS/XIFCWtBjzB7SQ6lY7UOhuCPISzX1jLKYxR 39zZRGKf5CbJwSqWpkH7pq/5qL2nGedfUDJHI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DFpj/fnUMBVQLv0uLvE3QXIgKUcQAnB9yQv3L++wgJU=; b=OZHXQDf0Ca6ayNzn2bHCYe42ynxNhneaR5EEp/zmufM0H/FszKFoJcl3l2+tfhWVRk mIZbl8I1QrprHGL6WV62hgtESTXx8cVJZ5iNpZXtsQOD129XLpTRyK3VPOPFhBc0caZL 42SjlbuPCZ+I48i22x7J3KD3yIpn7om8yvgJju/p0CbSthfWCFM2pgsEZXtpQ/OJIxub VC2FzuHJD/AX89Um3NTQVYul44aTYqQ8HiXWT08rqXBHiMt7WQAVjfMkPGbB5XNd07ES 17uHtrXrKPQIG3rUKR0KF3Pb2KzeCtFKdCuh4JOJNCNgGP4x273z55G+KN1IybvzxwMF otAw== X-Gm-Message-State: AOAM531Azx3ZdQcQpjRoZ0V9/zP3PTuLahRH7VmLIydl/X4sLoZTf+0f PLHsaYbJ0zoCrW8v8En72ala6/LQg6thmg== X-Received: by 2002:ac2:4477:: with SMTP id y23mr2155497lfl.378.1600792285416; Tue, 22 Sep 2020 09:31:25 -0700 (PDT) Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com. [209.85.208.182]) by smtp.gmail.com with ESMTPSA id y26sm3921964ljy.88.2020.09.22.09.31.22 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Sep 2020 09:31:23 -0700 (PDT) Received: by mail-lj1-f182.google.com with SMTP id u21so14672412ljl.6 for ; Tue, 22 Sep 2020 09:31:22 -0700 (PDT) X-Received: by 2002:a05:651c:104c:: with SMTP id x12mr1929758ljm.285.1600792282400; Tue, 22 Sep 2020 09:31:22 -0700 (PDT) MIME-Version: 1.0 References: <20200921211744.24758-1-peterx@redhat.com> <20200921211744.24758-2-peterx@redhat.com> <20200921223004.GB19098@xz-x1> <20200922115436.GG8409@ziepe.ca> <20200922142802.GC19098@xz-x1> <20200922155604.GA731578@ziepe.ca> In-Reply-To: <20200922155604.GA731578@ziepe.ca> From: Linus Torvalds Date: Tue, 22 Sep 2020 09:25:04 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/5] mm: Introduce mm_struct.has_pinned To: Jason Gunthorpe Cc: Peter Xu , Jann Horn , Linux-MM , kernel list , Andrew Morton , Jan Kara , Michal Hocko , Kirill Tkhai , Kirill Shutemov , Hugh Dickins , Christoph Hellwig , Andrea Arcangeli , John Hubbard , Oleg Nesterov , Leon Romanovsky Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 22, 2020 at 8:56 AM Jason Gunthorpe wrote: > > I thought MAP_PRIVATE without PROT_WRITE was nonsensical, MAP_PRIVATE without PROT_WRITE is very common. It's what happens for every executable mapping, for example. And no, it's not the same as MAP_SHARED, for a couple of simple reasons. It does end up being similar for all the *normal* cases, but there are various cases where it isn't. - mprotect() and friends. MAP_PRIVATE is fixed, but it might have been writable in the past, and it might become writable in the future. - breakpoints and ptrace. This will punch through even a non-writable mapping and force a COW (since that's the whole point: executables are not writable, but to do a SW breakpoint you have to write to the page) So no, MAP_PRIVATE is not nonsensical without PROT_WRITE, and it's not even remotely unusual. Linus