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=-8.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 D3881C433EF for ; Fri, 3 Sep 2021 20:03:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4B98F61058 for ; Fri, 3 Sep 2021 20:03:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4B98F61058 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id BA866900002; Fri, 3 Sep 2021 16:03:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B54E96B0072; Fri, 3 Sep 2021 16:03:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1CFA900002; Fri, 3 Sep 2021 16:03:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0203.hostedemail.com [216.40.44.203]) by kanga.kvack.org (Postfix) with ESMTP id 8F1D76B0071 for ; Fri, 3 Sep 2021 16:03:08 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4DE0532601 for ; Fri, 3 Sep 2021 20:03:08 +0000 (UTC) X-FDA: 78547336056.09.D4921BA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf14.hostedemail.com (Postfix) with ESMTP id EFA7C6001986 for ; Fri, 3 Sep 2021 20:03:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630699387; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VKgG5Q4GJoZylhkC+igd3ORO7G/PVfFNNgAWNVRKHjA=; b=Hbb2oEHS5BuSgEFRzowxb0zvLF2xqOPBwwFd62PpYz+yd7WcIztXnZw7MCLsE8/UWFRoSJ q3O/LrXGg7/zCRGpnFC8+e5LDnKWzsQKczuEOK6R2TXnBBPcULv5m7M/ugBMQXfRpWJV5+ BaMoe+fwRL6BSruIrRf7rYTwTZ93Ioo= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-497-27VW71kgOeCAb9eBe12SPQ-1; Fri, 03 Sep 2021 16:03:04 -0400 X-MC-Unique: 27VW71kgOeCAb9eBe12SPQ-1 Received: by mail-wm1-f72.google.com with SMTP id c4-20020a1c9a04000000b002e864b7edd1so7635wme.6 for ; Fri, 03 Sep 2021 13:03:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=VKgG5Q4GJoZylhkC+igd3ORO7G/PVfFNNgAWNVRKHjA=; b=ro2/HfvpVcS8pqklCiISfHjaTrNAStMhJRZsx5KSmv9XYRhj6Zex5/9URM1K/qi8zQ binEgAL8FeuF+7jUto5iiKugCQQVQ1hMdiEy9DMFe+fB9hAu2Kk672l6/gRQLv7SJr3r /yGoMEzUt3B004pLT2sYGIz3BD+sAXW83luar9xleAs8GEhxhCp9r/MDhawBlmlfR4B/ a0DEZ4HY2/uK2rvT/WkkoUMprZ9txoKN12Ylx9wUC16UOwMWgKUHht5wj1vJtS7HyU8j +Z0SVBthxbaB8zYLntDHjblIKxSDX1SyHietp+qrUtFBPO/uaK6wvbzHtAgBqa5CPlWe r49g== X-Gm-Message-State: AOAM531tnWj7n27jPTW/GlpV1yhuILmLWWFtPNJL4C3SlY8JXYQg3C7N Z7diBSmiIuQ2rBt7yCpRXrMn7hn38YjjpvpD3zk/1KnLb3/467DDa5h2vMsDDfEopGTbiGLngAW gKyFCxGAFTLo= X-Received: by 2002:a7b:c5c7:: with SMTP id n7mr384506wmk.5.1630699382958; Fri, 03 Sep 2021 13:03:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQhSfAMAF02/q6C2QxnKU2WGgOJyKv6ePPQ4NAfk0+wU4lJfiNPUufyOzUU+d+fOt0TKO1cw== X-Received: by 2002:a7b:c5c7:: with SMTP id n7mr384477wmk.5.1630699382743; Fri, 03 Sep 2021 13:03:02 -0700 (PDT) Received: from [192.168.3.132] (p4ff23e05.dip0.t-ipconnect.de. [79.242.62.5]) by smtp.gmail.com with ESMTPSA id b1sm188902wrh.85.2021.09.03.13.02.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Sep 2021 13:03:00 -0700 (PDT) Subject: Re: [PATCH v2 1/5] mm/shmem: Unconditionally set pte dirty in mfill_atomic_install_pte To: Peter Xu Cc: linux-kernel@vger.kernel.org, Andrew Morton , Hugh Dickins , linux-mm@kvack.org, Andrea Arcangeli , Yang Shi , Matthew Wilcox , Jerome Glisse , Mike Rapoport , "Kirill A . Shutemov" , Miaohe Lin , Alistair Popple , Axel Rasmussen References: <20210902201721.52796-1-peterx@redhat.com> <20210902201721.52796-2-peterx@redhat.com> <2f1bfe82-9bb7-957c-2b32-2ccf8a48e70a@redhat.com> From: David Hildenbrand Organization: Red Hat Message-ID: <05d64fe1-77f6-aa2a-6b79-e08f6b997ed9@redhat.com> Date: Fri, 3 Sep 2021 22:02:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hbb2oEHS; spf=none (imf14.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: EFA7C6001986 X-Stat-Signature: q9e7ejtbaj5akmxfgyehtfg9nasiginw X-HE-Tag: 1630699387-248776 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 03.09.21 22:00, Peter Xu wrote: > On Fri, Sep 03, 2021 at 09:42:34AM +0200, David Hildenbrand wrote: >> On 02.09.21 22:17, Peter Xu wrote: >>> It was conditionally done previously, as there's one shmem special case that we >>> use SetPageDirty() instead. However that's not necessary and it should be >>> easier and cleaner to do it unconditionally in mfill_atomic_install_pte(). >>> >>> The most recent discussion about this is here, where Hugh explained the history >>> of SetPageDirty() and why it's possible that it's not required at all: >>> >>> https://lore.kernel.org/lkml/alpine.LSU.2.11.2104121657050.1097@eggly.anvils/ >>> >>> Currently mfill_atomic_install_pte() has three callers: >>> >>> 1. shmem_mfill_atomic_pte >>> 2. mcopy_atomic_pte >>> 3. mcontinue_atomic_pte >>> >>> After the change: case (1) should have its SetPageDirty replaced by the dirty >>> bit on pte (so we unify them together, finally), case (2) should have no >>> functional change at all as it has page_in_cache==false, case (3) may add a >>> dirty bit to the pte. However since case (3) is UFFDIO_CONTINUE for shmem, >>> it's merely 100% sure the page is dirty after all, so should not make a real >>> difference either. >> >> Would it be worth adding VM_BUG_ON() to make sure that "100%" is really the >> case? > > I won't be able to make it 100% sure (and that's where I put it "merely"). The > example discussed between Axel and me in the other thread could be an outlier > (when two processes, uffd target, and uffd minor resolver, map the region as > RO), it's just that neither do I think that's a great matter, nor do I think it > would be worth a BUG_ON(), not to mention we use BUG_ON so carefully. Agreed then, if we really expect there are corner cases and that the corner cases are fine! (VM_BUG_ON() could have helped to catch these while testing) -- Thanks, David / dhildenb