Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp586806pxu; Fri, 4 Dec 2020 10:18:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/RvHGn5q4SspwEsPOVsWj+pzk4FTxnwfsVmx8PXRHgPUmppVtQ+WCJXp4kIL/ZEAHTu58 X-Received: by 2002:a17:907:6e6:: with SMTP id yh6mr8466418ejb.512.1607105889833; Fri, 04 Dec 2020 10:18:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607105889; cv=none; d=google.com; s=arc-20160816; b=wspiT1+yDpQoDxw3HlcnOHa6lDR7uIB2WHKsRGvqS0s0ezyFHUzIdAwXn0QkaP11yD O5eDBlHUBCcN4M6noRPIlDrgkLTtq2/oADfZpYYc9z5iBVcybr7kESqVlDBWwdfO1zDW kre5vPfg7875mE2otTq2wPJvSAhghRko3TuY1idL/ojf7K05uulAk9dyHz7YqA4ssFYK CfMAy5SxGVqw0drM+VYxIR2UlmhQiC9GKApfMOXbDRUYXBdGJ1BZQbD9ehYoIeXGVhda PvpuodJwl6IFeTgwjI/idRjAfxtx4CTo/BRUY23IcRf63L1yYi3ECDDRdSr3dJb0xL7k ayyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=4jiiSi2OMHYLdag0OnlL3n5HoKBr3a25AnpGnahrkVE=; b=zzUPu3K/jUSX98EO4dYsRkF+doh3mQzYDeTVWNsgcjvxCO6cGO09Zu/x9tYKpr4jYr 0elmwt6ZgTC5yg1/GVUXhf2rCPtWC5huT59gRL25DfL1aL7Ifs1Ykl/dyGPn2I1S/GPp kZIf3zJErBxpJ0A7oYPsQJ5UxKDpNfdygXrBCYUkY72M4vjgc8H3tMC5Cw6kVzYCacm6 +uq/tFQifo477xNFriDWro4jhMtg4GPLohSV1oAT/Vd90Hv1scMRtQXbQQ0nDexJrNZq AreJfsZ6kQPczvqEkjXHkkDPtSBqEHyO6jTAyVNlrd9pWH/JFGl8wVz/bGoUlnmWvxi/ X19Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SvXVNByg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si1867235ejn.15.2020.12.04.10.17.45; Fri, 04 Dec 2020 10:18:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SvXVNByg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387477AbgLDSOf (ORCPT + 99 others); Fri, 4 Dec 2020 13:14:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44466 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387419AbgLDSOf (ORCPT ); Fri, 4 Dec 2020 13:14:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607105589; 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=4jiiSi2OMHYLdag0OnlL3n5HoKBr3a25AnpGnahrkVE=; b=SvXVNBygKR31p1cXqk4HD1B62iGDvVMXwh+TL4VVnj3IoCJLV3DHcSBN3mbBpvIX+LSYsz G9pHusU4aR1AkD0+cudBnLQoeHbTJ0lIkLO555xtLQ6rpTtOH0XDn/NF/VwE5UjI9zcu3v wm3sXQCfeVQzmF0pl819AM+HycBDDrI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-262-96BjG46sM5uJfziFAbbziQ-1; Fri, 04 Dec 2020 13:13:05 -0500 X-MC-Unique: 96BjG46sM5uJfziFAbbziQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33890858180; Fri, 4 Dec 2020 18:13:03 +0000 (UTC) Received: from mail (ovpn-112-211.rdu2.redhat.com [10.10.112.211]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E24931A8A5; Fri, 4 Dec 2020 18:12:56 +0000 (UTC) Date: Fri, 4 Dec 2020 13:12:56 -0500 From: Andrea Arcangeli To: Peter Xu 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: References: <20201201125927.GB11935@casper.infradead.org> <20201201223033.GG3277@xz-x1> <20201202234117.GD108496@xz-x1> <20201203180234.GJ108496@xz-x1> <20201204023051.GL108496@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.2 (2020-11-20) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) 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) 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. Thanks, Andrea