From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D91ADC433ED for ; Wed, 7 Apr 2021 14:30:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 77DBC60FE9 for ; Wed, 7 Apr 2021 14:30:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77DBC60FE9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DC60C6B0080; Wed, 7 Apr 2021 10:30:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D9C8D6B0081; Wed, 7 Apr 2021 10:30:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C17256B0082; Wed, 7 Apr 2021 10:30:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id A587E6B0080 for ; Wed, 7 Apr 2021 10:30:08 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5D48A40CA for ; Wed, 7 Apr 2021 14:30:08 +0000 (UTC) X-FDA: 78005805696.23.F30AEA2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 6CA983C2 for ; Wed, 7 Apr 2021 14:30:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617805807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GDYJOulx7zxHZLZyk25KIXd/enfCBPJHhg/Sw/V6QOU=; b=ZGxJqhJX3iXWBvhzeFdukfD/jEqS2I4dkEyhLzfnuityooZnZ/Wxef0qw7yfSsRjnYUz6w dbgHyU+VPxvRGpsKFvSs8/c50VgLxu0yzZ/8L/6nKpR1kiq7u5zaPeGtH+uYIwnUdsZsxq 1eQl89QRjf28aaEFkKwJuw1c0Ztw9yg= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-403-jeD5F3JIPvKcIEIfRdTKNg-1; Wed, 07 Apr 2021 10:30:04 -0400 X-MC-Unique: jeD5F3JIPvKcIEIfRdTKNg-1 Received: by mail-qt1-f200.google.com with SMTP id t18so11938328qtw.15 for ; Wed, 07 Apr 2021 07:30:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GDYJOulx7zxHZLZyk25KIXd/enfCBPJHhg/Sw/V6QOU=; b=O3+Hd1efTmsaBJPUEiYvYLe9Zi3e/jQVYzivrtju2ngetlAyLhR3btbBYc29gMap90 fiU/TfQkOJg29lD+O1kZmde+FRy4ACbjlQUrovGK5PKYC1lOys8Bo434Z/IueLSEM7kv t0mgHsKIeygPCU2427b8SPN1Lc44agzrLdF+DR+I9ckD7MzxdkqO5FmbmUMPbxH07wtY kJ3f9wsROoec1up4H47+Owz623is+24kj/J0uLA0pqBTG8EZXHvfuVW96JGo8Ife61Gx z2mv6wfS419ZWKDX2rytj343YkKdzyZDmRZ9FSg1exyjoP0pPGjMjATRNDfkqw4OBdWp IiIA== X-Gm-Message-State: AOAM533Obtd6EwJsu6x05eYv4qPl/9bQ5Of3FytXVwmH/3BP7mdtUuBc GVI8I1xmNKdPVRkfROXrOBFxnm+0bZ2s2Au0Uf97KMNiXOKPPJpTxge62PgB7caKuTH/t1XDr5X xXkMFRTOdTsE= X-Received: by 2002:a05:620a:1133:: with SMTP id p19mr3546200qkk.340.1617805804151; Wed, 07 Apr 2021 07:30:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzemfyJsndiR794toQll/jxXTqquK1TrMQGdy5V/MEjR03W49+XHL7o/gI5hUEjYjU3jO2W+g== X-Received: by 2002:a05:620a:1133:: with SMTP id p19mr3546159qkk.340.1617805803851; Wed, 07 Apr 2021 07:30:03 -0700 (PDT) Received: from xz-x1 (bras-base-toroon474qw-grc-82-174-91-135-175.dsl.bell.ca. [174.91.135.175]) by smtp.gmail.com with ESMTPSA id u12sm18037837qkk.129.2021.04.07.07.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Apr 2021 07:30:03 -0700 (PDT) Date: Wed, 7 Apr 2021 10:30:01 -0400 From: Peter Xu To: Vlastimil Babka Cc: Linus Torvalds , Suren Baghdasaryan , stable , Greg Kroah-Hartman , Jann Horn , Kirill Tkhai , Shaohua Li , Nadav Amit , Linux-MM , Linux Kernel Mailing List , Android Kernel Team , Andrea Arcangeli , David Hildenbrand , Jason Gunthorpe Subject: Re: [PATCH 0/5] 4.14 backports of fixes for "CoW after fork() issue" Message-ID: <20210407143001.GP628002@xz-x1> References: <20210401181741.168763-1-surenb@google.com> MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Queue-Id: 6CA983C2 X-Stat-Signature: r6gnjuduguj17jhpxsprnx6kxid6eqfy X-Rspamd-Server: rspam02 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf04; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617805806-214221 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Apr 07, 2021 at 03:21:55PM +0200, Vlastimil Babka wrote: > 2) For backports go with the original approach of 17839856fd58 ("gup: document > and work around "COW can break either way" issue"), thus break COW during the > GUP. But only for vmplice() so that nothing else gets broken. I think 5.4 stable > (another LTS) actually backported only 17839856fd58 out of everything else, so > it should have even the THP case covered, but its userfaultfd() is now probably > broken... Since you mentioned this approach - AFAIU userfaultfd was only broken because with that approach the kernel pretends some read accesses as writes, while userfaultfd needs that accurate resolution. Adding something like FOLL_BREAK_COW [1] upon 17839856fd58 should keep both the vmsplice issue fixed but also uffd working since that'll keep the read/write operation separate. Meanwhile, I know Andrea was actively working on a complete solution [2] that's a few steps further. E.g., FOLL_BREAK_COW is done with FOLL_UNSHARE [3], speed up in COW path [4] with similar idea of what we do right now with latest upstream in 09854ba94c6aad7, allow write-protect with pinned pages (which is right now forbidden), and something more. However that's definitely a huge branch, even discussing upstream (or maybe stopped discussing for quite some days already?). Neither of above are within upstream, so I don't really know whether these information could be anything useful, just raise it up. If Android could drop userfaultfd, then I think solution 2) above is indeed the most efficient. Note that I think only uffd-wp was affected by 17839856fd58 but not the "missing mode", so if Android is only using missing mode it still looks fine to only have 17839856fd58. It's just that I remembered there's another report besides uffd-wp on 17839856fd58, but I can't remember the details of the other report. Thanks, [1] https://lkml.org/lkml/2020/8/10/439 [2] https://git.kernel.org/pub/scm/linux/kernel/git/andrea/aa.git/log/?h=mapcount_deshare [3] https://git.kernel.org/pub/scm/linux/kernel/git/andrea/aa.git/commit/?h=mapcount_deshare&id=7c3a31caa34ac6ac4a4ec0559b1307b5edfc0821 [4] https://git.kernel.org/pub/scm/linux/kernel/git/andrea/aa.git/commit/?h=mapcount_deshare&id=599aa62474f51a470408b28fd4365320a5357aca -- Peter Xu