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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 AFCAAC433E6 for ; Fri, 12 Feb 2021 20:48:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B75D64DEC for ; Fri, 12 Feb 2021 20:48:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231335AbhBLUsk (ORCPT ); Fri, 12 Feb 2021 15:48:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231578AbhBLUsb (ORCPT ); Fri, 12 Feb 2021 15:48:31 -0500 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E074AC061786 for ; Fri, 12 Feb 2021 12:47:50 -0800 (PST) Received: by mail-il1-x12a.google.com with SMTP id a16so414780ilq.5 for ; Fri, 12 Feb 2021 12:47:50 -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=XHQMdD4M/9n7kXDwApYNepXGgL4rr9toLyZC0YSWleM=; b=J1hnM+AVDAhiSATGl302gnQnCE/GOG7MuY62LilWK/sdFL812lS2Bdqnf2fQLH9VpQ SzmM1gCQNMH+gRnJHEedOgSB3Mxjd191Ve34rKxUCz5aBpMdmt9/wlQPW1Ce50WtxbgD ON5AlHpe8LT/nAzSpaTKz/4vknmVfNj08uFk6yL59XBq/0Ko7BpXjjOFhaT1xzn1crr1 oBcOPnRHOs3uv6kGiQnYHuOJr6phnsc+C3h5/yo4cZtENlUTCm8GccwJmpvr8IZZnDLQ 1Al2Ar8xTeYt+YJhhLB/xRjTwu1E+2S0h7j17nJ7oZKsEhogLRs7vJZqZW2IZiAi+K+s DynA== 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=XHQMdD4M/9n7kXDwApYNepXGgL4rr9toLyZC0YSWleM=; b=nOHO8qYT3gicxLuBPsYhQrFv4EY6o1HPmPpcOo3qkTlXkAjdOVoaPVeKnafw7W+K6a upZevNagHemi+fcPcZXxOM3nmqDkE3u0PnsX8PVWzlFDgDB8NNC/lWpIsEsEOkGIKyOu uFgYTixIze2XgPHNKUOvK7fp+BS6b/hApwMXuPbPYkdaA63U3pbb5/lGuJ+FYarsHQf2 hODSAJcQsn1p6C3UnnvX+Iwc8aVsCLPhJxEPKtApo+7rKMX9cwFQcoFaK2xfHU+oysjg LYGZx8xN6hgcBDU7dGQKxsaYRZREg3kM/QeNdWsgi3R74XdYqmICKQ/LtmnAswIQE8IG nxPQ== X-Gm-Message-State: AOAM530nVG8geqOibxQfK4HFpMI9NwLnqLhfayObz+bpO0eLqfkiHjV9 PidIkAjGE+v7zfw1W4217Q45sBeSiYMyQiW3F0nssg== X-Google-Smtp-Source: ABdhPJy7X2kavmCOVJnqOgE4aEszNs9PZjIWjqj0Wwe57tdEHfPYv7JFz1/cCUxHzeX2/mUbeHqaY8XYstpcrrvvp4M= X-Received: by 2002:a92:c941:: with SMTP id i1mr3869403ilq.258.1613162870096; Fri, 12 Feb 2021 12:47:50 -0800 (PST) MIME-Version: 1.0 References: <20210210212200.1097784-1-axelrasmussen@google.com> <20210210212200.1097784-3-axelrasmussen@google.com> <0a991b83-18f8-cd76-46c0-4e0dcd5c87a7@oracle.com> <20210212204028.GC3171@xz-x1> In-Reply-To: <20210212204028.GC3171@xz-x1> From: Axel Rasmussen Date: Fri, 12 Feb 2021 12:47:12 -0800 Message-ID: Subject: Re: [PATCH v5 02/10] hugetlb/userfaultfd: Forbid huge pmd sharing when uffd enabled To: Peter Xu Cc: Mike Kravetz , 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 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 Fri, Feb 12, 2021 at 12:40 PM Peter Xu wrote: > > 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. Sounds good to me. :) Thanks Peter + Mike for working on this! > > Thanks, > > -- > Peter Xu >