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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A74E6CCA479 for ; Wed, 13 Jul 2022 18:03:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 436ED940158; Wed, 13 Jul 2022 14:03:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E739940134; Wed, 13 Jul 2022 14:03:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AF90940158; Wed, 13 Jul 2022 14:03:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1D014940134 for ; Wed, 13 Jul 2022 14:03:58 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D68C120B3A for ; Wed, 13 Jul 2022 18:03:57 +0000 (UTC) X-FDA: 79682850114.27.855CF25 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 665E14003D for ; Wed, 13 Jul 2022 18:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657735435; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qq4rbqh9j9QqFNAu6orBc1kOpVtgKyUJMzBlJDFOspE=; b=PpE0Z3DeC9RmgkoKQik51tBnegI7Ah4CNnqS3df/gjkz2KMrpA01A7u9pGGUNwHZCnpU2M 5zVTNUKwTM4jkQtultNe0rdVOE8UefeESULBym80SuMP0VgoiOnf6GV08jrTAvFMHkTBS9 jSXV9tM0VBALsFlRaS4EBbMsY+QyD+0= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-182-3vaVcMmMPGeH3XLSJaLgpg-1; Wed, 13 Jul 2022 14:03:52 -0400 X-MC-Unique: 3vaVcMmMPGeH3XLSJaLgpg-1 Received: by mail-wm1-f69.google.com with SMTP id 83-20020a1c0256000000b003a2d01897e4so5760252wmc.9 for ; Wed, 13 Jul 2022 11:03:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=qq4rbqh9j9QqFNAu6orBc1kOpVtgKyUJMzBlJDFOspE=; b=23UwBlpo9rqn65KXdBEt9cX6cjpfx5ads8hem9fDFtSF9tDgEDD0XnWSNcK5lLT2Hs 2WvqhKcnJRYuli+zkERCFphCqHYrz1h/SJ6nWSXhxBbYLdgDCFbVMSf/FI/j6OIW9OKO osZJfIJSqdPEqXr8gKF9AJkiqGXjGynBjFrjRvPFsV+Hib4XQrOfROzxxtvgxYL79E2c WbK1trdRnoPqEvU9IvpLArXLyPTyhAH43HOppVfW6navIlWVb8UvBHbLkIGcFLWtvK0h WacZfNVxB8BNGBUtI+wL6XEnks1N7JzIwtJlR6qNGN3zHWhj5epBnCj3xwNOUGlY2NrK sNSg== X-Gm-Message-State: AJIora8sgxF6gkiSynL7dzfCOUiTE2kXPIkjLVQpGrcL8WxaYMMPmHqg CLPk/PRs+v+QX/XGbmUEvW1BvrbikkYhFzfIWl5imDTGgG5j8aZLEsGAR74JFqJdPzAJRAmA0X2 sOTv4WIpaaik= X-Received: by 2002:a5d:638e:0:b0:21d:68bc:17c8 with SMTP id p14-20020a5d638e000000b0021d68bc17c8mr4515519wru.467.1657735431062; Wed, 13 Jul 2022 11:03:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uWxDrVrEZx/YPI60k7+IxR4NpRPIkwimgG3BIPzBmrjO/IHk6FPykEeu5eTFieuTO477OAQA== X-Received: by 2002:a5d:638e:0:b0:21d:68bc:17c8 with SMTP id p14-20020a5d638e000000b0021d68bc17c8mr4515473wru.467.1657735430779; Wed, 13 Jul 2022 11:03:50 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:5800:5009:e8d0:d95e:544d? (p200300cbc70758005009e8d0d95e544d.dip0.t-ipconnect.de. [2003:cb:c707:5800:5009:e8d0:d95e:544d]) by smtp.gmail.com with ESMTPSA id t18-20020a5d6912000000b0021d888e1132sm11593492wru.43.2022.07.13.11.03.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Jul 2022 11:03:50 -0700 (PDT) Message-ID: Date: Wed, 13 Jul 2022 20:03:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2 0/9] Add support for shared PTEs across processes To: Mike Kravetz Cc: Khalid Aziz , Andrew Morton , willy@infradead.org, aneesh.kumar@linux.ibm.com, arnd@arndb.de, 21cnbao@gmail.com, corbet@lwn.net, dave.hansen@linux.intel.com, ebiederm@xmission.com, hagen@jauu.net, jack@suse.cz, keescook@chromium.org, kirill@shutemov.name, kucharsk@gmail.com, linkinjeon@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, longpeng2@huawei.com, luto@kernel.org, markhemm@googlemail.com, pcc@google.com, rppt@kernel.org, sieberf@amazon.com, sjpark@amazon.de, surenb@google.com, tst@schoebel-theuer.de, yzaikin@google.com References: <20220701212403.77ab8139b6e1aca87fae119e@linux-foundation.org> <0864a811-53c8-a87b-a32d-d6f4c7945caa@redhat.com> <357da99d-d096-a790-31d7-ee477e37c705@oracle.com> <397f3cb2-1351-afcf-cd87-e8f9fb482059@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657735436; a=rsa-sha256; cv=none; b=6kP40u9jBkdR3Q1jPbHA9piOzay/psCo6zm3nDyTK7DaiO+Jefvkk4R2TWADnI6r23HJpE kB7lkhCKGVPO77cRRd1bK7CZoyR6mTiCH8z8CxZquZcDH5zcCBaCq1N9Taeh3tAyFkn54D Xw0iVR9ZQL5vRaHLyBsFEyhsf2ek6NM= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PpE0Z3De; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf04.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657735436; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qq4rbqh9j9QqFNAu6orBc1kOpVtgKyUJMzBlJDFOspE=; b=bj92Jki9v5bmachV7ZrPUGGLHDSUVkEcufjOeo2NCtivW7aIqRAkCj66Dv84U0G/gBH+j2 nkeSvROAwfdTFxVGay3X0NsY15EaRsYocGqHa0XwRbfcCC3giep5hJh/cpLu3IvdKccMRp D+SHKt7QYRGdJznf5Y/I6FM4Ew9ZBXY= X-Rspam-User: X-Stat-Signature: 35p5c8wk39ngsw7g75f8wgcaeajhy34e X-Rspamd-Queue-Id: 665E14003D Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PpE0Z3De; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf04.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam03 X-HE-Tag: 1657735436-603966 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 13.07.22 19:58, Mike Kravetz wrote: > On 07/13/22 16:00, David Hildenbrand wrote: >> On 08.07.22 21:36, Khalid Aziz wrote: >>> On 7/8/22 05:47, David Hildenbrand wrote: >>>> On 02.07.22 06:24, Andrew Morton wrote: >>>>> On Wed, 29 Jun 2022 16:53:51 -0600 Khalid Aziz wrote: >> >>> suggestion to extend hugetlb PMD sharing was discussed briefly. Conclusion from that discussion and earlier discussion >>> on mailing list was hugetlb PMD sharing is built with special case code in too many places in the kernel and it is >>> better to replace it with something more general purpose than build even more on it. Mike can correct me if I got that >>> wrong. >> >> Yes, I pushed for the removal of that yet-another-hugetlb-special-stuff, >> and asked the honest question if we can just remove it and replace it by >> something generic in the future. And as I learned, we most probably >> cannot rip that out without affecting existing user space. Even >> replacing it by mshare() would degrade existing user space. >> >> So the natural thing to reduce page table consumption (again, what this >> cover letter talks about) for user space (semi- ?)automatically for >> MAP_SHARED files is to factor out what hugetlb has, and teach generic MM >> code to cache and reuse page tables (PTE and PMD tables should be >> sufficient) where suitable. >> >> For reasonably aligned mappings and mapping sizes, it shouldn't be too >> hard (I know, locking ...), to cache and reuse page tables attached to >> files -- similar to what hugetlb does, just in a generic way. We might >> want a mechanism to enable/disable this for specific processes and/or >> VMAs, but these are minor details. >> >> And that could come for free for existing user space, because page >> tables, and how they are handled, would just be an implementation detail. >> >> >> I'd be really interested into what the major roadblocks/downsides >> file-based page table sharing has. Because I am not convinced that a >> mechanism like mshare() -- that has to be explicitly implemented+used by >> user space -- is required for that. > > Perhaps this is an 'opportunity' for me to write up in detail how > hugetlb pmd sharing works. As you know, I have been struggling with > keeping that working AND safe AND performant. Yes, and I have your locking-related changes in my inbox marked as "to be reviewed" :D Sheding some light on that would be highly appreciated, especially, how hugetlb-specific it currently is and for which reason. -- Thanks, David / dhildenb