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 9A501EE644D for ; Thu, 12 Sep 2024 06:18:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 139DF6B007B; Thu, 12 Sep 2024 02:18:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C3696B0082; Thu, 12 Sep 2024 02:18:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E57C36B0083; Thu, 12 Sep 2024 02:18:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C30746B007B for ; Thu, 12 Sep 2024 02:18:22 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 432331C5212 for ; Thu, 12 Sep 2024 06:18:22 +0000 (UTC) X-FDA: 82555081644.02.1B629CB Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) by imf10.hostedemail.com (Postfix) with ESMTP id 61AD1C0014 for ; Thu, 12 Sep 2024 06:18:19 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=T2mbPIkO; spf=pass (imf10.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.160.42 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726121760; 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=MAcwRzdYBVGpQvvsotib//4T0Ptv25mGEFNsz8/kzr4=; b=VhvWjx0fCsi8cR14Wi9qauOpQ09oDSmfHcfswKXrUYhWlGqizKd1Zere5aGfasL1iWiBsK jPFXRNDR0jaqbQ+a4/3NGkVZ/+R8xrkYM9B9AxsaK8UrWk8XSk5KOhBFmF/8igzirz7vLd Lhrd/8L904b48dknFuzITbCIlRoffHY= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=T2mbPIkO; spf=pass (imf10.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.160.42 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726121760; a=rsa-sha256; cv=none; b=xmTgijWoRyzt61gHJKKx9gtUZkNIkVUNmUwht1NfZDhGKB8HACrPJ7aJj7KEvLYlpVSAbi Roqa1kk+tCzOAfvDfEzRRasPtQlx6shqHNVTKvnM63vRANsOI4vfCX5UL10MZOxb2pOZh3 8xCGDxIfI5dXPgNMO1SDP+05xgFyQ88= Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-27b88b8a24aso291798fac.1 for ; Wed, 11 Sep 2024 23:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726121898; x=1726726698; darn=kvack.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=MAcwRzdYBVGpQvvsotib//4T0Ptv25mGEFNsz8/kzr4=; b=T2mbPIkO4zMqyNS+uHLSxG9E4EB1o6fnPGidRRyDOZPPjYbJ3Rkc3+mIKbjOu9Myyp zLWonlozLHgyDwsJHmaXhodnP/qeCHKLe3Uy+06FcN+1SRhHKOOyoMNZkaUcOwAGS/Oe 6m1zijSfKecwSgtBV6wwc/doFa0jjGBuu2HLvJFUS4Yov8yLn4FQqM5Lr/3QGRj3Hh9y zTmWu57VnXGfIHytTwFOpzqA9+EXmWOgSOtQtacELWVH/ycriwqoEi9wULEny+kbrD0F txBvi45qcro6I/4JR5hoG6jOIRpv4pS6X/tq7GwOSPF9vEGhiLq0jQ5insLYUvQPfe0S AjTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726121898; x=1726726698; h=in-reply-to:content-transfer-encoding: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=MAcwRzdYBVGpQvvsotib//4T0Ptv25mGEFNsz8/kzr4=; b=QSIzRxjpxjKsFcAWQ8Wmf78Nw0HrdBBUGH9grdHulXHX+vZcanJ9WOvgEAqLHOrUmf dZLpfP/u5O7mQd+pDnC0bDXm5hEdVvZINx5s4XiYv7HcnlVIgkxdfSa5BoiWG+W2pR0p zlta0JGcvnYGEGZrUtBxlkv0R1HkhE5+u71RNdZ8oHMIjs420/UVCNdHXQlGRcc/WawP GA9zZUa2f/SK5yKPTYUHxf01l7Xemsrg00y8HkglEtCCXVGJ3xDlD0xxHVtRgGAEVWE0 hv9nPPJic58hGhuQHJBKx5x85I165KFdm0xJumcdilP+bkMvvB9J+rE03q0/ym8MhPFb srgw== X-Forwarded-Encrypted: i=1; AJvYcCWuZjE6bPyVxLmBip1z2sCjeOSPxkZyhqQTW4ub10JahomuChM7j9G1ZHaymH+5nmy8l8xe1mDPiQ==@kvack.org X-Gm-Message-State: AOJu0YwtC80KHV6wtTeMUwGeZ+tkmVxGHEMmr8FbFA85C3lwMDslZYz4 jXVcy1Qg/SxeYmUmzAojKWXqyZcZlb3srfAnUdb6bBBs7ISJb9Uu2b72sz9OpUU= X-Google-Smtp-Source: AGHT+IH1u/BITj52DSA2KLJ5czFa7HaODYxdqRl9mmjp1F3evKXCtYQOfdJUyouLtu9doLCVCxJHIA== X-Received: by 2002:a05:6870:910f:b0:277:eb68:2878 with SMTP id 586e51a60fabf-27c3f6a6e6emr1295326fac.44.1726121898162; Wed, 11 Sep 2024 23:18:18 -0700 (PDT) Received: from ghost ([2601:647:6700:64d0:7acc:9910:2c1d:4e65]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7190f888a78sm3692711b3a.140.2024.09.11.23.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 23:18:17 -0700 (PDT) Date: Wed, 11 Sep 2024 23:18:12 -0700 From: Charlie Jenkins To: Catalin Marinas Cc: "Liam R. Howlett" , Arnd Bergmann , guoren , Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Russell King , 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 , Vlastimil Babka , Lorenzo Stoakes , shuah , Christoph Hellwig , Michal Hocko , "Kirill A. Shutemov" , Chris Torek , Linux-Arch , 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, linux-abi-devel@lists.sourceforge.net Subject: Re: [PATCH RFC v3 1/2] mm: Add personality flag to limit address to 47 bits Message-ID: References: <20240905-patches-below_hint_mmap-v3-0-3cd5564efbbb@rivosinc.com> <20240905-patches-below_hint_mmap-v3-1-3cd5564efbbb@rivosinc.com> <9fc4746b-8e9d-4a75-b966-e0906187e6b7@app.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 61AD1C0014 X-Stat-Signature: 6xmayse4zshnmhkdpd3natofo4x66nmn X-Rspam-User: X-HE-Tag: 1726121899-604595 X-HE-Meta: U2FsdGVkX1+WNhOmSbTGry2OX74XU2IrqMoQJDSLLN1GIdVXjIBSHVJCL0GaFOXmqM0RfXvNRdsc8pP6sqNr3PtHTrYXC0L62vW774wqNk1vWiwiXthh/3jj59ZWXA3KxGtz3uIK2AYhR0+q/lfppy6R00zDWJn2dgKc9fI0LZbZ0MFj1DIBthF1ofHYTdEto055t+zfqxNUmeI/TgujmGivEAXbcLIRUutteWqr43nOZI1tGAHBRwBUQWiunR5k23GyNC1z575QOrwQdVNbOPMKG43s9Ou4tE9WLHnsb8L8d2/LbyWpAdeXYO974eKCABrdey1dF3TLQH0HY3QR5JdlUHMKjRbc1EzQUOrqyHpezEu5cLi2N9E3sYjXjwbCKpMAFF3NXh2lLTIGoxUdLFIvDUiCX4yPyLhIv53Xmgq3uCZqaHEGaeXoZjYu0VEiocZHwHmNfBEdoz/Nxnyw2YR8fptEWT5t/Dd/mMXWcTWJYfmPdHH3Ij1NSnFgJrTaLXLiElo7OzGSkzg9hfRrRbvhFGFXXgtSa0f9Ep6EpDO94SHpzMfMje9TLx28gLiiEfrn6ne8i84OD57Me98LEvcsObTqPCpHm5o+SLXgqSXoNtip6JGFE/Xj2dWzJL3JvJ6yVKbOte5B6R6IqBumZxfFzcQAh9UikboL6bmwH1pJpzulUlbTho12HTPZKaAP1D59lTojDIBF78KbNJB/JhafmLhLKHKw3hbF1/1BCoDS0g21LQEXNTdzSi8z1Hk9HXSzk0JKuw5UIkldeix6LqHh0DrntiYpbd5Dvyzu3kH4V7gBArgGiYDDbuvmXxUqX+AGln2mc6vYC2Jxa/wZw/lqgCVlxvlgVvz3ZwvghHj2KB6q0TA4K3w4Eqi+kJFlbjCIQ0g3z7F0BVpR/p3EEuGA/XX+w2rHkTcudrp4zxZbq3eg5ZhBXoi1WTQtoeXuRe4H6U61KfImfhCUXDT CHJE/AjO pDStI2H9GKAkvWtqUs1QMBP9QJWO1RymQYpgftPgCWWpR7jAtCo2tAaT9zCRKCjTzuGAM6MAZVWebiM0Cx6iIFT13c/jeVqTMr8DVr4Z45eFkHYUWft2p9/wjKwjKLIcx/pzUOMYMopiYhHpZBmTTlnSj8Iui4nSexR74EFmcXaFXhx766xwogXc6WTXUR44DyfT35DZu/SCHilkOrE5VGveGBwgO6b1BSly3wzCA6FIA0+eJJGFqm6+M1AN3Ym8nTlGtPLs3EQ/AFLhWd5uYIynutYb1/a0463j1PF6lutbqURsRaVngkKE136c9hxCXWWjU1swDkO3bz7V3R1KqhFfYPIGHWO1ZPL+gcobLIxhnidfTidD8cSw2d/pRls8Moyq5mFVBnMjFfWbZI9zrsC/Fg5GAOCsKImKKNQ1Ng0YIYwlceMn6ash/TD+dUeKZWtDhlxfU+XaWa6Lqid8Ry82rSqItFOxVHnR46nmmuA1rNwtS74Lb+coEDhtDi77vw+72XnYM4/7R2zSALNsgExC68mUOl1gS3wWfIeAjF4eue4BsqN5VA7rQhequKSSrhoTTQOs3RYmXcGhRUJtFzDMrJqkNVL8PIHnO4JwmyCvckn1hz1lDeROyXF3TC8gCJ8o+ 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 Wed, Sep 11, 2024 at 07:21:27PM +0100, Catalin Marinas wrote: > On Tue, Sep 10, 2024 at 05:45:07PM -0700, Charlie Jenkins wrote: > > On Tue, Sep 10, 2024 at 03:08:14PM -0400, Liam R. Howlett wrote: > > > * Catalin Marinas [240906 07:44]: > > > > On Fri, Sep 06, 2024 at 09:55:42AM +0000, Arnd Bergmann wrote: > > > > > On Fri, Sep 6, 2024, at 09:14, Guo Ren wrote: > > > > > > On Fri, Sep 6, 2024 at 3:18 PM Arnd Bergmann wrote: > > > > > >> It's also unclear to me how we want this flag to interact with > > > > > >> the existing logic in arch_get_mmap_end(), which attempts to > > > > > >> limit the default mapping to a 47-bit address space already. > > > > > > > > > > > > To optimize RISC-V progress, I recommend: > > > > > > > > > > > > Step 1: Approve the patch. > > > > > > Step 2: Update Go and OpenJDK's RISC-V backend to utilize it. > > > > > > Step 3: Wait approximately several iterations for Go & OpenJDK > > > > > > Step 4: Remove the 47-bit constraint in arch_get_mmap_end() > > Point 4 is an ABI change. What guarantees that there isn't still > software out there that relies on the old behaviour? Yeah I don't think it would be desirable to remove the 47 bit constraint in architectures that already have it. > > > > > > I really want to first see a plausible explanation about why > > > > > RISC-V can't just implement this using a 47-bit DEFAULT_MAP_WINDOW > > > > > like all the other major architectures (x86, arm64, powerpc64), > > > > > > > > FWIW arm64 actually limits DEFAULT_MAP_WINDOW to 48-bit in the default > > > > configuration. We end up with a 47-bit with 16K pages but for a > > > > different reason that has to do with LPA2 support (I doubt we need this > > > > for the user mapping but we need to untangle some of the macros there; > > > > that's for a separate discussion). > > > > > > > > That said, we haven't encountered any user space problems with a 48-bit > > > > DEFAULT_MAP_WINDOW. So I also think RISC-V should follow a similar > > > > approach (47 or 48 bit default limit). Better to have some ABI > > > > consistency between architectures. One can still ask for addresses above > > > > this default limit via mmap(). > > > > > > I think that is best as well. > > > > > > Can we please just do what x86 and arm64 does? > > > > I responded to Arnd in the other thread, but I am still not convinced > > that the solution that x86 and arm64 have selected is the best solution. > > The solution of defaulting to 47 bits does allow applications the > > ability to get addresses that are below 47 bits. However, due to > > differences across architectures it doesn't seem possible to have all > > architectures default to the same value. Additionally, this flag will be > > able to help users avoid potential bugs where a hint address is passed > > that causes upper bits of a VA to be used. > > The reason we added this limit on arm64 is that we noticed programs > using the top 8 bits of a 64-bit pointer for additional information. > IIRC, it wasn't even openJDK but some JavaScript JIT. We could have > taught those programs of a new flag but since we couldn't tell how many > are out there, it was the safest to default to a smaller limit and opt > in to the higher one. Such opt-in is via mmap() but if you prefer a > prctl() flag, that's fine by me as well (though I think this should be > opt-in to higher addresses rather than opt-out of the higher addresses). The mmap() flag was used in previous versions but was decided against because this feature is more useful if it is process-wide. A personality() flag was chosen instead of a prctl() flag because there existed other flags in personality() that were similar. I am tempted to use prctl() however because then we could have an additional arg to select the exact number of bits that should be reserved (rather than being fixed at 47 bits). Opting-in to the higher address space is reasonable. However, it is not my preference, because the purpose of this flag is to ensure that allocations do not exceed 47-bits, so it is a clearer ABI to have the applications that want this guarantee to be the ones setting the flag, rather than the applications that want the higher bits setting the flag. - Charlie > > -- > Catalin