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.1 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 F125EC433E0 for ; Mon, 1 Feb 2021 22:40:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7581B64E8F for ; Mon, 1 Feb 2021 22:40:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7581B64E8F 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 D75496B0005; Mon, 1 Feb 2021 17:40:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D262E6B0006; Mon, 1 Feb 2021 17:40:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C15946B006E; Mon, 1 Feb 2021 17:40:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id AB5286B0005 for ; Mon, 1 Feb 2021 17:40:41 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 6FDB48249980 for ; Mon, 1 Feb 2021 22:40:41 +0000 (UTC) X-FDA: 77771169882.16.push12_2702417275c5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 50087100E690B for ; Mon, 1 Feb 2021 22:40:41 +0000 (UTC) X-HE-Tag: push12_2702417275c5 X-Filterd-Recvd-Size: 8302 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Mon, 1 Feb 2021 22:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612219240; 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=J18vp4BI/ebFhdk0cpsu32Zy+DBZ0tg0DUF5VJd/Tc0=; b=LuFQ339/I2nM/5Rj6130QGBG36mwtK88bPPH5Og3e/+RmkCNYJ71J/zlPJXA3d5EJQAn1t YdeDSMElGQO3r0MP+NAi2YvNXmjUm51SGgzizRX0FRnqCgelVf6etbPlIfxeDWcgSbm19a 1/kf9SjIzYAmOqybIVEowHkSgji0olE= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-482-QoGYCTfSOnalny0RHRA69w-1; Mon, 01 Feb 2021 17:40:39 -0500 X-MC-Unique: QoGYCTfSOnalny0RHRA69w-1 Received: by mail-qk1-f198.google.com with SMTP id e5so14472203qkn.2 for ; Mon, 01 Feb 2021 14:40:38 -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=J18vp4BI/ebFhdk0cpsu32Zy+DBZ0tg0DUF5VJd/Tc0=; b=YtuF1Qp1VlfPhACQsayvW7CmtBwYoSSYASz+xUsWK8GZiYV96JotTssLRSEdSqdw24 yCCKvGUmxHUZOOciA6HWVRDxZt6ELZ5MTeTJmdy9DSzPAJvkJLfKJK9ivWN8M2jj/giU rG5+mzXRq1wgzkMkmJLqSlnZr9RGCIONflJT8KcaQp+8GCo/eU06OyOVzY6oRLUMqLpM FdV5SizgohHwFl+zhgqj0NIG9bffHzR6BWxzseskQQ4ywz0wf3Os8IFWURsDdVwM42Yu mT7+x5+lK75k9XhCnh1cTCktTlO9YwzUOEjEM5TcnnNsVwUzXypPYsUysYyPe90nTIFJ Wdqw== X-Gm-Message-State: AOAM531XjdkzjXmMePD2f0z+UdV0NIBrzGBTSGfVoGuaZBXTtpoWVuVA fPCDoOfTm93935MGnK1iMFro8PKlhqYsjmkEuGKqEytu7qVsR2OUMjIwqfUKlzF80uIAYwTUANt 99Ht2C3D21SE= X-Received: by 2002:ac8:a0e:: with SMTP id b14mr17645164qti.84.1612219237533; Mon, 01 Feb 2021 14:40:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJz7xwXfMofxMeMxRqMfaHNZOg0cOL3zUZ3F3Qf+B3DM0/q4O8qqrR6sOuxbjzxvhBSR938x4Q== X-Received: by 2002:ac8:a0e:: with SMTP id b14mr17645127qti.84.1612219237292; Mon, 01 Feb 2021 14:40:37 -0800 (PST) Received: from xz-x1 ([142.126.83.202]) by smtp.gmail.com with ESMTPSA id q92sm14531141qtd.92.2021.02.01.14.40.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 14:40:36 -0800 (PST) Date: Mon, 1 Feb 2021 17:40:34 -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 , Oliver Upton Subject: Re: [PATCH v3 7/9] userfaultfd: add UFFDIO_CONTINUE ioctl Message-ID: <20210201224034.GK260413@xz-x1> References: <20210128224819.2651899-1-axelrasmussen@google.com> <20210128224819.2651899-8-axelrasmussen@google.com> <20210201192120.GG260413@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-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 Mon, Feb 01, 2021 at 02:11:55PM -0800, Axel Rasmussen wrote: > On Mon, Feb 1, 2021 at 11:21 AM Peter Xu wrote: > > > > On Thu, Jan 28, 2021 at 02:48:17PM -0800, Axel Rasmussen wrote: > > > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h > > > index f94a35296618..79e1f0155afa 100644 > > > --- a/include/linux/hugetlb.h > > > +++ b/include/linux/hugetlb.h > > > @@ -135,11 +135,14 @@ void hugetlb_show_meminfo(void); > > > unsigned long hugetlb_total_pages(void); > > > vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, > > > unsigned long address, unsigned int flags); > > > +#ifdef CONFIG_USERFAULTFD > > > > I'm confused why this is needed.. hugetlb_mcopy_atomic_pte() should only be > > called in userfaultfd.c, but if without uffd config set it won't compile > > either: > > > > obj-$(CONFIG_USERFAULTFD) += userfaultfd.o > > With this series as-is, but *without* the #ifdef CONFIG_USERFAULTFD > here, we introduce a bunch of build warnings like this: > > > > In file included from ./include/linux/migrate.h:8:0, > from kernel/sched/sched.h:53, > from kernel/sched/isolation.c:10: > ./include/linux/hugetlb.h:143:12: warning: 'enum mcopy_atomic_mode' > declared inside parameter list > struct page **pagep); > ^ > ./include/linux/hugetlb.h:143:12: warning: its scope is only this > definition or declaration, which is probably not what you want > > And similarly we get an error about the "mode" parameter having an > incomplete type in hugetlb.c. > > > > This is because enum mcopy_atomic_mode is defined in userfaultfd_k.h, > and that entire header is wrapped in a #ifdef CONFIG_USERFAULTFD. So > we either need to define enum mcopy_atomic_mode unconditionally, or we > need to #ifdef CONFIG_USERFAULTFD the references to it also. > > - I opted not to move it outside the #ifdef CONFIG_USERFAULTFD in > userfaultfd_k.h (defining it unconditionally), because that seemed > messy to me. > - I opted not to define it unconditionally in hugetlb.h, because we'd > have to move it to userfaultfd_k.h anyway when shmem or other users > are introduced. I'm planning to send a series to add this a few days > or so after this series is merged, so it seems churn-y to move it > then. > - It seemed optimal to not compile hugetlb_mcopy_atomic_pte anyway > (even ignoring adding the continue ioctl), since as you point out > userfaultfd is the only caller. > > Hopefully this clarifies this and the next two comments. Let me know > if you still feel strongly, I don't hate any of the alternatives, just > wanted to clarify that I had considered them and thought this approach > was best. Then I'd suggest you use a standalone patch to put hugetlb_mcopy_atomic_pte() into CONFIG_USERFAULTFD blocks, then propose your change with the minor mode. Note that there're two hugetlb_mcopy_atomic_pte() defined in hugetlb.h. Although I don't think it a problem since the other one is inlined - I think you should still put that one into the same ifdef: #ifdef CONFIG_USERFAULTFD static inline int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, pte_t *dst_pte, struct vm_area_struct *dst_vma, unsigned long dst_addr, unsigned long src_addr, struct page **pagep) { BUG(); return 0; } #endif /* CONFIG_USERFAULTFD */ Let's also see whether Mike would have a preference on this. Thanks, -- Peter Xu