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 20E28CD6E56 for ; Thu, 5 Sep 2024 17:27:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AB2C6B0098; Thu, 5 Sep 2024 13:27:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65AAD6B0099; Thu, 5 Sep 2024 13:27:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 549756B009A; Thu, 5 Sep 2024 13:27:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 36E266B0098 for ; Thu, 5 Sep 2024 13:27:02 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CAE3180119 for ; Thu, 5 Sep 2024 17:27:01 +0000 (UTC) X-FDA: 82531365042.16.34DF97F Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf21.hostedemail.com (Postfix) with ESMTP id D36B01C0007 for ; Thu, 5 Sep 2024 17:26:59 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=TmRyjwXp; dmarc=none; spf=pass (imf21.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725557111; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TzHtjVKsvMG2J+VEdT3JJ4mY+8euHciuRxZ037YJyIs=; b=DhEw7FJjG3FBtL2FcZqBDa3N/sVUoITtdHbqwgaKTw2LveC45+jXtFrLTOZA9K5ozTBYtx /WkPyMU0UP9A6zTUI55/KVf+xmTIyOikYciYkxQrfoiMYh9oIQei64jReVfGFgap3TkCCq 2nCvdyzU/WI4h43UDdkP/CvjUC5cLWs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725557111; a=rsa-sha256; cv=none; b=2XWipMHi8eC6MesldqQy021NjRQvRh9uQpyH+RF9SsJofCSMpzb6nyiubylxrciqxVU0FT 68auHwtxFRdyZsB+2FtWBnr/1oOEHCGzsyqopnI7nu7yQx5SxEESTpc4ri/HDFQRA21A0Y iutZIkIiuEWRwYv37ly9NtBr3jWoAvA= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=TmRyjwXp; dmarc=none; spf=pass (imf21.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=charlie@rivosinc.com Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2d87176316eso1658968a91.0 for ; Thu, 05 Sep 2024 10:26:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1725557218; x=1726162018; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TzHtjVKsvMG2J+VEdT3JJ4mY+8euHciuRxZ037YJyIs=; b=TmRyjwXpNDivpOrKkKsO0AraqTAlphZCdsxwYKkTSfnSOSpkte7KY02IOC/jft/m2I aB33OfMvSlLO+/s9dNXtxz3BqlxHd5BW71hgk0VNNmVR9M22EMtOWu16HYS/wnvkZ1Ok zKNTblU48iITZPGc2dX6ljp0A6gw5cqnpaGYcW8G1ql+bjPFCdWY1sPaf7jLFRH1Hdhq vGiOdHfhhx4WTLep7qKc/9k2EDFRbyEl0gcbuYc50TBN1pl3ziIaC4ac3oPn9s0Ogyk/ 2975bRftsJct7kad84UiSfmx6pxxzBN2vIE5lo/ekuAc+f2I6U4RnTLAesCNF1JkuJR2 7NQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725557218; x=1726162018; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TzHtjVKsvMG2J+VEdT3JJ4mY+8euHciuRxZ037YJyIs=; b=r5QdwdLp3uQE024wm8NZ0D/cHbQEsPzjG/D1fexyBivlN1UvUiE9/tntruc19cHBfK M0c0vEvGT1PX/aVRWIl5MxkBiGMoMvdSKgDDgB8k4eXhM55LnvihlgTZP7cCa4Gp3l16 2wntvlm4kX6ZTJ4SkYPeHrxKWbEQxHdz/RGdE1iqbS7Z4lwKWx9OVQJ/COMkqFeAkHAC WlwX6xxNPD4CF68sxpqbma88sP36W/7f/PHilB4DQsG2ZplDPpN3YgjLwoKciidJtr0p fWfMYn0o0oB4dq0vn0iNNn1L92TnBOQxAfanmb1Tq337B+O8LzlfT4zI83+88FZXAtiv nXBg== X-Forwarded-Encrypted: i=1; AJvYcCUmV6fB0iphrWrZfok7M69EHHGfnc+Smycvp9GSCTAA+bRlNSeRjtza0XDLbxAez6Ou/gOgvpPy/A==@kvack.org X-Gm-Message-State: AOJu0YwBXPvhZLpYDzjcDJM+KmuFZcpNWVxxHI1GgAP03X10PLR0/3Gs euv24GM9i3muEdzlnXphJcaAJf7MymCMlNAbG0Im0JgJABtgVaN1DuwqTiXZM2M= X-Google-Smtp-Source: AGHT+IFxrgWNtdxCWG0RBGHbyeqfO4T1K/TMURzEB4vAspGF/eaSh/6stCCkbbdo5V+yBGPBQxqCJA== X-Received: by 2002:a17:90b:3d2:b0:2d8:9fbe:6727 with SMTP id 98e67ed59e1d1-2dad4f0e4damr67155a91.4.1725557218097; Thu, 05 Sep 2024 10:26:58 -0700 (PDT) Received: from ghost ([50.145.13.30]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2da5932d1ecsm6506552a91.43.2024.09.05.10.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 10:26:57 -0700 (PDT) Date: Thu, 5 Sep 2024 10:26:52 -0700 From: Charlie Jenkins To: "Kirill A. Shutemov" Cc: Arnd Bergmann , Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Russell King , Guo Ren , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , "David S. Miller" , Andreas Larsson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Muchun Song , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , Shuah Khan , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH RFC v2 0/4] mm: Introduce MAP_BELOW_HINT Message-ID: References: <20240829-patches-below_hint_mmap-v2-0-638a28d9eae0@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D36B01C0007 X-Stat-Signature: bkn659n16ziyskrkn6odpwymkrcrdwtp X-Rspam-User: X-HE-Tag: 1725557219-79277 X-HE-Meta: U2FsdGVkX1+IwTyvP64c0tU28BYvX1bfN/epU2BIhmbJH8IuNqoMEbwpxQWCr7yJobMp/aDCQdWFIl0v0BDC0rN+p0G38QW76TaE7KxIIocKqU5dF3buhM01ScAJyoI8E/tOCl0/CTIlQYNfnrq4SbXUT0+Y6wGobuFPvhvKgjmAhcyoO0Eb6anSQ+9FZJ2fZV04iyKMFdVKzr/317gVg+mM4v62ijbMI0qDuxgVAxnE9t9O6qblUieQs516fpR0vMzk+67yHESo01YM0PZB0p5jDE/Nqbk8/2LIxcay0saNUi2qr4oonDZjBplyNSBucmlAHIJMeovAD2rTR79Yi/E8dX80f55d0XZxEbcO2txIVAtRAPbfwVeqSu4fAvGtNnTwTm24fFrfSZjKImgDZbbvxgpZxh1nBDIja/oNYcP1RO58Z7KptTVcG9Su53YUd1MoYgTx53cyzXa4983nocfyrtE5/0NtI6rtvivmrhph3F2vbOOsFLLUr+MN1oVA30+0mJNcpKxCPOD6+IF+bBjJNR2IeD33BuXUyTy/MuQlOl92DneEDFW1rpSmWtxnxHSM2PeXFD8mBslGVkj5WzjJCkgny2AnUSJSo+JUXN1vXOOsGb27ggnrYhV5oE1Zcj+8S+UY8yTm/grb+BZMlPfxtT+/LnEj1xhgKunBrEfy2YEJiRobx/Wngrek/SwloIvcIed2DW72ZpTBmX6zqTQEyXBrGKwNlxJ9yrKSZvXNAdaQvV1g7Cyp4M8To3z8E/w0NkTUgFGQzmZoeReVAPQUWO5BgXrBJTslykgVbiX+qi3ZFvI9IUpkGDW6cuLsxfNVvwXokDgJ4+31soSn0KLDCvLRRbKblq7gtdy0QKr8ecdpqGJcE1Gb3SIHR1qgrj9gFW/I57XlcEz6oIxnwSxGdJuRrli+718w4pU2Wx2qnKbjiLvYLK/FvjG2QNcd5SgAgH9pr9RFbjrQiuf OwvZlf9+ 23QKX75i8qPXLswAgP7Dr0+lyE9XLGkjEvD3se5lK3b18X/k7dfQwVVJE9K2EQkUQBG2a3xJP9tm9DMQpHpHKuKGPDzUrDHektUrFKTfmbteqiso4KA4exC8nm+A4tfGw4W3GmJjMMhSGEYKStOBrEGIkhFU+oiYrUDKfw4J5whGBck11uM1pfh/NNtus8j51O9Kds+0wr26NhEA1JkvsBJZ09w3XRectm5A9dLjKI+UfNWyczvYBD6vGM9OjZ9V/pncIReFXDiDdCGI1Lx+CPfiurhAhtGhiUyBJ4sPYgw3fPASty6udeTUNp3ic4LBs4pKPGVCbFz2QkGcAhNKNRyDGxwEOpCOAoCTSc+FJ5Dh9tGKJWBUFpH6hauTVpk0ed4Hf60Ehi9FRuPW+TKMS8vWmFg== 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: List-Subscribe: List-Unsubscribe: On Thu, Sep 05, 2024 at 09:47:47AM +0300, Kirill A. Shutemov wrote: > On Thu, Aug 29, 2024 at 12:15:57AM -0700, Charlie Jenkins wrote: > > Some applications rely on placing data in free bits addresses allocated > > by mmap. Various architectures (eg. x86, arm64, powerpc) restrict the > > address returned by mmap to be less than the 48-bit address space, > > unless the hint address uses more than 47 bits (the 48th bit is reserved > > for the kernel address space). > > > > The riscv architecture needs a way to similarly restrict the virtual > > address space. On the riscv port of OpenJDK an error is thrown if > > attempted to run on the 57-bit address space, called sv57 [1]. golang > > has a comment that sv57 support is not complete, but there are some > > workarounds to get it to mostly work [2]. > > > > These applications work on x86 because x86 does an implicit 47-bit > > restriction of mmap() address that contain a hint address that is less > > than 48 bits. > > > > Instead of implicitly restricting the address space on riscv (or any > > current/future architecture), a flag would allow users to opt-in to this > > behavior rather than opt-out as is done on other architectures. This is > > desirable because it is a small class of applications that do pointer > > masking. > > This argument looks broken to me. > > The "small class of applications" is going to be broken unless they got > patched to use your new mmap() flag. You are asking for bugs. > > Consider the case when you write, compile and validate a piece of software > on machine that has <=47bit VA. The binary got shipped to customers. > Later, customer gets a new shiny machine that supports larger address > space and your previously working software is broken. Such binaries might > exist today. > > It is bad idea to use >47bit VA by default. Most of software got tested on > x86 with 47bit VA. > > We can consider more options to opt-in into wider address space like > personality or prctl() handle. But opt-out is no-go from what I see. > > -- > Kiryl Shutsemau / Kirill A. Shutemov riscv is in an interesting state in regards to this because the software ecosystem is much less mature than other architectures. The existing riscv hardware supports either 38 or 47 bit userspace VAs, but a lot of people test on QEMU which defaults to 56 bit. As a result, a lot of code is tested with the larger address space. Applications that don't work on the larger address space, like OpenJDK, currently throw an error and exit. Since riscv does not currently have the address space default to 47 bits, some applications just don't work on 56 bits. We could change the kernel so that these applications start working without the need for them to change their code, but that seems like the kernel is overstepping and fixing binaries rather than providing users tools to fix the binaries themselves. This mmap flag was an attempt to provide a tool for these applications that work on the existing 47 bit VA hardware to also work on different hardware that supports a 56 bit VA space. After feedback, it looks like a better solution than the mmap flag is to use the personality syscall to set a process wide restriction to 47 bits instead, which matches the 32 bit flag that already exists. - Charlie