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=-8.7 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,USER_AGENT_SANE_1 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 829E3C433FE for ; Fri, 4 Dec 2020 19:37:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 10BB622CA1 for ; Fri, 4 Dec 2020 19:37:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 10BB622CA1 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 610206B0036; Fri, 4 Dec 2020 14:37:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5BFE76B005C; Fri, 4 Dec 2020 14:37:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B98C6B005D; Fri, 4 Dec 2020 14:37:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0048.hostedemail.com [216.40.44.48]) by kanga.kvack.org (Postfix) with ESMTP id 326206B0036 for ; Fri, 4 Dec 2020 14:37:47 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E71A31EF1 for ; Fri, 4 Dec 2020 19:37:46 +0000 (UTC) X-FDA: 77556609732.23.act25_630c869273c7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id C8CA337606 for ; Fri, 4 Dec 2020 19:37:46 +0000 (UTC) X-HE-Tag: act25_630c869273c7 X-Filterd-Recvd-Size: 3660 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Fri, 4 Dec 2020 19:37:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607110665; 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=YkMVep6lpTapkyPhQc3/pDFiWvkLP0M38PqZ1b/p6cc=; b=J792vSoXETUrvDtCy/rn7Pk7Sc3tNdwU1RUi0kdebKkOsP2vADuHLiwAGOVlQD/RFP7lkc 1tw/lhBwSYG9ZF5LYpeHSMlWsAm0dDzaZdkbcPL4Nj7U0UGbxvEHZRggl8/bRGOoyz3W0k jNAkabFyB3sY0OphmJsAi450gAVl/9o= 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-11-49K0YkFOOdK5vozU-UX4RA-1; Fri, 04 Dec 2020 14:37:40 -0500 X-MC-Unique: 49K0YkFOOdK5vozU-UX4RA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 71C67107AFD3; Fri, 4 Dec 2020 19:37:18 +0000 (UTC) Received: from mail (ovpn-112-211.rdu2.redhat.com [10.10.112.211]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3587560861; Fri, 4 Dec 2020 19:37:18 +0000 (UTC) Date: Fri, 4 Dec 2020 14:37:17 -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: <20201202234117.GD108496@xz-x1> <20201203180234.GJ108496@xz-x1> <20201204023051.GL108496@xz-x1> <20201204192329.GP108496@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201204192329.GP108496@xz-x1> User-Agent: Mutt/2.0.2 (2020-11-20) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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 Fri, Dec 04, 2020 at 02:23:29PM -0500, Peter Xu wrote: > 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) Yes conceptually it's the same, but in practice it's different value in the raw pte if you set swp_offset to _UFFD_SWP_UFFD_WP. Setting swp_offset to _UFFD_SWP_UFFD_WP is just confusing, it's better magic type 1 offset 0 then to even touch _UFFD_SWP_UFFD_WP if you reserve the magic value in the swap entry. pte_swp_uffd_wp or _UFFD_SWP_UFFD_WP are the raw pte value. swp_entry(0, _UFFD_SWP_UFFD_WP) is not the raw pte value, and it has to be first converted to the raw pte value with swp_entry_to_pte, so the _UFFD_SWP_UFFD_WP gets shifted left. If we use _UFFD_SWP_UFFD_WP it looks much cleaner to keep it in the pte, not in the swp entry, since then you can use the already existing methods that only can take in input the pte_t (not the swp_entry_t). Thanks, Andrea