Message ID | 20210715201610.211610-1-peterx@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <SRS0=osCV=MH=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 315D9C636C9 for <linux-mm@archiver.kernel.org>; Thu, 15 Jul 2021 20:16:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CD7D1613C9 for <linux-mm@archiver.kernel.org>; Thu, 15 Jul 2021 20:16:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD7D1613C9 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 3C1FD8D0100; Thu, 15 Jul 2021 16:16:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3989F8D00EC; Thu, 15 Jul 2021 16:16:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 239D38D0100; Thu, 15 Jul 2021 16:16:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0178.hostedemail.com [216.40.44.178]) by kanga.kvack.org (Postfix) with ESMTP id 02D428D00EC for <linux-mm@kvack.org>; Thu, 15 Jul 2021 16:16:18 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E0654824805A for <linux-mm@kvack.org>; Thu, 15 Jul 2021 20:16:17 +0000 (UTC) X-FDA: 78365929194.28.9A189DB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 98FA61007FAC for <linux-mm@kvack.org>; Thu, 15 Jul 2021 20:16:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626380177; 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=l/r2tEksA7iAG8svGDApMzfpTe7AXzjcSqF0fovWgO0=; b=KTtZXkQMEBVrHiDWgW1xEzsCjp1tQOmJ0kMQ1Kgxx0xxdlEJzMv7AzlBV5b03t0NRCUVKP aVGx2XpCi/hAkOmXsbgUB7iE2i5cvzfP1TgBy8zh69iwWJElMIdnr2ZdEMJw520T4obFNP K6/f4ck2ahqbMaxBaRPiEEl/MiJ9ps8= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-478-hKW7BoG1MZybHrtffiBOtg-1; Thu, 15 Jul 2021 16:16:14 -0400 X-MC-Unique: hKW7BoG1MZybHrtffiBOtg-1 Received: by mail-qk1-f199.google.com with SMTP id n77-20020a3740500000b02903b496f6f425so4702290qka.1 for <linux-mm@kvack.org>; Thu, 15 Jul 2021 13:16: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:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l/r2tEksA7iAG8svGDApMzfpTe7AXzjcSqF0fovWgO0=; b=lMGKssIpNsIW7KZ/WEsAdMdhHXrE5R03RqgOH+q723VVEvDDjsXGxuAEgZ+FnvT6qk kG0LNAjjEuokuQU1kC3t+z4mGRgVmsnU1a4J/HPSdnbtGeJfayxgEpvSR/uymha4/3cM t7UBfri8v9m/AWcaac7RBWW/yGT6vvxL8QbIAW7bhZkixvZsXm0yDofZvMwZl2sS3fs6 HxV1r+HxNasDJJFYNWqg4zWU7HHPJ1Tr1sQ8YsWgZ0lEGU/JVcSAU79fZ5ZAi6A4sEBu V2B9PifleetTpxYaI1Hq0jZIygT5dQonTpXZaF2/jPDAJ0JMGplu98Sq4opiXBcu7zr6 yJsQ== X-Gm-Message-State: AOAM530e2d2nN+1QXcjRhcItLF0i4Z4JPtdOTOhPdBVRWFCnmDwtV+++ NAPEdjF3n+02eVm6l4/Wt+nHwu892rPtp1PqnqM2/YZ2rd2ocOn2zyldZ3urEBVVBhVgmYTqT+V jzQ7KIJ4xN7I= X-Received: by 2002:a05:620a:f03:: with SMTP id v3mr5952775qkl.96.1626380173829; Thu, 15 Jul 2021 13:16:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAlTDTDWRdLJ3h6dBRK5Qwm2taDlF4dP+ne0nAsiUi62UZRnXM9yTbENjgnGhNk1frpAneVw== X-Received: by 2002:a05:620a:f03:: with SMTP id v3mr5952756qkl.96.1626380173626; Thu, 15 Jul 2021 13:16:13 -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 l5sm2958062qkb.62.2021.07.15.13.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 13:16:13 -0700 (PDT) From: Peter Xu <peterx@redhat.com> To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Axel Rasmussen <axelrasmussen@google.com>, Nadav Amit <nadav.amit@gmail.com>, Jerome Glisse <jglisse@redhat.com>, "Kirill A . Shutemov" <kirill@shutemov.name>, Jason Gunthorpe <jgg@ziepe.ca>, Alistair Popple <apopple@nvidia.com>, Andrew Morton <akpm@linux-foundation.org>, David Hildenbrand <david@redhat.com>, peterx@redhat.com, Andrea Arcangeli <aarcange@redhat.com>, Matthew Wilcox <willy@infradead.org>, Mike Kravetz <mike.kravetz@oracle.com>, Tiberiu Georgescu <tiberiu.georgescu@nutanix.com>, Hugh Dickins <hughd@google.com>, Miaohe Lin <linmiaohe@huawei.com>, Mike Rapoport <rppt@linux.vnet.ibm.com> Subject: [PATCH v5 14/26] shmem/userfaultfd: Pass over uffd-wp special swap pte when fork() Date: Thu, 15 Jul 2021 16:16:10 -0400 Message-Id: <20210715201610.211610-1-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715201422.211004-1-peterx@redhat.com> References: <20210715201422.211004-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" X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 98FA61007FAC X-Stat-Signature: f7kd8z5bjwrayqumnx7omu81g1o49jnj Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KTtZXkQM; spf=none (imf13.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1626380177-937040 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 223781f115e9..af91bee934c7 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -776,8 +776,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 -EIO;
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(-)