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=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 A62E3C433E0 for ; Wed, 10 Feb 2021 19:06:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 38ABD64E42 for ; Wed, 10 Feb 2021 19:06:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38ABD64E42 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 B66576B0073; Wed, 10 Feb 2021 14:06:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AEDD36B0074; Wed, 10 Feb 2021 14:06:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91A556B0075; Wed, 10 Feb 2021 14:06:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id 779D26B0073 for ; Wed, 10 Feb 2021 14:06:21 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 423B1824556B for ; Wed, 10 Feb 2021 19:06:21 +0000 (UTC) X-FDA: 77803288962.05.9792061 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 510F6407F8DB for ; Wed, 10 Feb 2021 19:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612983979; 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=DOcyxj/IrTje6v/yL9Vori/8uPyJICDlkAQQb50zXV/pG5u15or1XhoHcs7QcOXVaJC+qv Wc1MueefBFaPW+XarYlm8tiuhhk6G2D9TFkJsQgdvGLTpuPrYzTdEKq1TBM7Fo4IgZdMnF c1+c9P7+Eam3V0qK54qNehWxjyRb5+g= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-498-xwCIPvFlMrGR2QZ2bXo0Rw-1; Wed, 10 Feb 2021 14:06:16 -0500 X-MC-Unique: xwCIPvFlMrGR2QZ2bXo0Rw-1 Received: by mail-qt1-f200.google.com with SMTP id o20so2325231qtx.22 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=As4chzzJI34zrbjhzY9YYBQg6QehWrtzLfEjxqb9hnzjM41vI0cTTiXNczToqeJvIL 3CprvmZiWi+s8UBgC5EnMhnRpZiSwrpnJcWtfF1AY3aMlCjUDoy1gTnx20NkdMySDwwl d0H7TjVsgAHLXJ2SsJQ5awUfofJn7OgIdokcpqU8MFJlfewsSKfCsK8DPznyWKqQ/0Ju Xxp5zwX3n+Ar/GxbmLofp69yJfKeS/PDGr7xrXUIvfuwLxyeAaAC6ljHqLUxlFI/LYWY Qg6Hj4iSfzTABF53ltJwTgQL9QHCQgyZxtGj0f8z6G8BEaU1+PbEHLphNDhrdi6mmFD/ TFmQ== X-Gm-Message-State: AOAM5301ZCrLhxzmYbuHbda39ET1UoS/L4hgwYi9cJMmzotBHEX1PYHs a+Hp+NYgGoyPlMAWRkC9/308ySLfX/a0WRpNYiL20tjvPph4z4Vcelxima0g2drJaicexqNoUhu 5dwg2LabFHT4= X-Received: by 2002:ac8:5448:: with SMTP id d8mr4222582qtq.6.1612983975779; 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 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-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 510F6407F8DB X-Stat-Signature: e9t3yda633uuu9m1s91fqecrkm59gj81 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf26; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=63.128.21.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1612983979-577993 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 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