Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp382088pxf; Wed, 31 Mar 2021 05:58:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDGRKN21UMSyAIF9BhrQmg9x495m2LE54J6pNid3pKVJFLjKuXZsArYLcNNIvWMx1zVjxp X-Received: by 2002:a17:906:4e99:: with SMTP id v25mr3361221eju.532.1617195525369; Wed, 31 Mar 2021 05:58:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617195525; cv=none; d=google.com; s=arc-20160816; b=FxtpaLZA0LRf8XWJnpkBg/OVrsgRBRg5WKaZr3vTWZIj09NrtL3E0Jzxofq6kyEPN+ qxSKeB0kjoK/1cQoGpOVIC5JdC4dnTCDvSgEf0gjghrLyceiFbl0zgSRhkjsRHwaMNVE I+idtrOsafwe/k7ceZzFojxqtKF6Mn9he2+RxW2QtDZ2SppjVgD46mECupkkx5NNrQdY 61jJeXm+n3K8nU1Xlv24QY0J6VajgR7v2+7D0+7aYTIj9SWYlDkOqI6RArdHs6h88Of2 uYHSEtZo2hLduI+4XZrf2p8p4cguWFEbEOjwGwh9TdtJ+Rp2ZjakUaCcZ3rBeS1PeMI5 kFpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BLVqguYYRqWS+fkpiZrnYWlDg4Em6ZwexNgxX0lsnu4=; b=x33PiLq1GfeOwgGa5PiVH5twsqrli7LlBldhso7PjWuCV0W3h2Dxozg3ANfgVqyl3q TM3DSeLMxJHAEuVNAB9GMVF3pJ8s0fz2IujGIMoGPPsdvr1DRr9lacmqcS6wkIxojSj0 uP+8puaJnK+oEBI3BexgWJPPC1cW7TSMiFJDPJTxlmxNDt4UI5R70ojmxIOvTBhXFHF6 M47yA07QyCnZ/j8Rcp58tKcnJrg/RJMc29MW0QYSXLheGgRJJGZWa4bN9L2WJInmJ1g3 ewxpQm8U3YT0a6yZJw5QsZN51cgYc2lKNC9K9V+/bi2WN/hPRXRnWOhSREvImheuQF1/ SKFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H8RavXFV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do3si1609456ejc.486.2021.03.31.05.58.22; Wed, 31 Mar 2021 05:58:45 -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=@redhat.com header.s=mimecast20190719 header.b=H8RavXFV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235685AbhCaMyr (ORCPT + 99 others); Wed, 31 Mar 2021 08:54:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56491 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235666AbhCaMyR (ORCPT ); Wed, 31 Mar 2021 08:54:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617195257; 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=BLVqguYYRqWS+fkpiZrnYWlDg4Em6ZwexNgxX0lsnu4=; b=H8RavXFVBwHwcMCLYL+w7w5HA8GwqCDwN0UWs8+titAW1NYzoE8V8+P3ndQRHGgPvJxviJ eyuw3IgvxPULNWW9++nk8q0Eb4KM2LKwYJuTbw4yVZy4njiulPUkL7JejYzbulGn5II+iQ XKBuDL+dnurIQw5/HEX3kusHddJYqh0= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-572-GMw99CW5OJ6r9YIgsygUdQ-1; Wed, 31 Mar 2021 08:54:14 -0400 X-MC-Unique: GMw99CW5OJ6r9YIgsygUdQ-1 Received: by mail-qt1-f198.google.com with SMTP id g7so1090932qtb.5 for ; Wed, 31 Mar 2021 05:54:14 -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=BLVqguYYRqWS+fkpiZrnYWlDg4Em6ZwexNgxX0lsnu4=; b=NJaEnK45b7yppEjCNt0Y0lb8lpHLs16ADqyqKB/UoOoo2wgLI/w+8fRJaTyWUOo7am +3VXglt+7nCZaZDJGQZvLC5/mAD4z80598mdrg5+F4B2P+LxoAL0qCK9OeSHlNJfYVNt ptId3SLJHFQdsRU294rornQTozYqnkXdRSEmD/pYAMcPy8EPFhoEJhWZjI3HBsXiXBbG vmTu82iwJw1q1SvWTVbfCSF3lWdG0XH6xFkCUBKuqIzU3eUOivZXT1tLTJeXUq9vUEnH kSRhuJrgFik8BJuqq77q5Z5OpxP1DKbbA4sHURVJsWuISr3vXfVmxqc2tUd/JIy7jGER hNKA== X-Gm-Message-State: AOAM5337IKqiVB/UIF0yh6Ak0AOSAp4Eipc/+9PyYUxUr2btPhUXKBkn fk80q57fGUQhlg1oX0pQVxJvUMLHrMnlDsIW4kFfQ/6epQR9EQJxQrrnyJ1x+2QFzm6mOb1nyhU vt5h8Kidkp+7vRgpkBZPjsDC2 X-Received: by 2002:a05:622a:48d:: with SMTP id p13mr2279126qtx.21.1617195253824; Wed, 31 Mar 2021 05:54:13 -0700 (PDT) X-Received: by 2002:a05:622a:48d:: with SMTP id p13mr2279090qtx.21.1617195253556; Wed, 31 Mar 2021 05:54:13 -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 a19sm1330189qkl.126.2021.03.31.05.54.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 05:54:12 -0700 (PDT) Date: Wed, 31 Mar 2021 08:54:09 -0400 From: Peter Xu To: Axel Rasmussen Cc: Alexander Viro , Andrea Arcangeli , Andrew Morton , Hugh Dickins , Jerome Glisse , Joe Perches , Lokesh Gidra , Mike Rapoport , Shaohua Li , Shuah Khan , Stephen Rothwell , Wang Qing , LKML , linux-fsdevel@vger.kernel.org, Linux MM , linux-kselftest@vger.kernel.org, Brian Geffon , Cannon Matthews , "Dr . David Alan Gilbert" , David Rientjes , Michel Lespinasse , Mina Almasry , Oliver Upton Subject: Re: [PATCH v3] userfaultfd/shmem: fix MCOPY_ATOMIC_CONTNUE behavior Message-ID: <20210331125409.GL429942@xz-x1> References: <20210329234131.304999-1-axelrasmussen@google.com> <20210330205519.GK429942@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Axel, On Tue, Mar 30, 2021 at 04:30:13PM -0700, Axel Rasmussen wrote: > Yes, a refactor like that is promising. It's hard to say for certain > without actually looking at the result - I'll spend some time tomorrow > on a few options, and send along the cleanest version I come up with. Before you move onto a new version... See this commit: 5b51072e97d5 ("userfaultfd: shmem: allocate anonymous memory for MAP_PRIVATE shmem", 2018-11-30) I found it when I was thinking why not move the whole continue logic directly into mfill_atomic_pte(), if we can have the pte installation helper, because that's all we need. So previously I got the semantics a bit mixed up: for private shmem mappings, UFFDIO_COPY won't fill in page cache at all, but it's all private. We keep the page cache empty even after UFFDIO_COPY for a private mapping. UFFDIO_CONTINUE is slightly different, since we _know_ the page cache is there.. So I'm thinking maybe you need to handle the continue request in mfill_atomic_pte() before the VM_SHARED check so as to cover both cases. -- Peter Xu