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.3 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 76F9AC433E0 for ; Wed, 10 Feb 2021 19:08:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48F5964E66 for ; Wed, 10 Feb 2021 19:08:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234537AbhBJTIN (ORCPT ); Wed, 10 Feb 2021 14:08:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:49421 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234491AbhBJTHp (ORCPT ); Wed, 10 Feb 2021 14:07:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612983978; 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=mTO49+9LAVg0rMFnoR7UG6tSv24dSvHoSbA2pY65UM0=; b=NeiLKnOeHI0k45+7Az/iFfhVLjMZfQkWvwlCmi84NqYqFncdOZQeKZ5ejk3kT0CvVPnDiG 0bXN4DgV1hmM7yfI69Lkjhb7dqqDMNaA5SIGogcyHdJqoSuGcobBEn2DLUyF9Uwle4/Mr1 dFUmohU4aKBOD8L24E65n2XFetIIi6s= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-334-2lC0UEciPMiRJR2pjWxiUA-1; Wed, 10 Feb 2021 14:06:16 -0500 X-MC-Unique: 2lC0UEciPMiRJR2pjWxiUA-1 Received: by mail-qt1-f198.google.com with SMTP id w92so2332779qte.20 for ; Wed, 10 Feb 2021 11:06:16 -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=mTO49+9LAVg0rMFnoR7UG6tSv24dSvHoSbA2pY65UM0=; b=X8un1dZT3/+XtV6ldNMtJywPem3cWL1pn0k0vU6C62L1ZeEQoeejcazVim8NM492ay +H1k+zSJPrLaE9UAqqkhG6VUOHXWqeY2QKGmbC9I+l+Dln3gVjNEIhC4zLu3sfy1Q/R3 RozqZhWPKhkqzi4k1TSDFHAzeQepFuYCzoCftiFz0f0msSiJ3UL0iNfi61uI1JeBzRtV gqzNyJhYk4PbbvIOa/6BuOFY1++n61dmhpbhIjgQqywBpKTp+woL8XxnVPWKxhHKrQh/ wYvahHNdq6cDL0/9Er/grOamZbGgcWfukn3gvkwJHXTJH3IDOvubPobndC85xX/LH3El 1gZg== X-Gm-Message-State: AOAM531/UczeUcvjGGNzw8Q824yLYRtpiDcUElAVRUCq2ke9/QtWSP3i KnmT0fDeYcDWD6heDE7K23gAqY+drunia2vEX7rq2nv3CUDT0DJNcGQ34iZRLCyEevBgJEYHNqW mLmFTWaZ0DI9Q0b7rax6d2kJe X-Received: by 2002:ac8:5448:: with SMTP id d8mr4222562qtq.6.1612983975769; Wed, 10 Feb 2021 11:06:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/tRv5jLjJTHr+SmhyryUCprE3egVTktEAB26vf0nH0SrxAd7lAW7psca7AdeRoRpnWVCiiA== X-Received: by 2002:ac8:5448:: with SMTP id d8mr4222534qtq.6.1612983975422; Wed, 10 Feb 2021 11:06:15 -0800 (PST) Received: from xz-x1 (bras-vprn-toroon474qw-lp130-20-174-93-89-182.dsl.bell.ca. [174.93.89.182]) by smtp.gmail.com with ESMTPSA id o24sm1948099qtt.36.2021.02.10.11.06.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Feb 2021 11:06:14 -0800 (PST) Date: Wed, 10 Feb 2021 14:06:12 -0500 From: Peter Xu To: Axel Rasmussen Cc: Alexander Viro , Alexey Dobriyan , Andrea Arcangeli , Andrew Morton , Anshuman Khandual , Catalin Marinas , Chinwen Chang , Huang Ying , Ingo Molnar , Jann Horn , Jerome Glisse , Lokesh Gidra , "Matthew Wilcox (Oracle)" , Michael Ellerman , Michal =?utf-8?Q?Koutn=C3=BD?= , Michel Lespinasse , Mike Kravetz , Mike Rapoport , Nicholas Piggin , Shaohua Li , Shawn Anastasio , Steven Rostedt , Steven Price , Vlastimil Babka , LKML , linux-fsdevel@vger.kernel.org, Linux MM , Adam Ruprecht , Cannon Matthews , "Dr . David Alan Gilbert" , David Rientjes , Mina Almasry , Oliver Upton Subject: Re: [PATCH v4 08/10] userfaultfd: add UFFDIO_CONTINUE ioctl Message-ID: <20210210190612.GR103365@xz-x1> References: <20210204183433.1431202-1-axelrasmussen@google.com> <20210204183433.1431202-9-axelrasmussen@google.com> <20210208235411.GC71523@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 10, 2021 at 10:00:21AM -0800, Axel Rasmussen wrote: > > > static __always_inline ssize_t mfill_atomic_pte(struct mm_struct *dst_mm, > > > @@ -417,10 +416,14 @@ static __always_inline ssize_t mfill_atomic_pte(struct mm_struct *dst_mm, > > > unsigned long dst_addr, > > > unsigned long src_addr, > > > struct page **page, > > > - bool zeropage, > > > + enum mcopy_atomic_mode mode, > > > bool wp_copy) > > > { > > > ssize_t err; > > > + bool zeropage = (mode == MCOPY_ATOMIC_ZEROPAGE); > > > + > > > + if (mode == MCOPY_ATOMIC_CONTINUE) > > > + return -EINVAL; > > > > So you still passed in the mode into mfill_atomic_pte() just to make sure > > CONTINUE is not called there. It's okay, but again I think it's not extremely > > necessary: we should make sure to fail early at the entry of uffdio_continue() > > by checking against the vma type to be hugetlb, rather than reaching here. > > Hmm, it's not quite as simple as that. We don't have the dst_vma yet > in uffdio_continue(), __mcopy_atomic looks it up. > > I'd prefer not to look it up in uffdio_continue(), because I think > that means changing the API so all the ioctls look up the vma, and > then plumb it into __mcopy_atomic. (We don't want to look it up twice, > since each lookup has to traverse the rbtree.) This is complicated too > by the fact that the ioctl handlers would need to perform various > validation / checks - e.g., acquiring mmap_lock, dealing with > *mmap_changing, validating the range, .... Sure. > > We can move the enforcement up one more layer, into __mcopy_atomic, > easily enough, though. Right, that sounds good to me. It should be right after the "if (!vma_is_anonymous(dst_vma) && !vma_is_shmem(dst_vma))" check. Thanks, -- Peter Xu