Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3237578pxb; Fri, 12 Feb 2021 12:52:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwb+NdMjnLa4w5N+H4V0wubuQrWrTOJlMn2ro9GhCKNTcTA171tmKRboIIS1f9KV550FDM X-Received: by 2002:a50:cd8c:: with SMTP id p12mr5344566edi.114.1613163158452; Fri, 12 Feb 2021 12:52:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613163158; cv=none; d=google.com; s=arc-20160816; b=VHZ4K9qnM5wHwp9Dj9YahdcopKwIJ6XcavWMwMzdRq3V2Wc8mYXkElEyQHXBCL+1mx lahntoZXuKDSNBX5G1tWVSnxKUcxNNy799Cd4VUafehb0si6T1SdXOk6JIPVCWrOMFv4 KNEoh+3iCl3ykTj3TE2XSJlNx9BJQ5B9ceK0fkKaX9nMi9TM1SygJe17VD8/tjfcSLxi OxnMq/WcQ9HnQ6YdwQjh/goOnkgb5F+WAcyGnPc4cxpiThYJcOYc122Q0KcCuLbqcYnk Bo9Mi29IcqcMxdnVlpReXtGGG4ejr0b1nYt9cGziqM2KrpvTAt7IjHLI3Ezt2Kk0Q6F5 ntEQ== 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=XHQMdD4M/9n7kXDwApYNepXGgL4rr9toLyZC0YSWleM=; b=bWYpaU0EJ5cyMBf1Efjy8m4VGGvJcRHfgX9Ae5ysmppXrXyX8nwVpAVdyRAyOUc2Be u7lUv2RJFDmo7JIMBxFaeoryNDfb5SepQBzqhbG8SaH+xvXpo1NRQSJuWX4CRlvX+mbQ IIBzu2OzDZc0gva6X5j4Wp/Uwgvl0UThrsqh2JM+3HE1kbFAJE0b3yYZsbKPs8QARlqZ hD2HWBDwy9H+8MCzWLRYwtp968brsiF/1xyUJOGGLRH58nm9Zk4wsdxC7OXtL7jLWFqx 9R6EcohaRBqVtZNcrL0TfVLjQbMm9TbdUHwTNKZXXnIOQaAfwIxUA8F9bP6IYfOJ/iO9 8b5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=J1hnM+AV; 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 j22si8372174eds.434.2021.02.12.12.52.15; Fri, 12 Feb 2021 12:52:38 -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=J1hnM+AV; 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 S231579AbhBLUse (ORCPT + 99 others); Fri, 12 Feb 2021 15:48:34 -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-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 >