Message ID | 20210427161317.50682-15-peterx@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=Z8q0=JY=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 0BB3FC43460 for <linux-mm@archiver.kernel.org>; Tue, 27 Apr 2021 16:13:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A81BD613C2 for <linux-mm@archiver.kernel.org>; Tue, 27 Apr 2021 16:13:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A81BD613C2 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 21D476B0082; Tue, 27 Apr 2021 12:13:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D5EE6B0083; Tue, 27 Apr 2021 12:13:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0284F6B0085; Tue, 27 Apr 2021 12:13:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0135.hostedemail.com [216.40.44.135]) by kanga.kvack.org (Postfix) with ESMTP id C75FC6B0082 for <linux-mm@kvack.org>; Tue, 27 Apr 2021 12:13:48 -0400 (EDT) Received: from smtpin37.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 87074180AD81D for <linux-mm@kvack.org>; Tue, 27 Apr 2021 16:13:48 +0000 (UTC) X-FDA: 78078642936.37.545FEF2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 47638A000192 for <linux-mm@kvack.org>; Tue, 27 Apr 2021 16:13:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619540027; 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=dXTRKapTK7xkWfcmUhC675oNCWp18cl/MiRtGAKeqgk=; b=gIPZmCRMVhHjB22Gl8TA+e3ck4c3ilyBAsp6xJyQdZNn717/K5ooQxOiE1BnohX5Xo6YYo e0Ao0KnMSr8cN5bNj+6EdpgGzV53VGA9oKeK87uz8H9E7oG6xyaHz5ldkPOQUHa5av2BFA inkOO/MURKLXHMB6S/cJjc884Sjm+M8= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-254-bg_uqcc0NRuF5fumR--StA-1; Tue, 27 Apr 2021 12:13:46 -0400 X-MC-Unique: bg_uqcc0NRuF5fumR--StA-1 Received: by mail-qv1-f69.google.com with SMTP id w9-20020a0cdf890000b029019aa511c767so3902672qvl.18 for <linux-mm@kvack.org>; Tue, 27 Apr 2021 09:13:46 -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=dXTRKapTK7xkWfcmUhC675oNCWp18cl/MiRtGAKeqgk=; b=QwNvQ09zCHIPaDpdJbDOaWFAgHE29Y9TEM7m0bNG7AoijNvSebILLWCQUnf+ZukuuO NiicQv+y/IcBm7TC/0LWr7oeuLUYQusOE7UtMQVpyXUVdUEThBuXeEe1NBQl/mkBkvf8 KIKh7KBLx+gGpsDDOP2I6y6TxE0h16RAUtl5F7sFQO1RAnPodZ3FCq8fNYUrFfwBiDxQ 2L/lWwpUsUM5XGwpro6ytxK16Ycv3Kj6DlmYhGs2NYq3+LVKTiZZvA85C3P5d0D826Wd oeYb1iWFlZiPjwbVBseU4yYZsr3Fc4Qp8ja99x4HxjpwT4BPrOOHDxXgLdw6A0upe9tX nBGA== X-Gm-Message-State: AOAM531KKxBrAvKKiNkEfRvradtO2ZI47JZ4Ls68jCyx5u7JPFcuKn1c A86DfIWRSmcRRNZZp7L8bLSg5YsemSvon6jg1jyUIS98JppMsQZvrP/JiXgIiMIKk2SlhRkmMjY 8nDBupHMWSSMNVWFVJ6Zu67rriNg4Xuh2gUZ6FbY2nBa7VkfPKPjeJcwXIzFb X-Received: by 2002:a37:390:: with SMTP id 138mr23732941qkd.136.1619540025078; Tue, 27 Apr 2021 09:13:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyrh8sZh+fxfsRGRfMYWR874+IQftCU711ibVBt1LefYgvzxPopd1PBmk0Q9G1Upc1N/6ITQ== X-Received: by 2002:a37:390:: with SMTP id 138mr23732903qkd.136.1619540024751; Tue, 27 Apr 2021 09:13:44 -0700 (PDT) Received: from xz-x1.redhat.com (bras-base-toroon474qw-grc-77-184-145-104-227.dsl.bell.ca. [184.145.104.227]) by smtp.gmail.com with ESMTPSA id v66sm3103621qkd.113.2021.04.27.09.13.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 09:13:44 -0700 (PDT) From: Peter Xu <peterx@redhat.com> To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Nadav Amit <nadav.amit@gmail.com>, Miaohe Lin <linmiaohe@huawei.com>, Mike Rapoport <rppt@linux.vnet.ibm.com>, Andrea Arcangeli <aarcange@redhat.com>, Hugh Dickins <hughd@google.com>, peterx@redhat.com, Jerome Glisse <jglisse@redhat.com>, Mike Kravetz <mike.kravetz@oracle.com>, Jason Gunthorpe <jgg@ziepe.ca>, Matthew Wilcox <willy@infradead.org>, Andrew Morton <akpm@linux-foundation.org>, Axel Rasmussen <axelrasmussen@google.com>, "Kirill A . Shutemov" <kirill@shutemov.name> Subject: [PATCH v2 14/24] shmem/userfaultfd: Pass over uffd-wp special swap pte when fork() Date: Tue, 27 Apr 2021 12:13:07 -0400 Message-Id: <20210427161317.50682-15-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210427161317.50682-1-peterx@redhat.com> References: <20210427161317.50682-1-peterx@redhat.com> MIME-Version: 1.0 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="US-ASCII" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 47638A000192 X-Stat-Signature: zuucf4djx3gct5di6jae7mftu4duqrw1 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf15; identity=mailfrom; envelope-from="<peterx@redhat.com>"; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619540024-674352 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/memory.c b/mm/memory.c index 872fb59192277..f1cdc613b5887 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -715,8 +715,21 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, unsigned long vm_flags = dst_vma->vm_flags; pte_t pte = *src_pte; struct page *page; - swp_entry_t entry = pte_to_swp_entry(pte); + swp_entry_t entry; + + if (unlikely(is_swap_special_pte(pte))) { + /* + * uffd-wp special swap pte is the only possibility for now. + * If dst vma is registered with uffd-wp, copy it over. + * Otherwise, ignore this pte as if it's a none pte would work. + */ + WARN_ON_ONCE(!pte_swp_uffd_wp_special(pte)); + if (userfaultfd_wp(dst_vma)) + set_pte_at(dst_mm, addr, dst_pte, pte); + return 0; + } + entry = pte_to_swp_entry(pte); if (likely(!non_swap_entry(entry))) { if (swap_duplicate(entry) < 0) return entry.val;
It should be handled similarly like other uffd-wp wr-protected ptes: we should pass it over when the dst_vma has VM_UFFD_WP armed, otherwise drop it. Signed-off-by: Peter Xu <peterx@redhat.com> --- mm/memory.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)