Message ID | 20210714222117.47648-2-peterx@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <SRS0=SYtF=MG=kvack.org=owner-linux-mm@kernel.org> 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 1B2E9C12002 for <linux-mm@archiver.kernel.org>; Wed, 14 Jul 2021 22:21:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C0FA6613C9 for <linux-mm@archiver.kernel.org>; Wed, 14 Jul 2021 22:21:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C0FA6613C9 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 0556B6B00A6; Wed, 14 Jul 2021 18:21:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 02C406B00A7; Wed, 14 Jul 2021 18:21:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE8756B00A8; Wed, 14 Jul 2021 18:21:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id BCFE76B00A6 for <linux-mm@kvack.org>; Wed, 14 Jul 2021 18:21:26 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A36691809FEEC for <linux-mm@kvack.org>; Wed, 14 Jul 2021 22:21:25 +0000 (UTC) X-FDA: 78362615730.14.935D60E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 3A76F900024F for <linux-mm@kvack.org>; Wed, 14 Jul 2021 22:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626301284; 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=2wghNqx4JftAFaj2ufqftGGQbCHL8Jx+CkAGBQbGsx4=; b=LSy3Mqf4wQXdQKpxieB+L9ySEPf402M1SzR1hd1k2rhRBRxe7Y55AhIs90rvrcSxGsdiVb +69io/S1mcn1sKs2nniA7Nw8BCrnBdFj7rZPVe5QUwVtEsMW69N+5yKfjQGS4SiV27baeO 2HJ4v5g1/h586F54XKINIYfoqWAu41U= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-425-r9w-lJaiN4irvtC87ygNGg-1; Wed, 14 Jul 2021 18:21:23 -0400 X-MC-Unique: r9w-lJaiN4irvtC87ygNGg-1 Received: by mail-qt1-f199.google.com with SMTP id w3-20020ac80ec30000b029024e8c2383c1so2833929qti.5 for <linux-mm@kvack.org>; Wed, 14 Jul 2021 15:21:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2wghNqx4JftAFaj2ufqftGGQbCHL8Jx+CkAGBQbGsx4=; b=aH2r4ZKiFQ6wUSoigqCTmMtN7kruzPFPz6Uyguty6/vpn5Dw8vbhVSbFhuoqhE4j0Y GN0Q4ammLu+lh1kR54jzC7Sdc2phhXxtU1e0ei/4TNYv5cZ5Tu3OcUdD2uT3uswWxVF8 JVvrEHz8W+sCiyTR3CMHikQnJ9gmA4G7SGPdFQYq5u4VO9GKiaZrGnOUczPZ37UfO7cB l2WbllG3mi9bHGUnTQ18u2EtsYRhmWfQB5gncWPOtgkmUgpQyAmsGJK4mZJLyMTLULlG PaNvMDYM10aYcddrPAZDQc+jORv9KLRJ+TOey407IURbCEdPnU5i4ekhUAcg/QkWpB7s 6EHQ== X-Gm-Message-State: AOAM533DNSFT7aM3OsR8koxGIQgOIOtEcb+VJTO63NPinEIMfFP2UUnz u0zTMaCnsToICQA0DSgkLB5eTED5cYxOfGiBtfqUi4QRNRktksmZLyQ60gVYN+91l0Kl+dJ/Kfh +rV+I+tJCBTQ= X-Received: by 2002:a05:620a:16b7:: with SMTP id s23mr187832qkj.495.1626301282799; Wed, 14 Jul 2021 15:21:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHBJUlax/lXVspNfFXeao9SZKZfEe/LZ0w2Bg7nDn4nRH7cKQmqRx3VxQaS8Lv2fCmBULSGw== X-Received: by 2002:a05:620a:16b7:: with SMTP id s23mr187816qkj.495.1626301282594; Wed, 14 Jul 2021 15:21:22 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-65-184-144-111-238.dsl.bell.ca. [184.144.111.238]) by smtp.gmail.com with ESMTPSA id b25sm1625854qka.123.2021.07.14.15.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 15:21:22 -0700 (PDT) From: Peter Xu <peterx@redhat.com> To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe <jgg@ziepe.ca>, peterx@redhat.com, Matthew Wilcox <willy@infradead.org>, Andrew Morton <akpm@linux-foundation.org>, Axel Rasmussen <axelrasmussen@google.com>, Nadav Amit <nadav.amit@gmail.com>, Jerome Glisse <jglisse@redhat.com>, Mike Rapoport <rppt@linux.vnet.ibm.com>, Miaohe Lin <linmiaohe@huawei.com>, Hugh Dickins <hughd@google.com>, Alistair Popple <apopple@nvidia.com>, Andrea Arcangeli <aarcange@redhat.com>, Mike Kravetz <mike.kravetz@oracle.com>, "Kirill A . Shutemov" <kirill@shutemov.name>, David Hildenbrand <david@redhat.com> Subject: [PATCH v4 01/26] mm/shmem: Unconditionally set pte dirty in mfill_atomic_install_pte Date: Wed, 14 Jul 2021 18:20:52 -0400 Message-Id: <20210714222117.47648-2-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210714222117.47648-1-peterx@redhat.com> References: <20210714222117.47648-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="US-ASCII" Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LSy3Mqf4; spf=none (imf29.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: s77b15gzx76omdwtbe5bdbfbw13sg8cu X-Rspamd-Queue-Id: 3A76F900024F X-Rspamd-Server: rspam01 X-HE-Tag: 1626301285-520925 Content-Transfer-Encoding: quoted-printable 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: <linux-mm.kvack.org> |
Series |
userfaultfd-wp: Support shmem and hugetlbfs
|
expand
|
diff --git a/mm/shmem.c b/mm/shmem.c index 70d9ce294bb4..dc9f95b5fb34 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2449,7 +2449,6 @@ int shmem_mfill_atomic_pte(struct mm_struct *dst_mm, shmem_recalc_inode(inode); spin_unlock_irq(&info->lock); - SetPageDirty(page); unlock_page(page); return 0; out_delete_from_cache: diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 0e2132834bc7..b30a3724c701 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -69,10 +69,9 @@ int mfill_atomic_install_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, pgoff_t offset, max_off; _dst_pte = mk_pte(page, dst_vma->vm_page_prot); + _dst_pte = pte_mkdirty(_dst_pte); if (page_in_cache && !vm_shared) writable = false; - if (writable || !page_in_cache) - _dst_pte = pte_mkdirty(_dst_pte); if (writable) { if (wp_copy) _dst_pte = pte_mkuffd_wp(_dst_pte);
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. This should make it much easier to follow on which case will set dirty for uffd, as we'll simply set it all now for all uffd related ioctls. Meanwhile, no special handling of SetPageDirty() if there's no need. Cc: Hugh Dickins <hughd@google.com> Cc: Axel Rasmussen <axelrasmussen@google.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> --- mm/shmem.c | 1 - mm/userfaultfd.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-)