Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2576108pxb; Tue, 23 Feb 2021 10:09:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJyAfuNXUCbSjljfuHNkDZH84HexiQuWCMrF8LdRQ3AfYkqn6Jx/d2Vl0lAEMUfzjR0omkiq X-Received: by 2002:aa7:ca59:: with SMTP id j25mr19858638edt.175.1614103743337; Tue, 23 Feb 2021 10:09:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614103743; cv=none; d=google.com; s=arc-20160816; b=T3EtRdNymnrBIvMp+zKYV7J+2T6o7vcFqcaZLo72Q8Vcg3M5vMxKcsCmdxv8+eaKyh KyJ/lGUIZBGBVXNcv3hiyjiiEne3Knld+e4XFKjQ9OzyLdNUdUta+GWeyLkk4ycztVdK jh0ac1PiAufNYtDiMH+ibCNRS6CaYAGjLkj8mHxKGyoSaeIjrAh1i4Vs6mcLOeQdZTIi ka7bNrETx8vgk29u9yJaiM6CtTx/oIqKVzHWoRm99r0Sz4sjS+nkvKaUij1W/0WitM88 OQjeWiZJvqnk0KmZ81a2dceRvExpAHnArA6KaJfINZzc6ZkRBfV0QmKkUPkjihN0GNXu 3z8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=vTI/ZdZz+qz8Dx2SLW9Ocz24gRVgR01CbdQNKNmll5k=; b=MOPp+ZVx799cNjIYk8axDAn6zeYTUcZgegaBEjsVLcEuHOe1DPDrsylsFvNgJuGuoo LQob02aYP72Bb6MiEMGOctrbDYBX3e62JwXI7xqAc0WhPjmqstDaPt+IoHtM8pFHQNdd 2wCyIkowdOazMKKHU9Z7bnhoXXRksSUu0r7k/YwwcmONB0k8EA9P6YhkFz6Ul2J3VlcP E3Reth77T95Hmodd0ptctDoD0Knyv3xj81HvGMxp+7zHxppidiHMsqBhT/8LCRqJnwgt LBpSSKIgXM2eAYk8oygKsefHok/KIEOzDY/M7LM4ZhOLZK1ygAbJ+86Lig6s3QGUvawu vESg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kJv3Zxq0; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs2si13838182edb.459.2021.02.23.10.08.14; Tue, 23 Feb 2021 10:09:03 -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=@google.com header.s=20161025 header.b=kJv3Zxq0; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233764AbhBWSHK (ORCPT + 99 others); Tue, 23 Feb 2021 13:07:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232180AbhBWSHI (ORCPT ); Tue, 23 Feb 2021 13:07:08 -0500 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76838C061786 for ; Tue, 23 Feb 2021 10:06:28 -0800 (PST) Received: by mail-io1-xd2e.google.com with SMTP id s24so18100913iob.6 for ; Tue, 23 Feb 2021 10:06:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vTI/ZdZz+qz8Dx2SLW9Ocz24gRVgR01CbdQNKNmll5k=; b=kJv3Zxq0E0xdXJMdBV0Qymaxo3EKmXLhrzNKEoR1lEq6FQ2L+KIToHQV71nOETjiu4 jSIDazyhhQfKFV3Siq4AGLLgHpeAJgvfeNFFwl6ZBV/NypjnFAv26PscPklbQKZkbhIg KDaQvT5mNTADuS2BE5Z/VFllYEjnbu736vlWbV0xSE74lwfdo2P+3SMSBuWCzk2d90X5 HmYlmKJd0nucCD/9eyNVU9egBEf6Y/sqkUNBf1FGWNLYulQ3vHiy1IEDz5FiGqsOc2JY bnw/q/JSbt8u8APa8ShoLnkzb05+xx30eFz/W7GHM/NuZn1EL1MmXYGVk82D0N3MXgUO D+zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vTI/ZdZz+qz8Dx2SLW9Ocz24gRVgR01CbdQNKNmll5k=; b=P4nBnaFRhteYp/shOaxsqDASoLsRb1K+csMEhWp033JrBE2TPKhXO8VWVIFQmBB4ag 5s0+NRnPXEx8HrKqmz7Ug5FraZJGJX4nxI6pwf0jWDvOlMi2qItkPEDlnlWUzrSYMmo2 3eMlPy3elBLZSynbVothFo0+d6LoOQBl3OFULOlOWKz4Qnu0KWCu9ayWRU9TNAFWZhB/ yy0rShdCKyvfOQGXUNOAlm7wlGGE31YYyVThHBKYLs+erctsQtCK0UdMWwCzoNAJMWK6 l6d3ECXrbSJ9iqWTEActt3EGyxdccc/9qUz/68ueXqms/LQthDtuc1YP9iOwPkzWYmzJ 5byQ== X-Gm-Message-State: AOAM5334KCy8M8EPoZ/WL4Jhc3skMOHPxpCHefLMsm+BYhQ0qcWhY1Jf 19/oJUSSGWcli7LZHeTjwf1iF2LjU3AQRBjvHvVNwA== X-Received: by 2002:a6b:c84a:: with SMTP id y71mr20733760iof.86.1614103587647; Tue, 23 Feb 2021 10:06:27 -0800 (PST) MIME-Version: 1.0 References: <20210219004824.2899045-1-axelrasmussen@google.com> <20210219004824.2899045-5-axelrasmussen@google.com> <20210223153840.GB154711@xz-x1> In-Reply-To: <20210223153840.GB154711@xz-x1> From: Axel Rasmussen Date: Tue, 23 Feb 2021 10:05:49 -0800 Message-ID: Subject: Re: [PATCH v7 4/6] userfaultfd: add UFFDIO_CONTINUE ioctl To: Peter Xu 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 , =?UTF-8?Q?Michal_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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 23, 2021 at 7:38 AM Peter Xu wrote: > > On Thu, Feb 18, 2021 at 04:48:22PM -0800, Axel Rasmussen wrote: > > @@ -4645,8 +4646,18 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, > > spinlock_t *ptl; > > int ret; > > struct page *page; > > + int writable; > > > > - if (!*pagep) { > > + mapping = dst_vma->vm_file->f_mapping; > > + idx = vma_hugecache_offset(h, dst_vma, dst_addr); > > + > > + if (is_continue) { > > + ret = -EFAULT; > > + page = find_lock_page(mapping, idx); > > + *pagep = NULL; > > Why set *pagep to NULL? Shouldn't it be NULL always?.. If that's the case, > maybe WARN_ON_ONCE(*pagep) suite more. Right, the caller should be passing in NULL in the MCOPY_ATOMIC_CONTINUE case. Looking more closely at the caller (__mcopy_atomic_hugetlb), it already has a BUG_ON(page), so at best this assignment is redundant, and at worst it might actually cover up a real bug (say the caller mistakenly *did* pass in some page, we'd set it to NULL and the BUG_ON wouldn't trigger). So, I'll just remove this - I don't think an additional WARN_ON_ONCE is needed given the existing BUG_ON. > > Otherwise the patch looks good to me. Shall I add a R-B? :) Thanks for taking the time to review Peter! > > Thanks, > > -- > Peter Xu >