Message ID | 20240827-patches-below_hint_mmap-v1-13-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 13AE7C5474A for <linux-mm@archiver.kernel.org>; Wed, 28 Aug 2024 05:50:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9978C6B00A9; Wed, 28 Aug 2024 01:50:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 945636B00A8; Wed, 28 Aug 2024 01:50:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C0C66B00A9; Wed, 28 Aug 2024 01:50:14 -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 59E126B00A7 for <linux-mm@kvack.org>; Wed, 28 Aug 2024 01:50:14 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1D6541C4F2E for <linux-mm@kvack.org>; Wed, 28 Aug 2024 05:50:14 +0000 (UTC) X-FDA: 82500578748.18.B23E8D3 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by imf09.hostedemail.com (Postfix) with ESMTP id 18191140017 for <linux-mm@kvack.org>; Wed, 28 Aug 2024 05:50:11 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=dkOOoxLT; spf=pass (imf09.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.215.181 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=1724824124; 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=AarzQWw7jN5pNetRW1c1iMmZVGfhSNhFxAvdf8X4j7o=; b=QKh+WJ2c1x9cGIHcCcPxMYs8cN11ZE6nCTtE31AaC4WCOtY/HOlw/ou7/szZC88Toryi09 GXI1Q8eDm5D5ULwkRiUojw1EOMRgdDe6U3VRvFXQku3zDysNubZGcIJb9k7qGlEoPVic29 F7tYw3Ca0zE/P3yCOWw0W9PnQUSQRdE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824124; a=rsa-sha256; cv=none; b=oyPCEfKQGhXh9Kt08HhFfTNpi3J5shdULTDBl7rfpdImV2oGHSWZOf4qj6yQraIVEhfauh qvqvshX5plTjVMzSpFBrjTIrbYn1IjD2bET7covakw6KBstGQLzLdBA7xMyMD2+vHHuhAw SH/7n9aCF9vSKbE530YC+Ep8RBuKTFQ= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=dkOOoxLT; spf=pass (imf09.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.215.181 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-76cb5b6b3e4so3982702a12.1 for <linux-mm@kvack.org>; Tue, 27 Aug 2024 22:50:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824211; x=1725429011; 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=AarzQWw7jN5pNetRW1c1iMmZVGfhSNhFxAvdf8X4j7o=; b=dkOOoxLTutCC59wy8Qlun42bU3Vcnx/g3UsW79EIhUJeNtaW/Ju00YYvV8+Ej1wDEz mZp1GJTyUNNL9KzEQO4J30Dydi+u8aezzwTOpWJCnsyAvw1MZA0j0FIJEbyfJLX8nhoo CIO23kpBmVGkaGCT/vTQudAbHhveG9z3p6mn4skyws2hSJBDd6tl/dbavaUL4UwZ3ASZ F+h5L9Rf7rR5+s7hqn0YmodyK2QRPBL85w9CLjVGk1zZEu3CVvIjsAmSIM+qTx+m6fmK DcE7qfliCujiZWB4MX3oqmshNjiz3uxaVikMVTjebLD3CCATaGHbKTEA1KtL8oOELU5w 5zaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824211; x=1725429011; 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=AarzQWw7jN5pNetRW1c1iMmZVGfhSNhFxAvdf8X4j7o=; b=UBoOXVTkTDtZdtwkXb2uSZB045KbW53hhlogwGxwcJF0wNHuOJy/6THbL4NRtMCsnM hjLcqPGG0+NMCMskllPVKPCAa2POqqDNNEj3yBJoG30rlFyrz3teeKk1LARDmF8+lLyh NW7xcIuTRjSQv1IfYJKdmj282LjW1dMlr8kj1anFFVMGmUWGdzMcHTiWVPy33UTJ8Fl0 CH6G0iWbBK/ZaBUiaKZh50L3+1wf+HVWe4htOPxmj7e6img8NbYcaSCdYRcYMPiLe2Rj gkv9XNOYSLE0x4KuTMMlS2WwLruUbTdMp3Hl7Q0XfYdbX8U2DlIQuQxNEcpXw9cZT2nv aDgQ== X-Forwarded-Encrypted: i=1; AJvYcCXEj/L4GNc2WspdU0zBjbie62aZUsRNjgeoiu742oJTqE67aeGJJRl0f0bMR5g0ZLZM+PI+tzaPyQ==@kvack.org X-Gm-Message-State: AOJu0YyfoXFya8USBBInpnld68L/BHwchT3BWxooYOmTuL6NgmDwFIAT TNJ8qpJ/sFDLuNo+QsdtXCdfq5c0DW1FafRDnKK776hq9iaA8SkzN5OrGD+9WOQ= X-Google-Smtp-Source: AGHT+IGSDxOLe5G0EzaI75j/pi3mF3L/KyOur/N+gUKJdt7aHyrcvZDzyi6uPsaAVyWSE2f/rnhW5w== X-Received: by 2002:a05:6a21:2d8f:b0:1cc:cdb6:c11a with SMTP id adf61e73a8af0-1cccdb6c913mr2470861637.24.1724824210534; Tue, 27 Aug 2024 22:50:10 -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.50.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:50:09 -0700 (PDT) From: Charlie Jenkins <charlie@rivosinc.com> Date: Tue, 27 Aug 2024 22:49:19 -0700 Subject: [PATCH 13/16] s390: 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-13-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=1730; i=charlie@rivosinc.com; h=from:subject:message-id; bh=LDlOb3puh00G9LsastMFHCdP3tuzGW5CWMac22J4/f0=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XQkTzp+9JuBqJbUp4CZHz86P7jsl/+dUPtx28/aiw uJ/F77s7ShlYRDjYJAVU2ThudbA3HpHv+yoaNkEmDmsTCBDGLg4BWAilewM/zPyq60vOxt27XXL PhSUqxi9dMWuaSXlSf4nvq4JmxBdu5+RYfa1r9wzZq5YzaDtGr2m541pUMtOl1Xnuf/rbZGaqVf Eyg0A X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 18191140017 X-Stat-Signature: apeeb31gmwhya796syoa6fff5kzctep4 X-HE-Tag: 1724824211-533049 X-HE-Meta: U2FsdGVkX18qDko1cy5YpuNDHMsJPNxMZ5FEzIkw+o5cIvcnvPRGJEVaQWWieLD9G9l1CuVHaXqnJWEG1A8L8/PksdiK4hxEFXl1appL9aA4UXB27Lek89xV1zfkfOZmvlfTyrx2SbwwlJz5Yr2xjd0j10sX6FeptypuFaH3wRPHBrTyUPD6UdfVwE/AJJ+iwVlo8OQtVXkNXgHxBDQljuUzIsFTwwGACmv2W3qoT9r6AUQ6Kxztrx5rtopu8fvf3q2Mpz6PrUzNdO6lSADsJAwcwBHi60vpppsYXiNbFjYRRU7iGxiIy3l7yysRduhyJl0Jm/OeEAygG21rGcJE5Q8QNWXCNtd3HFnTL/ezy6J5HayyZCBj7rkoA3kZ3ck7mektrgeqErfQOxooHIbyDJIHOEf5HrG1J4fLPikpFuodbpwW3cH9hlEZ8qc+dM9dNqBf80vuthX1WKN7kedX3UnfO7MDNdjVXq6TQhe0ISOXrO+9XK1EVtH7XbVXstrebAJ4Are/h9BJ8hgI14nnttyV3U65qQNki+mBF0kYtsBlnAc1pfPggVqlxUON3UBEvx1zHfbWY7VyPre4L9uB8sIOrzx2vZy5uBFHLcL9rOnhXnaUJ1TPjOb+7C+3K3EiBmvxVvFuM2yJGnVKTtDC8Q8SPFiT0TRSaV0RrZg1DuJ1LLz9JixrycVyUuTI3xYalNWAC8zsisjHnFIOJoKl2B5u8mbA4MREFQgpSgDBpPwcmy4zECDxrEwriedI/hOfoDzET80vgr2iJF2e6h1j21rWynEaJMvM0FDweqvEaw0MQ4ycnB0NQzGn1As+7Xt8Npr3xNolR7An6j4rIHJGz5sEYslJznnJJ32epdFKAiuDdDhSgHttXZ0K8KUFePHKGd9CFCyr2OniI/0zxwlH6jr5h3y6OS1EGJ7B9XxkjCyigtMglZyPLMxgJBLn67CYesX+SjoMVKeEkCzLGOP Ib/k3MHr JrqSeoINjVGOmGR/6ULBzWpzNx41fSAzXGRGYpxEuYq/iCEEpOyI6iiHaTw/bATsqsddZIoyy5ft4bSsGCTn/fjbLJATc+OChj6sy9THf0x3GvwWWAEI26wnvhsfJaLjiKUiDt6U6CMTnt1uP/qnvQcLqyNsUbPTQdSi2BwVWLCY/8ZAyPL4DOVTnO/QjYmi1DPqcnwoPR1rCqJufCJ+RtQlTTq7JUEhYlGeI06czxDA2wWS8/XdHGppmxifidnn2h0ytIAzFjBqwb/laTh3DwocKGl8F3sOGZRnhVT+chI8O+VENX1mWtQsmGha/zEHEktuvNCree3D61UqO3s8ZsVef47sqkiAeKJTF/WzvFd8N7BGIZjzNys9AgS470z4gzDFHtNqGyxUOS74E0dxlD7k9N1rt/enRSZ10h8oIpjMucKTFiCGrk1J7lQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000009, 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/s390/mm/mmap.c b/arch/s390/mm/mmap.c index 206756946589..29e20351ca85 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -105,6 +105,8 @@ unsigned long 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 = get_align_mask(filp, flags); info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); @@ -143,6 +145,12 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned long ad info.length = len; info.low_limit = PAGE_SIZE; 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 = get_align_mask(filp, flags); info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); @@ -158,6 +166,8 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned long ad info.flags = 0; info.low_limit = TASK_UNMAPPED_BASE; info.high_limit = TASK_SIZE; + if (flags & MAP_BELOW_HINT) + info.high_limit = MIN(TASK_SIZE, addr + len); addr = vm_unmapped_area(&info); if (offset_in_page(addr)) return addr;
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/s390/mm/mmap.c | 10 ++++++++++ 1 file changed, 10 insertions(+)