Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp641765pxu; Fri, 4 Dec 2020 11:43:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVbMrlqunoZoPgti8CoyrzUb2/i7Hlr/jdTZ/2CRTA08BvP9qM0FhvpP0LDn/DUcown8GB X-Received: by 2002:aa7:da8f:: with SMTP id q15mr9053009eds.239.1607111000427; Fri, 04 Dec 2020 11:43:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607111000; cv=none; d=google.com; s=arc-20160816; b=zG2Srz761ejNGQEDAirLSmaoYq/7EDlPWRgoYHSsPlDi1D0cIvrV8aetzbiMHBQHP7 WhngvT5wJ1reZo2XAKCGlnvAR+6dSgCumiWjonBeOQ2xVzKVB5QsEE1ivuxcf5d1nuHT MJTi8Cb0nQB2hh0eC3/8VzRgkjKjGQ96Q9u3TtA1OtgYnmG5Y+KdT6HYgrmlSTOZBLyB xSVAhsAHdvietqWYYCkM+2dbY6JjCh71iASOvjOato23MbcsllOXLz4hEs9kjjQkFQHd kndEmiBFnVZNQe06jFPD9UN7d9NrGpuDauMbRNoRUc1KGsXIroBGENcFNGXXK10p8ZF6 Tt3A== 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=YkMVep6lpTapkyPhQc3/pDFiWvkLP0M38PqZ1b/p6cc=; b=QEHRL1K3bD8OUuHq6z0JfL1J5Dtg3twI+nm33XXJD7xQq5L7fSFBJhWrR1sd4IfEH8 UhGcpkLO4DWf9+WeYQh+eqflB5oHrGaG8qjuGCz+6BZVTv28lYXzdER4gX6Zh9hv2te6 6z9/JwZ3nrC/yUgbS3sFKB9F2KKPY0eT32FAY2NmXpj53c1JhmBZTI9obe0yPZrL8iQP JThh/+JIa+omgWa/gLyaaQch1io6jI2zxHfbW80W/FQmoIvzdikpyb/Zcz5TL58bmZAV XEB3qkAR/6w/kivVb7yg6qduT0/qoAsCvrroIntUDFtIjdnXLiNys3qV9QQ1rLDB9d14 qTwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aVeHBVF2; 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 y24si2005475ejc.613.2020.12.04.11.42.57; Fri, 04 Dec 2020 11:43:20 -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=aVeHBVF2; 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 S1727693AbgLDTjK (ORCPT + 99 others); Fri, 4 Dec 2020 14:39:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23052 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725923AbgLDTjJ (ORCPT ); Fri, 4 Dec 2020 14:39:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607110663; 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=aVeHBVF2urGZZAMdj+Bopg/RqszsznZgiuLFhRbu0vffMXxS82sP69miLQk1Ytc+uYKHsR VlHfsmbIoA/1thuKVz7uUcVaB1KhDW/a0MsMWN3u5x72VetBIm51P7cATRRLtcRIwnXUyp xn3dSqe0tVT5vM/lRWqWEqrCe/XkElw= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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