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=-7.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 49C83C4361A for ; Fri, 4 Dec 2020 19:23:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D22D322C9C for ; Fri, 4 Dec 2020 19:23:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D22D322C9C 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 0A7CF6B0036; Fri, 4 Dec 2020 14:23:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 058BF6B005C; Fri, 4 Dec 2020 14:23:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E13616B005D; Fri, 4 Dec 2020 14:23:35 -0500 (EST) 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 C93646B0036 for ; Fri, 4 Dec 2020 14:23:35 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8FF73181AEF23 for ; Fri, 4 Dec 2020 19:23:35 +0000 (UTC) X-FDA: 77556573990.26.use16_081263c273c6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 767C71804B66B for ; Fri, 4 Dec 2020 19:23:35 +0000 (UTC) X-HE-Tag: use16_081263c273c6 X-Filterd-Recvd-Size: 6325 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Fri, 4 Dec 2020 19:23:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607109813; 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=niaIGDCDXfXTEqCqwbBQh3Co62h+ONx2LUP6ZS97Ulg=; b=ZzWKGv3rVfQi+l3atpQd1obSGvjDdNaHnLvT3J4+LFaJ0ZyDu9YS0BPR+v9ADspfj6u/JW EMsgZ5ILptylHwG8teEhqQrzjjFLfl6eepGhcLzpW8m3vzgJDkDShwOTi0vJKp3wa/VhfE qPtEMJlgkNNy7mxt1G4m9/Sk4niXXhI= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-514-6_T5_65rOsGNAA7S5dHExQ-1; Fri, 04 Dec 2020 14:23:32 -0500 X-MC-Unique: 6_T5_65rOsGNAA7S5dHExQ-1 Received: by mail-qv1-f71.google.com with SMTP id e11so5602528qvu.18 for ; Fri, 04 Dec 2020 11:23:32 -0800 (PST) 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=niaIGDCDXfXTEqCqwbBQh3Co62h+ONx2LUP6ZS97Ulg=; b=OEakyGy9Pv7asYeAMb/OgWaB2We4+BWXpgzC6Yz4dC55KW28UduPmQLgTt91QYgmKd 21dRryPhF6G1ktjAjSRV/o/Cy/kwie45EW0rGUQdo4Jzm3r9yOGjYwwVq8UvuESz6/56 zmutoyJJ+YDAS8lgFOlvV7Jk1nkjIhfoM2GKlk5DvSvLNLGBr+MjwqxPXAyxmC0vPRA5 Q36uPm+/i9gP5L8FK8rsQLk4FLM+0NRHYBIgjGqbBp8RHiYerEjtpZpRG9wmVPCvTkN/ RWWjrdAt6OnPslgD7Zv98+a81eGsaBbeSvDp/76w5bIu37/W/LRTywDx4OjHkgRDt5f/ tL9w== X-Gm-Message-State: AOAM531YIdD6S1USsTX0Ph1U4yjcWyjalpVplatfgyoACNX1Sta/WIC6 7ACMu6+wXTVOknfNzx83gZq7QaBcxEhlInycnbx5CX+FWnPQESYVFuY5zSSmzNbtlqePedLJSYn l4XC83vt1kZg= X-Received: by 2002:ad4:55ad:: with SMTP id f13mr7064887qvx.22.1607109812102; Fri, 04 Dec 2020 11:23:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPwfdWkjrqP22VYjaNLyGNycheU8bKQHrQUx5OO1VxEyQeTSJauNi8O1k47Dz8B+UQQtr8oA== X-Received: by 2002:ad4:55ad:: with SMTP id f13mr7064861qvx.22.1607109811795; Fri, 04 Dec 2020 11:23:31 -0800 (PST) Received: from xz-x1 ([142.126.94.187]) by smtp.gmail.com with ESMTPSA id e11sm1321364qka.126.2020.12.04.11.23.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 11:23:30 -0800 (PST) Date: Fri, 4 Dec 2020 14:23:29 -0500 From: Peter Xu To: Andrea Arcangeli Cc: Hugh Dickins , Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Mike Rapoport , David Hildenbrand Subject: Re: [PATCH v2] mm: Don't fault around userfaultfd-registered regions on reads Message-ID: <20201204192329.GP108496@xz-x1> References: <20201201223033.GG3277@xz-x1> <20201202234117.GD108496@xz-x1> <20201203180234.GJ108496@xz-x1> <20201204023051.GL108496@xz-x1> MIME-Version: 1.0 In-Reply-To: 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=utf-8 Content-Disposition: inline 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: Hi, Andrea, On Fri, Dec 04, 2020 at 01:12:56PM -0500, Andrea Arcangeli wrote: > On Thu, Dec 03, 2020 at 11:10:18PM -0500, Andrea Arcangeli wrote: > > from the pte, one that cannot ever be set in any swp entry today. I > > assume it can't be _PAGE_SWP_UFFD_WP since that already can be set but > > you may want to verify it... > > I thought more about the above, and I think the already existing > pte_swp_mkuffd_wp will just be enough without having to reserve an > extra bitflag if we encode it as a non migration entry. > > The check: > > if (!pte_present && !pte_none && pte_swp_uffd_wp && not_anonymous_vma && !is_migration_entry) [1] > > should be enough to disambiguate it. When setting it, it'd be enough > to set the pte to the value _PAGE_SWP_UFFD_WP. > > Although if you prefer to check for: > > if (!pte_present && !pte_none && swp_type == 1 && swp_offset == 0 && not_anonymous_vma && !is_migration_entry) [2] > > that would do as well. > > It's up to you, just my preference is to reuse _PAGE_SWP_UFFD_WP since > it has already to exist, there are already all the pte_swp_*uffd* > methods available or uffd-wp cannot work. Yes, I had the same thought that it would be nice if this special pte can be still related to _PAGE_SWP_UFFD_WP. To me, above [2] looks exactly the same as Hugh suggested to check against swp_type==1 && swp_offset==0, since: - do_swap_page() basically already means "!pte_present && !pte_none" - "not_anonymous_vma" seems optional if uffd-wp+shmem will be the first user of such a swp entry - "!is_migration_entry" seems optional since if swp_type==1, it will never be a migration entry While for above [1] that's the thing I asked besides the current type==1 & offset=0 proposal. Quotting one of the previous emails: > So I guess I'll start with type==1 && offset==0. > > (PS: I still think "swp_entry(0, _UFFD_SWP_UFFD_WP) && !vma_is_anonymous(vma)" > could also be a good candidate comparing to "swp_entry(1, 0)" considering > type==1 here is kind of randomly chosen from all the other numbers except 0; > but maybe that's not extremely important - the major logic should be the same) If we see [1]: if (!pte_present && !pte_none && pte_swp_uffd_wp && not_anonymous_vma && !is_migration_entry) Then it's fundamentally the same as: swp_entry(0, _UFFD_SWP_UFFD_WP) && !vma_is_anonymous(vma) Reasons similar to above. Thanks! -- Peter Xu