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=-6.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 A1CBCC433DB for ; Fri, 12 Feb 2021 20:40:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 339A164D9F for ; Fri, 12 Feb 2021 20:40:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 339A164D9F 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 BB68B8D008B; Fri, 12 Feb 2021 15:40:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B67C78D0060; Fri, 12 Feb 2021 15:40:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A56598D008B; Fri, 12 Feb 2021 15:40:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id 90FCD8D0060 for ; Fri, 12 Feb 2021 15:40:38 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5C773183C8CD9 for ; Fri, 12 Feb 2021 20:40:38 +0000 (UTC) X-FDA: 77810784156.08.limit82_120ca9627624 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 3B6A01819E643 for ; Fri, 12 Feb 2021 20:40:38 +0000 (UTC) X-HE-Tag: limit82_120ca9627624 X-Filterd-Recvd-Size: 6850 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Fri, 12 Feb 2021 20:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613162436; 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=lhv01WUAUIt7cfh7FfrEWuxYc6udpak2O8cJ5MSKjhM=; b=eUSZ9qjb2i4MZ6IXt19+s6OMl37SMr2OGOBA6Yw21KMLT467AQ92/E9Agp0FHZhoBquemc bte8dxDoHfqbF0dl2PkT2RhisCXG/YGYQH9gpXBMkW/9IBK6Nzo+KXliaKHMfBLZEOv1RK oh2pPYeMcXfUXrreZlNuTtHIXi10rjY= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-546-o7ZFDwFuMLWj7c0QwcJdWg-1; Fri, 12 Feb 2021 15:40:32 -0500 X-MC-Unique: o7ZFDwFuMLWj7c0QwcJdWg-1 Received: by mail-qv1-f71.google.com with SMTP id t18so383952qva.6 for ; Fri, 12 Feb 2021 12:40:32 -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=lhv01WUAUIt7cfh7FfrEWuxYc6udpak2O8cJ5MSKjhM=; b=VaePB7hkMMj3WIgGDFa0x421JE6RRzR0XpMr3Uu33cZTmEPQhH1o1Fcl+B639dGtuH ZSouF4fy4Z7vPpx3HpQbUuGlPcq538tIzTY9KHZ1Sj8tfKYnDYTexf4oSs1BfO4jy65f NeWqirRU5+iScR1KokxXgXQVNHL5W/viGDuIVSrKUjk+GHXNcIio8JhKx4HrZBBudxAB 7ikQ/PrpUPIWdHQh2R2FAieYqOMzQ715L+LsS8PMVjGRlYb499yJLoHilJUewlkQTgXP lMWQye4fpUzlPEXWq4Xv0VkADAVlfu0KK9JcYaJ74QPbmuXB8RWEfYD+HJxNoI+FGWt7 j5Vw== X-Gm-Message-State: AOAM5333g0XiAvR9WKucyBOlxDx8UnGfNxMRXgpKsb6NXlRB2bxg1N/E Gae1hZkEG+YJLBjFdQjgSvVCnrq0GF8e8HKUaB8KeT48mvpd7JoD/G3IGX6ZoKRWY909HbMyy9i +kbvvY6ZGsiM= X-Received: by 2002:a37:794:: with SMTP id 142mr4518162qkh.108.1613162432218; Fri, 12 Feb 2021 12:40:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUswzGCW3ELL2qJurJb7kKjeX2jYZXKw9W8lc+8Y9xOJdWIoFNQJ7ew2FPIeSB2eswM62WHQ== X-Received: by 2002:a37:794:: with SMTP id 142mr4518131qkh.108.1613162431919; Fri, 12 Feb 2021 12:40:31 -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 s129sm7083362qkh.37.2021.02.12.12.40.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 12:40:30 -0800 (PST) Date: Fri, 12 Feb 2021 15:40:28 -0500 From: Peter Xu To: Mike Kravetz , Axel Rasmussen Cc: Axel Rasmussen , 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 Rapoport , Nicholas Piggin , Shaohua Li , Shawn Anastasio , Steven Rostedt , Steven Price , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Adam Ruprecht , Cannon Matthews , "Dr . David Alan Gilbert" , David Rientjes , Mina Almasry , Oliver Upton Subject: Re: [PATCH v5 02/10] hugetlb/userfaultfd: Forbid huge pmd sharing when uffd enabled Message-ID: <20210212204028.GC3171@xz-x1> References: <20210210212200.1097784-1-axelrasmussen@google.com> <20210210212200.1097784-3-axelrasmussen@google.com> <0a991b83-18f8-cd76-46c0-4e0dcd5c87a7@oracle.com> MIME-Version: 1.0 In-Reply-To: <0a991b83-18f8-cd76-46c0-4e0dcd5c87a7@oracle.com> 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 Thu, Feb 11, 2021 at 04:19:55PM -0800, Mike Kravetz wrote: > want_pmd_share() is currently just a check for CONFIG_ARCH_WANT_HUGE_PMD_SHARE. > How about leaving that mostly as is, and adding the new vma checks to > vma_shareable(). vma_shareable() would then be something like: > > if (!(vma->vm_flags & VM_MAYSHARE)) > return false; > #ifdef CONFIG_USERFAULTFD > if (uffd_disable_huge_pmd_share(vma) > return false; > #endif > #ifdef /* XXX */ > /* add other checks for things like uffd wp and soft dirty here */ > #endif /* XXX */ > > if (range_in_vma(vma, base, end) > return true; > return false; > > Of course, this would require we leave the call to vma_shareable() at the > beginning of huge_pmd_share. It also means that we are always making a > function call into huge_pmd_share to determine if sharing is possible. > That is not any different than today. If we do not want to make that extra > function call, then I would suggest putting all that code in want_pmd_share. > It just seems that all the vma checks for sharing should be in one place > if possible. I don't worry a lot on that since we've already got huge_pte_alloc() which takes care of huge pmd sharing case, so I don't expect e.g. even most hugetlb developers to use want_pmd_share() at all, because huge_pte_alloc() will be the one that frequently got called. But yeah we can definitely put the check logic into huge_pmd_share() too. Looking at above code it looks still worth a helper like want_pmd_share() or with some other name. Then... instead of making this complicated, how about I mostly keep this patch but move want_pmd_share() call into huge_pmd_share() instead? Btw, Axel, it seems there will still be some respins on the pmd sharing patches. Since it turns out it'll be shared by multiple tasks now, do you mind I pick those out and send them separately? Then we can consolidate this part to move on with either the rest of the tasks we've got on hand. Thanks, -- Peter Xu