Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3266531pxk; Mon, 28 Sep 2020 12:45:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFJZjYMckzjwtE7tphkHhPyTssUCnPObEunwXuWPGIkbkbkUhsCAefNbf0j7av0q20IvJQ X-Received: by 2002:a17:906:6409:: with SMTP id d9mr380187ejm.344.1601322350699; Mon, 28 Sep 2020 12:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601322350; cv=none; d=google.com; s=arc-20160816; b=BH1cyQ/aC8Ob5B/Fx1/5fPN4aT+oLA8TKfGGxpzc4JXHT6VBUKLmCRS9f3CFg/eTao C/k8+sMHNCAaXJnzHh6rRnC6vW5hRQBsYjAJhJl6hw07EsaJHuRLp1SnO+M0RPs3CH8e Zn4tfmEAmuh4A//siDnpbMdDnWbBb66ACgUIyct759aU8z4Rp8v33VMJRIPapQj9uHn0 d8mWApliV1Xzn5rJVMLXdhx6OPvRaP+55UaAwukgzPIjFDHcOnG2vAv1E99WjpiPkUeh 5XgZZYchgfX9fLIHauTAzFUbZSKDqkrW9kK4X0UButzr3S/BFJnfgk3S2LHmm29n7fen IGTw== 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=SkMJ9vgT72YsSMnKCcPYU1IIxIP9bXClnVqgMshREjw=; b=PaMKkg+i1PEpxe5b+o+0j2Ky86XFCqo5mp+TujCQc+2EpxrbiwJCc6LXyR5qzcIx9Y Ivhm+0TCrTPuICATSir0U6+jc9xJTkxo6uId3CdriQixYMrycLL44UN8hGmoNGNx+won E2gU3ItBewgmsFVQ9jSzDS5qejnXK68htCb0Y7b9l9u2w/8ZtRrNTigc4w9ZvPZXnLGv hrersiG6Lb+BlXOqPDYeH2RFuyCWORJn6LOHyBUHZjxQW6QlCVvfTt53wqIhB1nM9FCH fE5+koB+XufF+pxqPSFSIHJbI7lpxq4wOsL8wKc5BqBcZT2KHHQ7dS7fhShrBuTD7Noo zqfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=W4DgUE7i; 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 r12si1288158edb.495.2020.09.28.12.45.27; Mon, 28 Sep 2020 12:45:50 -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=W4DgUE7i; 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 S1726670AbgI1Tm1 (ORCPT + 99 others); Mon, 28 Sep 2020 15:42:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726389AbgI1Tm1 (ORCPT ); Mon, 28 Sep 2020 15:42:27 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED1A8C061755 for ; Mon, 28 Sep 2020 12:42:26 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id g4so3077278edk.0 for ; Mon, 28 Sep 2020 12:42:26 -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=SkMJ9vgT72YsSMnKCcPYU1IIxIP9bXClnVqgMshREjw=; b=W4DgUE7iQ15VMtJKxlGaWgeXDPLdMBzay4aRO5K22JIpWg4LUrshY7AhiCK83/HxRr iv7IIBGBbCzs7J4C7D70277ARK/Tuz/MkxOsngSzwOD1/6iLfOBrHNX2r0CvjKZbSAAZ rb6irsX1QD/b9RVofDrB/GIxk+JxPez+1Wxkc= 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=SkMJ9vgT72YsSMnKCcPYU1IIxIP9bXClnVqgMshREjw=; b=qFAJGzAj2PnENpVn5+0+d0lrUSpDkq/AAmJe8OLeE0gkkWW1N7x0BSjXU1LgxhwmAm zwXnkgMfx0pI0lsPxV9LoSj0M4qaJxw86zMNcJSbrP62yILSMIJZGWWgLygFsHetbSvl 5NtSkZdNlOmuJm6M7VXhTCQhtM/rRMQk33MfdOkm9hDe9BzBmp/67yglvIdbh3S7f9gO nMIWc77hU9BgZdQwfZn5FBGcbi6au75ox1cgpVO9O94814qmIPgon6wNP3T2DQkv71a9 P9IgXmrnvDu+RYhZ/K21P9kaU4qqbVUhtowCYQulO5VHbcRcqYT6dyCDRq671yn/42lq tSnw== X-Gm-Message-State: AOAM533VHxJVqYbI8pyna4019tCp+045EUHE2A3VSZzH/H5L4oADSVzT 8GZeXUmMgVLICnSApOKeUVVEOjgrK+XlAA== X-Received: by 2002:a50:ab59:: with SMTP id t25mr3437373edc.364.1601322145416; Mon, 28 Sep 2020 12:42:25 -0700 (PDT) Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com. [209.85.218.41]) by smtp.gmail.com with ESMTPSA id ef3sm2314155ejb.114.2020.09.28.12.42.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Sep 2020 12:42:25 -0700 (PDT) Received: by mail-ej1-f41.google.com with SMTP id gx22so10616580ejb.5 for ; Mon, 28 Sep 2020 12:42:25 -0700 (PDT) X-Received: by 2002:a05:651c:32e:: with SMTP id b14mr43230ljp.314.1601321800700; Mon, 28 Sep 2020 12:36:40 -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: <20200928183928.GR9916@ziepe.ca> From: Linus Torvalds Date: Mon, 28 Sep 2020 12:36:24 -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: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 28, 2020 at 11:39 AM Jason Gunthorpe wrote: > > All of gup_fast and copy_mm could be wrappered in a seq count so that > gup_fast always goes to the slow path if fork is concurrent. > > That doesn't sound too expensive and avoids all the problems you > pointed with the WP scheme. Ok, I'll start by just removing the "write protect early trick". It really doesn't work reliably anyway due to memory ordering, and while I think the dirty bit is ok (and we could probably also set it unconditionally to make _sure_ it's not dropped like Peter says) it just makes me convinced it's the wrong approach. Fixing it at a per-pte level is too expensive, and yeah, if we really really care about the fork consistency, the sequence count approach should be much simpler and more obvious. So I'll do the pte wrprotect/restore removal. Anybody willing to do and test the sequence count approach? Linus