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=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 2C888C31E40 for ; Tue, 15 Sep 2020 18:29:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A8695206B7 for ; Tue, 15 Sep 2020 18:29:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="a5D8w8T9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A8695206B7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2B28E90007B; Tue, 15 Sep 2020 14:29:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28920900079; Tue, 15 Sep 2020 14:29:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19FB190007B; Tue, 15 Sep 2020 14:29:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id 05067900079 for ; Tue, 15 Sep 2020 14:29:40 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8DD11362B for ; Tue, 15 Sep 2020 18:29:39 +0000 (UTC) X-FDA: 77266134078.11.self89_54119cd27113 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 737A1180F8B86 for ; Tue, 15 Sep 2020 18:29:38 +0000 (UTC) X-HE-Tag: self89_54119cd27113 X-Filterd-Recvd-Size: 5366 Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Sep 2020 18:29:36 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id d190so5225119iof.3 for ; Tue, 15 Sep 2020 11:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=QH0oevRAXAfKjkr8xwGWq7ufd7Zmd6cGXZiCflHDesA=; b=a5D8w8T9XU1Z5Sg3El875tpdfLEgvabG4sAGeB37Wr1WfMICFJ1rqI8EuyKuvKFyqh ctfGnliM0miH9CluA8q6wGyqcv8uoRUwKJv4avYtqpZD4YJzJvlGvHh7shIPeYLjqfgE YWl+Ati9kVlc7YjQcKkn5lzOIe8Uj0vt1ho1m5QvYhc2Zg+nCk6WumnncLPwfApQaP1F yG2TXV8o1w0tAlJFQs0tVe0boOSeXBXHzCsx258y4QSFvQAYGV8CAz/85XFxMjNvjqXu Xw8I17Y/orn+PMg2qFeslypqX86SNsS23BXpBGNhN7R1tKvT2A/i8kTfmSrXRM2T9Nyb U5og== 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=QH0oevRAXAfKjkr8xwGWq7ufd7Zmd6cGXZiCflHDesA=; b=Ze1gbkQeu9GWDrB5Y8cc2031mKH6NlnhZPKT2IWletrOdoL/hF7Jt7UToQnVPKd7px r+OZPQoomrN2oYVFMBIybNd3ClCzTwTS6aW5PTZ8OGligartVJ+gYVh2Ri10DJ5252KT B0rkilT87o+6MlYol6ZbcJk22JTgEcCMxiwOzC8fATL/rw3zkeCLHNkaGQOgRdbRCXCA GIWoPTxQbt0PgYwU3WGoFJ8i3SnT5A3gJxZwPwHJYfsgF/eGQEXSb/wZUuw8iW14nmOn IXfiT5vdlOSH8ecrQvXQOlAMeaCHsFQ2CtNreFNdvyrLaXlhkXR42wbRmrE09F5d7sLF ZK1g== X-Gm-Message-State: AOAM530JK6dh0Ng5nvCgRqoDZCSRV+OWmwsh+A01Q9aM0aSllZcJj4A+ GQbBrq4xuX/lb5uEyXIllrCmWA== X-Google-Smtp-Source: ABdhPJwmx/LUpglx7XpAipNeMR+kHJPe2QCViaCkWocmK98vW3k5whvbv4Z0KH1re3/hxdhjxsU/yw== X-Received: by 2002:a05:6638:24c1:: with SMTP id y1mr18589650jat.119.1600194575776; Tue, 15 Sep 2020 11:29:35 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id p17sm9234963ilj.81.2020.09.15.11.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 11:29:34 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kIFht-006eMK-OT; Tue, 15 Sep 2020 15:29:33 -0300 Date: Tue, 15 Sep 2020 15:29:33 -0300 From: Jason Gunthorpe To: Peter Xu Cc: Linus Torvalds , Leon Romanovsky , Linux-MM , Linux Kernel Mailing List , "Maya B . Gokhale" , Yang Shi , Marty Mcfadden , Kirill Shutemov , Oleg Nesterov , Jann Horn , Jan Kara , Kirill Tkhai , Andrea Arcangeli , Christoph Hellwig , Andrew Morton Subject: Re: [PATCH 1/4] mm: Trial do_wp_page() simplification Message-ID: <20200915182933.GM1221970@ziepe.ca> References: <20200821234958.7896-2-peterx@redhat.com> <20200914143829.GA1424636@nvidia.com> <20200914183436.GD30881@xz-x1> <20200914211515.GA5901@xz-x1> <20200914225542.GO904879@nvidia.com> <20200914232851.GH1221970@ziepe.ca> <20200915145040.GA2949@xz-x1> <20200915160553.GJ1221970@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200915160553.GJ1221970@ziepe.ca> X-Rspamd-Queue-Id: 737A1180F8B86 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 Tue, Sep 15, 2020 at 01:05:53PM -0300, Jason Gunthorpe wrote: > On Tue, Sep 15, 2020 at 10:50:40AM -0400, Peter Xu wrote: > > On Mon, Sep 14, 2020 at 08:28:51PM -0300, Jason Gunthorpe wrote: > > > Yes, this stuff does pin_user_pages_fast() and MADV_DONTFORK > > > together. It sets FOLL_FORCE and FOLL_WRITE to get an exclusive copy > > > of the page and MADV_DONTFORK was needed to ensure that a future fork > > > doesn't establish a COW that would break the DMA by moving the > > > physical page over to the fork. DMA should stay with the process that > > > called pin_user_pages_fast() (Is MADV_DONTFORK still needed with > > > recent years work to GUP/etc? It is a pretty terrible ancient thing) > > > > ... Now I'm more confused on what has happened. > > I'm going to try to confirm that the MADV_DONTFORK is actually being > done by userspace properly, more later. It turns out the test is broken and does not call MADV_DONTFORK when doing forks - it is an opt-in it didn't do. It looks to me like this patch makes it much more likely that the COW break after page pinning will end up moving the pinned physical page to the fork while before it was not very common. Does that make sense? Given that the tests are wrong it seems like broken userspace, however, it also worked reliably for a fairly long time. I'm waiting for confirmation that adding the missing MADV_DONTFORKS restores all tests to success even with this patch. Regards, Jason