From patchwork Thu Aug 29 07:15:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13782676 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 40CD9C7EE31 for ; Thu, 29 Aug 2024 07:16:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C35F76B00BC; Thu, 29 Aug 2024 03:16:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BBC226B00BE; Thu, 29 Aug 2024 03:16:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0E8B6B00C0; Thu, 29 Aug 2024 03:16:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7EF746B00BC for ; Thu, 29 Aug 2024 03:16:20 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 25854409D2 for ; Thu, 29 Aug 2024 07:16:20 +0000 (UTC) X-FDA: 82504424520.26.8F9D738 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by imf11.hostedemail.com (Postfix) with ESMTP id 1EEAF4002C for ; Thu, 29 Aug 2024 07:16:17 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=cwxzA9EH; spf=pass (imf11.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.215.176 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=1724915689; 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=K+PlWd5TxPsjPig/hDVlAKKLZn98jtqGVu2vnt7YwwU=; b=ARgr1VlkJzfPPa9u4ZSwqYzrYq1eTn8QzhuXuWPBZkALdXLZg8LQIJ3/SOnOBtfTWRxw0/ 813eVJKQn3EWZXlhfaGh38weluVLR5cDy7l7USKmvC+pcZl9r+E4H6ZVDysIALOdcLMMug 8Viqd+GAD9r8bjWD5Wqyu+gnEsgbfSE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724915689; a=rsa-sha256; cv=none; b=428DrVc70tIrMDsqgPOr4CuFyd9aMoox2mlfgk7JCsa0OiFkv+svSSyJ8S16PkoJU8ODEo XUevG5IHscfvaQm1JvPr8TWiZZn87/DHfGhK/ZSIdA6DD7xF68bLsefgXMkMsECtZrqGJ/ dsYWyFD+4UNA5aRu4Zeao0xKK3FpkLo= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=cwxzA9EH; spf=pass (imf11.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.215.176 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-7ae3d7222d4so204778a12.3 for ; Thu, 29 Aug 2024 00:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724915777; x=1725520577; darn=kvack.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=K+PlWd5TxPsjPig/hDVlAKKLZn98jtqGVu2vnt7YwwU=; b=cwxzA9EHbnyAyS60GWO/EfFBPeVzF5gFASuQaDD6XgnDwPNxCdFiKvdo/GAotmdII4 kfNPsOTqR6VwtIL1JCd2PD25AdY8nmp3jbbMRv/rUMHbQMWnSTcx1CNNwVroDGFak9yU 4cNoSrpCxQ6NxGT2wuLFNlk+AOngizHlT/FaNm/zUyAPym3csc9Kf0eHfSEo5XCu8lgE ccajbtaBQHZN/6GK/SAH1mthTahhrN/hAkXx0W4ShIiVvFOIUUV533CASGSfAm2hNH6g NWaP67gxZIC6gErTLAYXMSQE5AoiltW3DQWlALiZ1R/7NucCYF37USx2Nv7MG1/U2kUt Q16A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724915777; x=1725520577; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K+PlWd5TxPsjPig/hDVlAKKLZn98jtqGVu2vnt7YwwU=; b=vIOmPwzySgWcgtoyL1MoA10A7Yt2nLkvJZag1EddU/BeO/PkL8PAUWBJRb3RQtIFk1 eoQUJ1odJDhoRQKOI8bXm5QiHnVROGkegcCFkJCHfX69rNC+tcQXILlVHq2Wk+8AXU/n cWomJUjvafbE5ELd8rLculOu2kwsA2M6CEUApfCpD2xAcLuZM9/lFxX+0Dtd9Mf4b6dE 1CmUeiIooaK+azaub1x9+tUp82RDY+CcRe1eBttrCmKgl/Bvzti3MxF/xvwQksr+y+9t J4OCB8V0vwOyn/51yPVkK/Gyo6LQEs/ZFD4AbPMQvxKBmp3DmrkCa+zCPDEiHMjFNY3+ Fg2Q== X-Forwarded-Encrypted: i=1; AJvYcCUm0n2ALVKwY/X6xEJHa/oJQ8s4d/9nyxpr7+XzMkF6YDU5qkG7tFjxjinLm+ZZVDFajtgcX7LUgg==@kvack.org X-Gm-Message-State: AOJu0Yw3PxgUI9MqQMCik/ORn7TNHEWXCNWmrngXwf0k1NN/Yspk/M6z gK/c0dYoKiL9GBSij1vz2sz00NRaU07cJtmsDTUWu/q+FQSZTdpbFupSkZ82ZwQ= X-Google-Smtp-Source: AGHT+IFLTY1yKSBMzZ5xgis43aJyn47zOLzwLd2defzztxCwj/TAmDuOoW0Odpywez2pOZ4X8GI8+g== X-Received: by 2002:a05:6a21:164e:b0:1c3:b16d:9ebf with SMTP id adf61e73a8af0-1cce10103d0mr1908062637.15.1724915776548; Thu, 29 Aug 2024 00:16:16 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7d22e9bef08sm581976a12.58.2024.08.29.00.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 00:16:15 -0700 (PDT) From: Charlie Jenkins Date: Thu, 29 Aug 2024 00:15:58 -0700 Subject: [PATCH RFC v2 1/4] mm: Add MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240829-patches-below_hint_mmap-v2-1-638a28d9eae0@rivosinc.com> References: <20240829-patches-below_hint_mmap-v2-0-638a28d9eae0@rivosinc.com> In-Reply-To: <20240829-patches-below_hint_mmap-v2-0-638a28d9eae0@rivosinc.com> To: 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 Cc: 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, Charlie Jenkins X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1708; i=charlie@rivosinc.com; h=from:subject:message-id; bh=BFQJVSzGcUiBI/yFP8LdbUQD3Uj+U8GuBEaXAXz6ZKc=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9oFBYuLDvF9d6RNyqKnPc++ZptxLkm788kE4fk8m6PdD Gf/eyDdUcrCIMbBICumyMJzrYG59Y5+2VHRsgkwc1iZQIYwcHEKwEQUHjP8FT4q7/qhylvttk3+ XKO3ddmdn3jey344uGPfdmlzxi+3HBkZXsjbfilaf335tejK27Ovnk67EVP0NumF3oyGea6eXuV VHAA= X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 1EEAF4002C X-Stat-Signature: sq4n5oa6wpj1p5bwqz8ecpzp7czniphe X-HE-Tag: 1724915777-691042 X-HE-Meta: U2FsdGVkX18HWYgiOCy4e3vE4NcoJfXzylGcDpzbHCApvGtL0dU0tXktVjq2EuOL9QRonYYYpc0Ng//sRaZPWU2Qbs5Q0IvfKQ7SNCNTlqj0dWgVH8xonPy5LgJKkFbpeq+pR4XutIIiMib10g8ChO3qylB/j4D6vdPub4Fz8XZB5aL5ynhDDHs2ImXXLIVN8ByZqM/4KTHeh0cVBO0z7meZSwPeX+7L5jF1DWmaoal8ZBJVinB81PT04HQA2ADlqJaAFzxyOBNn2pkDq0o+T2YyE+RKrVLBSKb4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R9xEO9Wu3x+Iwh62grgjVw/v5ThIe6/LPgtlG/bCcvQ+rZmyd59OSRrxCyOuCQ== 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: 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). To make this behavior explicit and more versatile across all architectures, define a mmap flag that allows users to define an arbitrary upper limit on addresses returned by mmap. Signed-off-by: Charlie Jenkins --- include/uapi/asm-generic/mman-common.h | 1 + tools/include/uapi/asm-generic/mman-common.h | 1 + 2 files changed, 2 insertions(+) diff --git a/include/uapi/asm-generic/mman-common.h b/include/uapi/asm-generic/mman-common.h index 6ce1f1ceb432..03ac13d9aa37 100644 --- a/include/uapi/asm-generic/mman-common.h +++ b/include/uapi/asm-generic/mman-common.h @@ -32,6 +32,7 @@ #define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be * uninitialized */ +#define MAP_BELOW_HINT 0x8000000 /* give out address that is below (inclusive) hint address */ /* * Flags for mlock diff --git a/tools/include/uapi/asm-generic/mman-common.h b/tools/include/uapi/asm-generic/mman-common.h index 6ce1f1ceb432..03ac13d9aa37 100644 --- a/tools/include/uapi/asm-generic/mman-common.h +++ b/tools/include/uapi/asm-generic/mman-common.h @@ -32,6 +32,7 @@ #define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be * uninitialized */ +#define MAP_BELOW_HINT 0x8000000 /* give out address that is below (inclusive) hint address */ /* * Flags for mlock