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=-11.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 E830BC48BCF for ; Wed, 9 Jun 2021 14:43:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9B88F60C41 for ; Wed, 9 Jun 2021 14:43:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B88F60C41 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 1EA326B0070; Wed, 9 Jun 2021 10:43:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C1416B0071; Wed, 9 Jun 2021 10:43:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 061E56B0072; Wed, 9 Jun 2021 10:43:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0059.hostedemail.com [216.40.44.59]) by kanga.kvack.org (Postfix) with ESMTP id C6AC26B0070 for ; Wed, 9 Jun 2021 10:43:47 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 665D2181AEF31 for ; Wed, 9 Jun 2021 14:43:47 +0000 (UTC) X-FDA: 78234454494.20.D08C1E4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 952A9C00F793 for ; Wed, 9 Jun 2021 14:43:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623249826; 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=hrjd0vAHqmk1gDJJdLOYF6cPc1MLvKQtTt47CRg14Ds=; b=QYZOlpYnVm3xcRMeq/hG3WyRKL8rLiC+ZVHBn9z9rYgNPohnx2ZeiDQ2yvJbAJA99LJuwW TKJuPtal65MrZnf6U+cqVEEwwdboOjXC7SlNMBpzq7HCqyBhjUeerm+QWM27ZPUisWkwFt llajFYW4dvktyVK9ZpcYlPV7ohnjVCU= 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-106-hUsGTasFM3ix23zBoYj5Kg-1; Wed, 09 Jun 2021 10:43:40 -0400 X-MC-Unique: hUsGTasFM3ix23zBoYj5Kg-1 Received: by mail-qk1-f199.google.com with SMTP id s4-20020a3790040000b02902fa7aa987e8so17228085qkd.14 for ; Wed, 09 Jun 2021 07:43:40 -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=hrjd0vAHqmk1gDJJdLOYF6cPc1MLvKQtTt47CRg14Ds=; b=JLlz0tWqCgni8DsCO2fv7tmSPWHuD5KdeBmyGGPzDTi5qfmop56Zphl69yjQ0yyk8f 1K4wK/nqzU2yhf5KXF6vUmie0nC1zP8ycONjPPkSf/xEwa45dfcyNFwRJfyl61RzwaLn RYqKUhab+m7bFGoibYcEfeiGm5zQ8InorCsEVMpaRdHP405vesEgvIzou54PEOaSPvPM TgJ0rqGKsjPB5ER22vsKreOcCv7lYf+jy1j11wH9Bct0PJPXQ+6PhwfaZps9ra7Vs/J0 Uot84z/PIryyUn75RatHUJdMAVc99lQ1N1FX4etQ8USwwxz9wYPgvP9xvp9hpvVucrxT klhw== X-Gm-Message-State: AOAM531SboVA0ZK9OVnti2wZG/Z/J0XfpF/Q3qSMaKmoarr7MNZpL2eq yN08fB/ukYPx12UUGcB0XEdyl1TUuvhc6CaZqM3o2WYNqeGIuDqxIXXddP/t3E67Bk4GZ8fqoei msMDZen54Zf0= X-Received: by 2002:a05:620a:1272:: with SMTP id b18mr15787593qkl.82.1623249819669; Wed, 09 Jun 2021 07:43:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvfpN1NcM9Fj56PO+RMrhMow2+zD6jj3I+p6YzQj0glPLbzqgroksliu2gRQR8EH4SKk/e4g== X-Received: by 2002:a05:620a:1272:: with SMTP id b18mr15787570qkl.82.1623249819431; Wed, 09 Jun 2021 07:43:39 -0700 (PDT) Received: from t490s (bras-base-toroon474qw-grc-88-174-93-75-200.dsl.bell.ca. [174.93.75.200]) by smtp.gmail.com with ESMTPSA id b123sm184851qke.87.2021.06.09.07.43.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 07:43:38 -0700 (PDT) Date: Wed, 9 Jun 2021 10:43:37 -0400 From: Peter Xu To: Alistair Popple Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Axel Rasmussen , "Kirill A . Shutemov" , Hugh Dickins , Andrew Morton , Miaohe Lin , Mike Rapoport , Jerome Glisse , Andrea Arcangeli , Nadav Amit , Mike Kravetz , Jason Gunthorpe , Matthew Wilcox Subject: Re: [PATCH v3 04/27] mm/userfaultfd: Introduce special pte for unmapped file-backed mem Message-ID: References: <20210527201927.29586-1-peterx@redhat.com> <20210527201927.29586-5-peterx@redhat.com> <2227669.OCfziWJ48r@nvdebian> MIME-Version: 1.0 In-Reply-To: <2227669.OCfziWJ48r@nvdebian> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QYZOlpYn; spf=none (imf03.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-Stat-Signature: d6b7dnq6x1htw1otmup1953y4jcam4hu X-Rspamd-Queue-Id: 952A9C00F793 X-Rspamd-Server: rspam06 X-HE-Tag: 1623249822-466010 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 Wed, Jun 09, 2021 at 11:06:32PM +1000, Alistair Popple wrote: > On Friday, 28 May 2021 6:19:04 AM AEST Peter Xu wrote: > > [...] > > > diff --git a/include/asm-generic/pgtable_uffd.h b/include/asm-generic/pgtable_uffd.h > > index 828966d4c281..95e9811ce9d1 100644 > > --- a/include/asm-generic/pgtable_uffd.h > > +++ b/include/asm-generic/pgtable_uffd.h > > @@ -2,6 +2,9 @@ > > #define _ASM_GENERIC_PGTABLE_UFFD_H > > > > #ifndef CONFIG_HAVE_ARCH_USERFAULTFD_WP > > + > > +#define UFFD_WP_SWP_PTE_SPECIAL __pte(0) > > + > > static __always_inline int pte_uffd_wp(pte_t pte) > > { > > return 0; > > diff --git a/include/linux/userfaultfd_k.h b/include/linux/userfaultfd_k.h > > index 331d2ccf0bcc..93f932b53a71 100644 > > --- a/include/linux/userfaultfd_k.h > > +++ b/include/linux/userfaultfd_k.h > > @@ -145,6 +145,17 @@ extern int userfaultfd_unmap_prep(struct vm_area_struct *vma, > > extern void userfaultfd_unmap_complete(struct mm_struct *mm, > > struct list_head *uf); > > > > +static inline pte_t pte_swp_mkuffd_wp_special(struct vm_area_struct *vma) > > +{ > > + WARN_ON_ONCE(vma_is_anonymous(vma)); > > + return UFFD_WP_SWP_PTE_SPECIAL; > > +} > > + > > +static inline bool pte_swp_uffd_wp_special(pte_t pte) > > +{ > > + return pte_same(pte, UFFD_WP_SWP_PTE_SPECIAL); > > +} > > + > > Sorry, only just noticed this but do we need to define a different version of > this helper that returns false for CONFIG_HAVE_ARCH_USERFAULTFD_WP=n to avoid > spurious matches with __pte(0) on architectures supporting userfaultfd but not > userfaultfd-wp? Good point.. Yes we definitely don't want the empty pte to be recognized as the special pte.. I'll squash below into the same patch: ----8<---- diff --git a/include/linux/userfaultfd_k.h b/include/linux/userfaultfd_k.h index 489fb375e66c..23ca449240d1 100644 --- a/include/linux/userfaultfd_k.h +++ b/include/linux/userfaultfd_k.h @@ -177,7 +177,11 @@ static inline pte_t pte_swp_mkuffd_wp_special(struct vm_area_struct *vma) static inline bool pte_swp_uffd_wp_special(pte_t pte) { +#ifdef CONFIG_HAVE_ARCH_USERFAULTFD_WP return pte_same(pte, UFFD_WP_SWP_PTE_SPECIAL); +#else + return false; +#fi } #else /* CONFIG_USERFAULTFD */ ----8<---- I'll see whether I can give some dry run without HAVE_ARCH_USERFAULTFD_WP but with USERFAULTFD. Thanks for spotting that! -- Peter Xu