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 C4B20CCF9EB for ; Thu, 26 Sep 2024 01:49:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5ABD66B00B4; Wed, 25 Sep 2024 21:49:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55AE76B00BF; Wed, 25 Sep 2024 21:49:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FC036B00D2; Wed, 25 Sep 2024 21:49:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1F0BD6B00B4 for ; Wed, 25 Sep 2024 21:49:04 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D3EE7ABECD for ; Thu, 26 Sep 2024 01:49:03 +0000 (UTC) X-FDA: 82605206166.11.FA71882 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id 2308EC0007 for ; Thu, 26 Sep 2024 01:49:01 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dX5sgYBo; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of jarkko@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jarkko@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727315326; a=rsa-sha256; cv=none; b=uE9CE/zsrnyMTYWnf4p/01Kf5P1XIYobg73cboK9dHgsWgS7/Ghz5Qxvmh/OP4WoCaN1Ds XfXu+rTExS5R5xMNnNYhXsM//oVzsJV3LlSzUwudXCBCvYH/3RYeqDnh2/wIbmpLTrru4G PgqDT7PsRyKW2YgzMrdkLHq/BepVPSo= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dX5sgYBo; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of jarkko@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jarkko@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727315326; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=H8juGeCViGTm1bIc/cdL2BSa7Jvw3B3ONt+9KpofNg4=; b=38C355gldXmb+abdOSoygv5liab4U1OmkXWDe8QrDaCZ3S591BN1HaQuKr9CMwaPS0RjLh am6wyGuUz6OGZqHCyfxKM5xGpFqIfg+lr2HY9iK3F4Iyya0u9Qh6W5ZsYb+3YrJaY8Q0Zx YxcwytkJ7ysizRmrv0UqpR8w1i2AePU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F00F55C5663; Thu, 26 Sep 2024 01:48:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4383CC4CEC3; Thu, 26 Sep 2024 01:49:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727315340; bh=bGGN0MlFRdWr6XSSQfBysbQYemUhBKtd0dP6ORgAqFs=; h=Date:To:Subject:From:References:In-Reply-To:From; b=dX5sgYBomN5MZPkc7m6dkphOKDQHxZsRLAzl5uoa13847qGBg0TLhUm6xdk98aGpN yE+usoXxzrLfTdjJhze4MNuvYOnLhXyIKzOEiqMALmjkWRRsua9s3XYaPKfoRgFMHZ ZgXEmJ+WDSQU9NIn1GaD0lAe4rx6lN/eR9GAGXjfN0w038ij64rW9I/qIuAvSszwRf AREckmgXX4k1CFb+/p5ZxWg0SgMNlr9aWz3LYejRRJoSKij7ZnMqdrJB5VVXNZg+NX tOWk8UE4kKRAC76Kiy0YAwrCRQvBMB5bE0KBBV/YTYuzRwyOZDutnolosQesntyb0A QBTORQyDDM94g== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 26 Sep 2024 04:48:56 +0300 Message-Id: To: "Jarkko Sakkinen" , "Huang, Kai" , , Subject: Re: VMA merging updateds? From: "Jarkko Sakkinen" X-Mailer: aerc 0.18.2 References: <51631b6d-5138-4195-8722-651d9ea79dc1@intel.com> In-Reply-To: X-Rspam-User: X-Stat-Signature: m1i8opij7uby6ihmpaxjbms4zsr8b3jg X-Rspamd-Queue-Id: 2308EC0007 X-Rspamd-Server: rspam02 X-HE-Tag: 1727315341-115570 X-HE-Meta: U2FsdGVkX19Qepti5TWM0cexoFzD4pJQ6DyxuOcXgnt5VB7n1POVFQmO8ksahS8frpHH0B6a1Qq1K5rb3Jwp4d7z41WhHHKRbyphZnR/IbAm01FDHDlzLFocJOnh5c3l0AAEUTJPsvIjaM05LkJfJcb/OpCz8QvUvSfg+CmsBOGK1RUsH4cy/5wDhbHAHB1r2zOUG67U+PbzJbwnWjOofl+PybqJH5zs3/oh44k6iORDjIR5nhu3PUttvgBZgnKyRFqTm+gD1iP+EaSK1jpUzvw3/NcAt+Vmt8JlpTiYLfWhsSWrl2iHSLSESeWv6O1o9/Uf67RnkDfN+X3sEddRX2BAfbkQCLwZPCY9Ry8edyr7pVKOhhb49L0yCvxnebuBXIFTK04WUnCcTVxPbVBiqsuqbZCVsegrkghYHshOJNQ3OIBBn4VHAw7q/wHceKpagA+N5943k7myORmj7iym3g3WLdJUKbVBVf409+iMWZ64NAVdptIaxVvGnSw3Q67a8r3RN5qv6rzXHsdSOsInc0/vH9nUThcQ7i9Lis6lfbiIA9sKuzCHcdl3BMfhf9hSrijdegFUIWwW5dFOjOwp0curyn63WJDBEsQD76peaRpmUSwfAHivwC+stk6CNJqIZLEWRRKkcPWFzmMfo01MUsoI43so5IoBHvYmuvL8395jHq5Qx/LHmzZUAXLYAppwJCJ8NvTZXqbhhVJMb4d1p1+7WtRyhUlQ2BzZJyZ+iI0L24h7pZamEOx5zDbpHDbP2mnM3jvJmcD5YVIQnrrquRGWuWC5AdnhYj36Gq17HuBaWAq6o4FCISZDjyjbr7co5cS0bosLuARVR6aegh4r2GIWM27Y7PWrUxIRNJGMPquqB2SpSamz42/6XUf3j5qMuTWJZNDQLvMQBR8iuNvLwrHAW+D6McAaMwWcCuGXxSeScN5xW0eRYmj2tuIhgy/rTsTcFlZ8pnhWRDhrI6T 1cWa8Vh+ BJc3FxDqc4PTMXJPffQLKlUOK4HliEXBuYPQ3EDBgrgZtfuM4MGXAEaORyAqMWoIcwjaH3806oi2zymlk/n3nKvgBObsFkwNtzWqG3ptYZth+qFIQaZ2/U29FjoLZqK34ldfYEyGbI7NMz6zkYsVbWhsV5m1sS9zrEMT/oHlegKVfK/ivxCbnla3RDIfcnySX1BMkU+hQMR4LSoMOrHH2CEI9mBgg1uYYaef3p5+CiWCR6o4Je9f3fK4izHJ3pbmkiGwlrt3hRXIhWv22gvgtm7CdOkc+xfObhfjPaSjpe6RGPFX17zIJ/9MvWg+RoSHL0vuP/ZQy9fPzyamEKnO1NhhmGQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.001278, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu Sep 26, 2024 at 4:47 AM EEST, Jarkko Sakkinen wrote: > On Thu Sep 26, 2024 at 3:38 AM EEST, Kai Huang wrote: > > > > > > On 26/09/2024 12:33 pm, Jarkko Sakkinen wrote: > > > On Thu Sep 26, 2024 at 3:07 AM EEST, Kai Huang wrote: > > >> > > >> > > >> On 23/09/2024 7:48 pm, Jarkko Sakkinen wrote: > > >>> On Sun Sep 22, 2024 at 7:57 PM EEST, Jarkko Sakkinen wrote: > > >>>>> On Sun Sep 22, 2024 at 7:27 PM EEST, Jarkko Sakkinen wrote: > > >>>>>> Hi > > >>>>>> > > >>>>>> I started to look into this old issue with mm subsystem and SGX,= i.e. > > >>>>>> can we make SGX VMA's to merge together? > > >>>>>> > > >>>>>> This demonstrates the problem pretty well: > > >>>>>> > > >>>>>> https://lore.kernel.org/linux-sgx/884c7ea454cf2eb0ba2e95f7c25bd4= 2018824f97.camel@kernel.org/ > > >>>>>> > > >>>>>> It was result of brk() syscall being applied a few times. > > >>>> > > >>>> Briging some context here. This can be fixed in the run-time by bo= ok > > >>>> keeping the ranges and doing unmapping/mapping. I guess this goes > > >>>> beyond what mm should support? > > >>>> > > >>>> I thought to plain check this as it has been two years since my la= st > > >>>> query on topic (if we could improve either the driver or mm someho= w). > > >>> > > >>> In the past I've substituted kernel's mm merge code with user space > > >>> replacement: > > >>> > > >>> https://github.com/enarx/mmledger/blob/main/src/lib.rs > > >>> > > >>> It's essentially a reimplementation of al stuff that goes into > > >>> mm/mmap.c's vma_merge(). I cannot recall anymore whether merges > > >>> which map over existing ranges were working correctly, i.e. was > > >>> the issue only concerning adjacent VMA's. > > >>> > > >>> What I'm looking here is that can we make some cosntraints that > > >>> if satisfied by the pfnmap code, it could leverage the code from > > >>> vma_merge(). Perhaps by making explicit call to vma_merge()? > > >>> I get that implicit use moves too much responsibility to the mm > > >>> subsystem. > > >>> > > >> > > >> Hi Jarkko, > > >> > > >> Just want to understand more on the background: > > >> > > >> Are you seeing any real problem due to needing a lot of mmap()s to t= he > > >> same enclave, or it is just a problem that doesn't look nice and you > > >> want to resolve? > > >> > > >> I mean, this problem doesn't seem to be SGX-specific but a common on= e > > >> for VMAs with VM_PFNMAP (any bit in VM_SPECIAL), e.g., from random > > >> device drivers with mmap() support. We will need a good justificati= on > > >> if we want to make any core-mm change, if any, for this. > > >=20 > > > It requires essentially replicating core mm in user space. > > >=20 > > > > Is there any real problem if we don't do this at all (neither in core m= m=20 > > nor in userspace)? > > 7f8f00000000-7f8f00009000 r--s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f00009000-7f8f00034000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f00034000-7f8f000ff000 r-xs 00000000 00:05 84 = /dev/sgx_enclave > 7f8f000ff000-7f8f00201000 ---p 00000000 00:00 0 > 7f8f00201000-7f8f003fc000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f003fc000-7f8f003fd000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f003fd000-7f8f00400000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f00400000-7f8f00643000 r--s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f00643000-7f8f0197b000 r-xs 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0197b000-7f8f01bab000 r--s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f01bab000-7f8f01fa7000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f01fa7000-7f8f08000000 ---p 00000000 00:00 0 > 7f8f08000000-7f8f08001000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08001000-7f8f08003000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08003000-7f8f08006000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08006000-7f8f0800b000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0800b000-7f8f08014000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08014000-7f8f08025000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08025000-7f8f08046000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08046000-7f8f0804a000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0804a000-7f8f0804b000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0804b000-7f8f0804c000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0804c000-7f8f0804d000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0804d000-7f8f0804e000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0804e000-7f8f0804f000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0804f000-7f8f08050000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08050000-7f8f08051000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08051000-7f8f08052000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08052000-7f8f08053000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08053000-7f8f08054000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08054000-7f8f08055000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08055000-7f8f08056000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08056000-7f8f08057000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08057000-7f8f08058000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08058000-7f8f08059000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08059000-7f8f0805a000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0805a000-7f8f0805b000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0805b000-7f8f0805c000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0805c000-7f8f0805d000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0805d000-7f8f0805e000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0805e000-7f8f0805f000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0805f000-7f8f08060000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08060000-7f8f08062000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08062000-7f8f08063000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08063000-7f8f08064000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08064000-7f8f08065000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08065000-7f8f08066000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08066000-7f8f08067000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08067000-7f8f08068000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08068000-7f8f08069000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08069000-7f8f0806a000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0806a000-7f8f0806b000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0806b000-7f8f0806c000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0806c000-7f8f0806d000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0806d000-7f8f0806e000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0806e000-7f8f0806f000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0806f000-7f8f08070000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08070000-7f8f08071000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08071000-7f8f08072000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08072000-7f8f08081000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08081000-7f8f08082000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08082000-7f8f08083000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08083000-7f8f08084000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08084000-7f8f08085000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08085000-7f8f08086000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08086000-7f8f08087000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08087000-7f8f08088000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08088000-7f8f08089000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08089000-7f8f0808a000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0808a000-7f8f0808b000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0808b000-7f8f0809a000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0809a000-7f8f0809c000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0809c000-7f8f0809d000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0809d000-7f8f0809e000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0809e000-7f8f080a0000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f080a0000-7f8f080a3000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f080a3000-7f8f080a9000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f080a9000-7f8f080b5000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f080b5000-7f8f080c0000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f080c0000-7f8f080c6000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f080c6000-7f8f080d1000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f080d1000-7f8f080dd000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f080dd000-7f8f080f4000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f080f4000-7f8f08121000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08121000-7f8f0814a000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f0814a000-7f8f08162000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08162000-7f8f08177000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08177000-7f8f081a0000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f081a0000-7f8f081c1000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f081c1000-7f8f081d6000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f081d6000-7f8f081ff000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f081ff000-7f8f08228000 rw-s 00000000 00:05 84 = /dev/sgx_enclave > 7f8f08228000-7f8ffffff000 ---p 00000000 00:00 0 > 7f8ffffff000-7f9000000000 rw-s 00000000 00:05 84 = /dev/sgx_enclave Just giving ridiculous answer to a ridiculous question. You clearly started commenting w/o reading the original thread. BR, Jarkko