Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3269281pxk; Mon, 28 Sep 2020 12:51:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw77kqJGaa7K2dZ56czP27R8oKLUyMSZypHCTLm7uzxau2yS+x6tWNkeQaeWqQvkz6Rc9Hj X-Received: by 2002:a17:906:a256:: with SMTP id bi22mr358226ejb.375.1601322711504; Mon, 28 Sep 2020 12:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601322711; cv=none; d=google.com; s=arc-20160816; b=neWAI9ywtOMKotzjgD55Nl/bAtnREfH1EF6ovTVsT8sxdbqujCsvAt86zWlLronBH3 7RooHd6fQUqaQ8J6USNILr9nBDSO4dQjNeKjs0fAyfyzQpblEU+CfYztZ922qSQOJwg5 jgXb/uMg5FUylGtFW2mHTX5lY/uxOPhRGGMBCM2N1CM6VOB42EB5nJELL3sCBfDY2oex WF9AT7bRsFB9ixBLOSzTuktsIqK9ITAdi2S+5x7XAxlhbj5NG3DRsCKag/E+hzZGJJJf EeElSwwHeNu+t4eCW/WTmsD8cSNrjQT4Fdi+YO0454z7rGEhd1qtRhhGDS91hHROuVVg vNow== 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=iFe59ygllh1csDHLKc44rrpmdcLi64mRKne6cb8G5UI=; b=b5cN1x0VQjcFu7HG6gS6Vweb8Osnxy91WYQNTzSlAGnmIVwnlqPBPoqDR2O88bAhQp EHzHZcUNgezd3rm9fifcUAq8hU2gzxABGhdLBt/G7UsXkVmOUvcrmv2UlvLQwLRVLc9+ SfOQReE4WkeMDrJQ3B/iCdC9sQgNmmxP9cQj4dKcPvn+a53KSAzjPgkUofLQYA9uhnW3 klJKpwabsp/MdFKrcixdsiJuzXiTI4X8DD8fCpuV6VOFMbXMN0wDfX+aJp5QDyU012WC udhfuOu/z2uVQmDsha0ncYhM5ezZyzN2wIHQwcbC+XVhFW+jZzaU1684YBBKvQm3buj4 nmnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Z0cCPdE6; 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 l26si1193728eji.646.2020.09.28.12.51.27; Mon, 28 Sep 2020 12:51:51 -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=Z0cCPdE6; 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 S1726551AbgI1TuZ (ORCPT + 99 others); Mon, 28 Sep 2020 15:50:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbgI1TuZ (ORCPT ); Mon, 28 Sep 2020 15:50:25 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A68BCC061755 for ; Mon, 28 Sep 2020 12:50:23 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id d15so2705063lfq.11 for ; Mon, 28 Sep 2020 12:50:23 -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=iFe59ygllh1csDHLKc44rrpmdcLi64mRKne6cb8G5UI=; b=Z0cCPdE6eUpwNg59dDo5sroppxJdJjGWOa0DlXCxyc6xwoewubzGhHY+W2SnxgFXY6 BQAGI/kDvFOe9f8N/05GMm2wT4fxaHSXxGDf/xGBj/Md6yNoJ1jSVfpzSSSvRwUto3Ff TcmrSRZ+nRW7MfF9KCZ4CrfxAXla/gqbDcT50= 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=iFe59ygllh1csDHLKc44rrpmdcLi64mRKne6cb8G5UI=; b=mUQZW4hn7crtz6XsILv2vdxe2UdtJNkJ9xh0RE0gPVq7/pO1smoSsAdyWNTzTvVyzg q9S/Xl/a4gxVbR4Vy2b6aKQkXqhU/dzms7dOfFCCLBwUIrsWrEqvMvY/oVVGXxWBz/t6 yQuYkspgUp4wdxwBRsq5mQ0OhE4ziHfEgTJVxRXbkr/wcVeV0aKX2JLUCOlBGoHTdZl+ BCY0TsB4kWsORgr9It8LHcbwWIOplTjHqm+jpINg1MYdgdKewnWCeWokW9S2PtsflAkI UNhDvcbfV8V9aHv53T6e3cq5EHOxs5w5fJ7YMfAAmkrvnbJT9XtTHCJ+nKCyQxomRD3f g6Qg== X-Gm-Message-State: AOAM530THqU73yynzSaFBy8YyVr1Ex1jOVuwtj8CIcSPGapOJGyjqIvV 98gnB7gLKzyuij55v41wVHVqW+6oG0RMCA== X-Received: by 2002:a19:c002:: with SMTP id q2mr957850lff.372.1601322621839; Mon, 28 Sep 2020 12:50:21 -0700 (PDT) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com. [209.85.167.41]) by smtp.gmail.com with ESMTPSA id z7sm2956127lfc.59.2020.09.28.12.50.19 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Sep 2020 12:50:20 -0700 (PDT) Received: by mail-lf1-f41.google.com with SMTP id 77so2767619lfj.0 for ; Mon, 28 Sep 2020 12:50:19 -0700 (PDT) X-Received: by 2002:ac2:4ec7:: with SMTP id p7mr913345lfr.352.1601322619227; Mon, 28 Sep 2020 12:50:19 -0700 (PDT) MIME-Version: 1.0 References: <20200926004136.GJ9916@ziepe.ca> <20200927062337.GE2280698@unreal> <20200928124937.GN9916@ziepe.ca> <20200928172256.GB59869@xz-x1> <20200928183928.GR9916@ziepe.ca> In-Reply-To: From: Linus Torvalds Date: Mon, 28 Sep 2020 12:50:03 -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 , Leon Romanovsky , John Hubbard , Linux-MM , Linux Kernel Mailing List , Andrew Morton , Jan Kara , Michal Hocko , Kirill Tkhai , Kirill Shutemov , Hugh Dickins , Christoph Hellwig , Andrea Arcangeli , Oleg Nesterov , Jann Horn Content-Type: multipart/mixed; boundary="000000000000e3fbfb05b064f9df" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000e3fbfb05b064f9df Content-Type: text/plain; charset="UTF-8" On Mon, Sep 28, 2020 at 12:36 PM Linus Torvalds wrote: > > So I'll do the pte wrprotect/restore removal. Anybody willing to do > and test the sequence count approach? So the wrprotect removal is trivial, with most of it being about the comments. However, when I look at this, I am - once again - tempted to just add a if (__page_mapcount(page) > 1) return 1; there too. Because we know it's a private mapping (shared mappings we checked for with the "is_cow_mapping()" earlier), and the only case we really care about is the one where the page is only mapped in the current mm (because that's what a write pinning will have done, and as mentioned, a read pinning doesn't do anything wrt fork() right now anyway). So if it's mapped in another mm, the COW clearly hasn't been broken by a pin, and a read pinned page had already gone through a fork. But the more I look at this code, the more I go "ok, I want somebody to actually test this with the rdma case". So I'll attach my suggested patch, but I won't actually commit it. I'd really like to have this tested, possibly _together_ with the sequence count addition.. Linus --000000000000e3fbfb05b064f9df Content-Type: application/octet-stream; name=patch Content-Disposition: attachment; filename=patch Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kfmy4mp90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