Message ID | 20240827-patches-below_hint_mmap-v1-10-46ff2eb9022d@rivosinc.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 06F76C5472D for <linux-mm@archiver.kernel.org>; Wed, 28 Aug 2024 05:50:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8845D6B00A1; Wed, 28 Aug 2024 01:50:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 833B46B00A2; Wed, 28 Aug 2024 01:50:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6ADD76B00A3; Wed, 28 Aug 2024 01:50:04 -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 4C1696B00A1 for <linux-mm@kvack.org>; Wed, 28 Aug 2024 01:50:04 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0023D141C44 for <linux-mm@kvack.org>; Wed, 28 Aug 2024 05:50:03 +0000 (UTC) X-FDA: 82500578286.16.B8E71E7 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf03.hostedemail.com (Postfix) with ESMTP id F17AA2000C for <linux-mm@kvack.org>; Wed, 28 Aug 2024 05:50:01 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=Hvq0sks3; dmarc=none; spf=pass (imf03.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824137; a=rsa-sha256; cv=none; b=tAJ7cYjBBBc6y41sL3xtjTmX1eT+4eRfBDolwK6jlI9z58pKPVRItghi0M7p0pmqVVLWH6 qR2JjZ8vNbecxRQaHeAL5rVgzVh2D63eSgEZ2T4oQgB/cElpQ78ti9wrTNimErHp47wS2a f2OI4Go1chOKPl2FUDk+wQbDeawtX3w= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=Hvq0sks3; dmarc=none; spf=pass (imf03.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.176 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=1724824137; 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=hfZJveM1parb4u035pYGD3zTISJbrOiZGzu54vNwlmI=; b=fZmu5yD956R3sqSSVI1iLK7QOoR6tHaoErJDLNgS2KXyBGdn+/tEm6s7mVv6Yi+d/5RmtI ydyb0a0b/jOnUSt+XVhjzn5ZN0vqGjHTEgQbYhYZlTIYqWZFD7oeELGOto4mGDDPgNsho1 PAdU1Qg3CW+EVGOjG5VE41gjh4hDEHM= Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2020e83eca1so60935445ad.2 for <linux-mm@kvack.org>; Tue, 27 Aug 2024 22:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824200; x=1725429000; 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=hfZJveM1parb4u035pYGD3zTISJbrOiZGzu54vNwlmI=; b=Hvq0sks3NMvvxy5zVyMaPlgU6StF24udUWJICG6PkXQX1jWxO2tiSrrpZ+0GZHYH20 RHkLnJ2wkSjb7YdL3aXdrpnnTyqlAhwbt02K+LXzzc6iGVDH8Rh+a3K41BZCEhw9+5Il Z6c9RjDJYCHUOS5HNtsYePQfHqjnCKMfmK0ssQ2izm08mCFFkfCZol9i94w0MXJi4zwL YFQjFvw1yVafzHG7eYyj/OW3wG0NWks8eRoWaumlnAOT9X9BfS1u0BnV1g56if8BMAis XyCFcsKVjvEewW7rX3dIF1zqdjl+82ATluJmwq1MgzNxXgDJCGBDA/lHeJeAHt6ZvEz5 FwSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824200; x=1725429000; 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=hfZJveM1parb4u035pYGD3zTISJbrOiZGzu54vNwlmI=; b=NPtHsVCJooz/a1sxBxaYSjjkP3TCwy1xEDXYBApo/rX/Q/Y7EHptAD49d6NoHzLqGr 4o1sgic1r78LpX2dFjBVmS0AphL94BkqB/uAGWDqcoGahtQsx5iJHIXH7yI+K175ByPi gICDoxLAfSpSe/ywMhGquOk2x1UDCRggTjDyo5UNpiqADqWVFKJNTs0wjDO2J6mRKl7W Da9g4blGVkTU3Xhbbbz/plfxKgyy1byq32Pi73piD911/eRNiavFPMGpMKr4trMe1R1e Rt6F3S6Tp2XDElowf9T1YUvSKdDlsQ72Cr5/RZt2U5uOx2S6xmeKwVQM161TfiP2OPgN sq9g== X-Forwarded-Encrypted: i=1; AJvYcCXxohvg+mbd9Pfd39DD3TxxqUh2K87CDZr2BO+0HXUGVgQXh2erPBgNBnZGKpQT+SDi4rDBA6xDNA==@kvack.org X-Gm-Message-State: AOJu0YxOJXPai/uWGMMnofAFvTV3po4OtqujY/VEjAzcaFZ0ggEuaTgt dnnGVNpaAMk320x5WvrYNvwoYAc4hhM9BZ1ZklFVvDl5y1VO+5TwSidL+AWSEdY= X-Google-Smtp-Source: AGHT+IF596NtgPi2otbs5poJBgAoGUDj9IXzCrdKWZMEp8cIFyXQZx8MxZQO71jW2zsopg6SUNTImQ== X-Received: by 2002:a17:903:2352:b0:201:f065:2b2c with SMTP id d9443c01a7336-2039e4fbbe2mr155506935ad.55.1724824200296; Tue, 27 Aug 2024 22:50:00 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-203855df0c4sm92092495ad.157.2024.08.27.22.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:49:59 -0700 (PDT) From: Charlie Jenkins <charlie@rivosinc.com> Date: Tue, 27 Aug 2024 22:49:16 -0700 Subject: [PATCH 10/16] arm: mm: Support MAP_BELOW_HINT MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240827-patches-below_hint_mmap-v1-10-46ff2eb9022d@rivosinc.com> References: <20240827-patches-below_hint_mmap-v1-0-46ff2eb9022d@rivosinc.com> In-Reply-To: <20240827-patches-below_hint_mmap-v1-0-46ff2eb9022d@rivosinc.com> To: Arnd Bergmann <arnd@arndb.de>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Michael Ellerman <mpe@ellerman.id.au>, Nicholas Piggin <npiggin@gmail.com>, Christophe Leroy <christophe.leroy@csgroup.eu>, Naveen N Rao <naveen@kernel.org>, Muchun Song <muchun.song@linux.dev>, Andrew Morton <akpm@linux-foundation.org>, "Liam R. Howlett" <Liam.Howlett@oracle.com>, Vlastimil Babka <vbabka@suse.cz>, Lorenzo Stoakes <lorenzo.stoakes@oracle.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>, Huacai Chen <chenhuacai@kernel.org>, WANG Xuerui <kernel@xen0n.name>, Russell King <linux@armlinux.org.uk>, Thomas Bogendoerfer <tsbogend@alpha.franken.de>, "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>, Helge Deller <deller@gmx.de>, Alexander Gordeev <agordeev@linux.ibm.com>, Gerald Schaefer <gerald.schaefer@linux.ibm.com>, Heiko Carstens <hca@linux.ibm.com>, Vasily Gorbik <gor@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Sven Schnelle <svens@linux.ibm.com>, Yoshinori Sato <ysato@users.sourceforge.jp>, Rich Felker <dalias@libc.org>, John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>, "David S. Miller" <davem@davemloft.net>, Andreas Larsson <andreas@gaisler.com>, Shuah Khan <shuah@kernel.org>, Alexandre Ghiti <alexghiti@rivosinc.com> Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt <palmer@rivosinc.com>, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kselftest@vger.kernel.org, Charlie Jenkins <charlie@rivosinc.com> X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1701; i=charlie@rivosinc.com; h=from:subject:message-id; bh=1syBnrvTSOlOGGJG9VxttpQivuBkydj5+eNQ5N/relM=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XfH7+5/NObdD1TC7as2nnrut80uYIpiTE6QKMsStV jRo9UV3lLIwiHEwyIopsvBca2BuvaNfdlS0bALMHFYmkCEMXJwCMJH3iowMbzKLnvWynRbmDQrg 3uNwlaGFp7De9nT0tCfZV9Zxzb2swMjwZeP9u8Jhqpz79ln+TNZVkXSd3DxD3/DEm3BhhnWsrp8 4AQ== X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspamd-Queue-Id: F17AA2000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: r5x4xrcrwt9fscn4gp6eaw4oi7gfhkzo X-HE-Tag: 1724824201-80306 X-HE-Meta: U2FsdGVkX1+cSVXTY8ZQ5HvKZOYQoNUlA36pV9gAScy71BlPS3PLudTnTOV8+fY0KmTMVbqRMeHkOgqj6GJj4Tt8CAc97gClU6A5KV3VzJvDJdCuCsACNc9owUm/gbd7pRECFw9J2fgmWd7dQncil7VgwVb/WXomtFqTMVgBb0FUPPm39Sp8niIbVg5DD7TcFt13OqnkbBf0jkEyatNwdOcx7ExE4QXvKNh7fCv1kZ9RHxMHLvff4PHR6Fb8uelwk/pvXetRoU9IoVUfFBJ20QtRlL2nGVEuf2GhCgRoPvW57jhj1lcEfJRc2FwsLiLlzL5Xb/zxClm0yHlIqCzEAgGnkDHaT1LerQygFR0Wv8oKZUAYBd92Cln8o6v08WD8Sk1jF4nRaTmkQNYLrnGwDowsjYIY1v/ZUWeOzrBKdjljqgTFgKXNwrujucd2xkwzTloiWtfEwmSoP+NEvmaCDDMIE6tqPYpyhk11XoHk1EyO42l8g4EASXSlAV4CDmzREhvkagqr8l/AAoCIuWM23833dLmemkjGktz4nweJ6i8QHJmSzEUDXU7nXiMwqMIFDmeVzpDW3B8MWqGgf2qu5ku8jbMZ3ReA+wry7IzwHu5ZzyM8m0vfH2NgcLz81MIrFpWSFs68Y+vw1lP7a/jIU6GqRSa2fAdrUWzJb29Ca5YE4JdML6RcdlEM7H/exB2iStfQdSURHVpeG4HSkxwxd4PmSpKZgoWQ221RqlH7GDoCYUHTTAH0etsIcTkD+c6QIid6v5yUhP3qCy9epolxACXWO3/G+bxig/S1HBd2cRF7fUYcZIZcSwezI2WCbF1UXXO8T2kkXLBzqg6uIrDQJASi5hyGWDhJ3E7TxmixTB2hPeWPFyNRakBjD8FQEgeSifPyMjAqfYWWssAJzoDnns/EmuE5ThEQAZctxhM87XX9V3H4Ax3NkWgNuUiHNQZkUhUNaMNyk9ckLc/O+1Z QWOY3Vtm 1xYp/YphUMX+OyAG1A5jmI3gDAklpPCBhgm2vpzCaG2sQA8n3St5NDYSUVs4uRfbxy3L3es2aHqhzSY8h8TRV8NarIcbiw3WFZ9Swx0PBD9vLYXY5RyIqyQQ+8negSCrK43swpI0Z8xY5ewmo01g4S+0z2r4Z5JasVpLC6Btj/zRzR9eokmtsTYqnT+32UAbkmnBlpS48yDpmp0SyKtinYUMYNal99uYmQ0m1mqcwDjo6q1JeANGyV2f9oUCIPZNjewg0/4KBM0f3T1+zpi0pfakWGssj07Meo9nsImrWb81gWfitx1d5FMVtv4Ow0DUTPCVuFypUTTV/Yq5DQrxomNySpQOk4WOjDSsneFxbZUtvCowuhiwOIrlvz2fcsBWJ6rRjWjMbjbZAINdbyM472jDIdoOdjlM83HJ3MhxvrFvYD3wgXeu3pq0ABA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
mm: Introduce MAP_BELOW_HINT
|
expand
|
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c index d65d0e6ed10a..fa0c79447b78 100644 --- a/arch/arm/mm/mmap.c +++ b/arch/arm/mm/mmap.c @@ -71,6 +71,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, info.length = len; info.low_limit = mm->mmap_base; info.high_limit = TASK_SIZE; + if (flags & MAP_BELOW_HINT) + info.high_limit = MIN(info.high_limit, addr + len); info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0; info.align_offset = pgoff << PAGE_SHIFT; return vm_unmapped_area(&info); @@ -122,6 +124,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, info.length = len; info.low_limit = FIRST_USER_ADDRESS; info.high_limit = mm->mmap_base; + if (flags & MAP_BELOW_HINT) + /* + * Subtract (STACK_TOP - mm->mmap_base) to get random + * offset defined in mmap_base() in mm/util.c + */ + info.high_limit = MIN(info.high_limit, (addr + len) - (STACK_TOP - mm->mmap_base)); info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0; info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); @@ -137,6 +145,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, info.flags = 0; info.low_limit = mm->mmap_base; info.high_limit = TASK_SIZE; + if (flags & MAP_BELOW_HINT) + info.high_limit = MIN(info.high_limit, addr + len); addr = vm_unmapped_area(&info); }
Add support for MAP_BELOW_HINT to mmap by restricting high_limit to addr when the flag is enabled. Signed-off-by: Charlie Jenkins <charlie@rivosinc.com> --- arch/arm/mm/mmap.c | 10 ++++++++++ 1 file changed, 10 insertions(+)