Message ID | 20240827-patches-below_hint_mmap-v1-14-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 7CB56C5472D for <linux-mm@archiver.kernel.org>; Wed, 28 Aug 2024 05:50:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 096C06B00A7; Wed, 28 Aug 2024 01:50:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F12636B00A8; Wed, 28 Aug 2024 01:50:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA3896B00AA; Wed, 28 Aug 2024 01:50:17 -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 98ECE6B00A7 for <linux-mm@kvack.org>; Wed, 28 Aug 2024 01:50:17 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5073014174F for <linux-mm@kvack.org>; Wed, 28 Aug 2024 05:50:17 +0000 (UTC) X-FDA: 82500578874.21.264E465 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf07.hostedemail.com (Postfix) with ESMTP id 66EB940004 for <linux-mm@kvack.org>; Wed, 28 Aug 2024 05:50:15 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=yNkDTd2H; spf=pass (imf07.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.182 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=1724824128; 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=74ih38qyFApS59Oo5hAHcKEdd4ieUrnz9WHar/pXDMA=; b=c5U6ZovtxG0AY+N11yyJm2Uj9XbTchj7xtJgA3YhJNx0VPwG1XdKD+FZy1k9gi+UQSo9Be 4CAZjvWPEmxf2G1rO6g/XeoC8fMvueSAks9cmH29BpEZXShzeBlbIbD9BE3LaSSFYQ+Jid qflPI8GXTL6PfM7iXjNuFRVt7xOtzjM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824128; a=rsa-sha256; cv=none; b=RkdRImAiqzh3/2vQDQC3C/3Jp5rjLZCU68q8ch32gnJ02yrUo9CBI1LCnLal8ermxaNTFG 1zNO6bDNKZxav8HXwNR+ye2T+oyjJxCJqvD+7AoR0sNpPgvCiWE+EJWPvZhSu9c1LnPzQZ /jD1L5+V0XTJXnyMXCAqZXUTk6eK4zk= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=yNkDTd2H; spf=pass (imf07.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-204eebfaebdso8519335ad.1 for <linux-mm@kvack.org>; Tue, 27 Aug 2024 22:50:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824214; x=1725429014; 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=74ih38qyFApS59Oo5hAHcKEdd4ieUrnz9WHar/pXDMA=; b=yNkDTd2HrHGKAyfu68ak0S8u1qJv0HwPUE4agvmvkp4T8Go3g5DEWX9xfQ8TW4JozH TbsVnpfa2rFPIgk1+igPVbvpA5DrCg0vBuQ3O01PI1DyXS2ohE88eOCH95uU5UhsxKr5 8wz2FsshCz/bdl/Z4HfogNu8fUP9Ao3t361btLCS9YmS7+M3J63CDAJr7dKJk+kK5QOH 0G8jSBqG+EXaltNev9+x1FCCZvoC4x75ssWVMdZMVVaPl/Ty9M9q1ZQaBq+TXzz0LJeQ yATcXYzWKIFRlOX93ya7bpO3lQ8VZ1rvHRcAOMcZjEbZj9mfMMkjWPpvom8NWSxua+pq +IJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824214; x=1725429014; 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=74ih38qyFApS59Oo5hAHcKEdd4ieUrnz9WHar/pXDMA=; b=Vc9vPooRLGjqtbf3vGM97sTQDgw7QUG3BaB4oWz4AGd87EXQUTFTsK95dcTqoWatpf cQ8DcohhT5Wg+EBSfGl9X+T7jpwpEH6exovaX9AtWuzsjeeQxkxwOSqil88PLocHGsHo 5MtNOrTQL4Srh6TfAnqFlGNbvJRlWtrrbx3H148sAPWJuAzXl1PIzKHMqyh8tzyW66XX YRY3PIkSKt0FJ0xMmhoPJJyNeZGp5zl8oD57XVQ6v7EYEUYCIDyVQ+T895k32T5T7M54 frwGti0zEk6SdIdl8FNK6AkHi2IqM5ksDJkyOmK+hn24wq5ym3gX+OshyowGWXdrNiZ1 AhYA== X-Forwarded-Encrypted: i=1; AJvYcCUZ3BHbWIdwPxj5dxRgkmjmvkWeBze6FueRKR1WSYO4u9p2JZZSZIEkkocYehlaiD7v5H/3XG1hiQ==@kvack.org X-Gm-Message-State: AOJu0Ywax+CDCNweWRQDAbRxCH1fSXPUHJzMdUtjK0oAm44k8PLh7oOI Gzqc2UB3XtCfEWlS89GA0Z7qW7CxTLIYxtjsCc1+rRt0/VEij7HZYYzcLnGFnCE= X-Google-Smtp-Source: AGHT+IHaxH8ov/UqUPxBA8x0bmmHbs3R6mKOF+WDurSlvopgHqFjxqmjotSQ0dAp9h1od2RsPmTDOA== X-Received: by 2002:a17:902:e852:b0:200:ac2c:6785 with SMTP id d9443c01a7336-2039e44cbcdmr164066655ad.3.1724824213959; Tue, 27 Aug 2024 22:50:13 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:50:13 -0700 (PDT) From: Charlie Jenkins <charlie@rivosinc.com> Date: Tue, 27 Aug 2024 22:49:20 -0700 Subject: [PATCH 14/16] sh: 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-14-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=1729; i=charlie@rivosinc.com; h=from:subject:message-id; bh=RSW/tCXIl3OqIq1wugK/BMhqzVxC+hGCJaNgaxgxyH4=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XYlVP75VR006aZFn+70kVT1K4PGO6plPeD6ttY1Ib fZuvX6uo5SFQYyDQVZMkYXnWgNz6x39sqOiZRNg5rAygQxh4OIUgInsXsrw34+bSWfTiYerug+W bJm2uPHhi6ei0zVPGCvcutghUP70ggcjQ8uKDy93HJCN5MpSDQ5Y9+eF9/TONIm5nufepW33SA2 /wgMA X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 66EB940004 X-Stat-Signature: gxyeeumgy59gjwffafzxbejqs9893cxd X-HE-Tag: 1724824215-670892 X-HE-Meta: U2FsdGVkX1+FBkg4YnKq5vWYnNcsL63faOyciym03L++lFpl1gl3f+hn3zX6udSiB/NEkao3GP2ZwWulXnvoItyUa2DTHJM/XIjY4LxCY2ei1oPxGqUrBLUaUQJcVFAKLCLJGomOT2Qvo0vLWwzAxzxBOLvPNqaRg+iED8mR8POqR1DtMu1do2viR7X2tg+IYFyTnaIQx7jAQSSE4/BIt2GASwZPOXIOufebJVojxvHTCGEKRzfrMznNyCw9nmlNBR2fnx36LnYve5Vo6pRK0aAdRk7GqUIWagr2F+zYB4NYcqGpuD7S7hD2iJYzB+qIA6EzCxPx599f2srvsY3zGgVd43ESPIBBSpaLvqPxfcGEY4x1FLZjmP2im+niYvEtLATQtu0ci6TAZcPuvJTknjkH0l6HhUhPbihR668yeLS3bl8fMNeIZ23MFlaO4zp75n7gryOucHMHzjGw4yswWAb98JzM0gMVzzDBlclpwYuaYZudU5wdsF9fgS+SEQE9R9rn/I15Ma6ptt+lK+mM+wxze0kbu+IeEncow/08IwFb+A332fh0rtChgoPD/1abSHna1MbjIWOPKOGcjfldkT29bTVU85AhQKYQm383uUT94cwj02U0P5PP4VzeAM3YGomjZyM5s4+/tUcfPjjxJz6w9SFf20hjUWpttfzB2EhIHJhisoFb/qQ3MVa/nUD7dBEgZYi3duGIUoDKodqdlsoIBcnYn2EU//44B386wFr+4sVk962IGDsxMFiJ+CmXZo+CRQ6mREih/oQ2NOkWg/E5MRMPiXlV2y9ZzXvRgVSloT7QL8U3RXuNvnKgqQWaIZU5PtUp7sd9E90pT59+SUK9CvcAEJdywVlua9GSp13Vv1tB6jN3GOEYk4VlSFSbn1u40YTDI/yx68qIIU4aQlZ2tx+xzPs29FKFY6RjPwv0iBRvhzkINFKIvDfk6CCYrNoDfW01OMx7ppHNFM6 FN2RgNqp Zy8DzmJLcRjd/Ua4vUFnMwsafxqIFXsPNHZHUw04snuwVBk8AfG04i9ONpp4YutiGHAzAC8KqrstXVCl8IHIoR7qiHb2/2lYjnCR5t8V7beLCC115eplub5zWrQV5qQB0TDgN7+eQYXkdhLjmSem3BXJeKG4EN2iHr2vQcDT/IFvfyOdSGdkXjRwqUuB2RdlkCcIoBoNGW4LxFxhUOMbHCeQAkrIzp3zRc/cbHHPiJUhrz+fFsNkR+dZHBBJ7FaBjZJe8du8Fc1row0ZS5VKrcvMJlK13ETD29HYnJ5L042MZ2B/OYciGUJHD5Ow2SvqIbJUcdua+RywJzUvkHJwW+C8iXuGRQG7JsHgdmDO9UK84D1ukIV4kNH84LRdo2RjIvRBaPT/HyV29Kty3/C/nXHVZce12dh3CtnIl 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/sh/mm/mmap.c b/arch/sh/mm/mmap.c index bee329d4149a..867f6598b7d0 100644 --- a/arch/sh/mm/mmap.c +++ b/arch/sh/mm/mmap.c @@ -91,6 +91,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, info.length = len; info.low_limit = TASK_UNMAPPED_BASE; info.high_limit = TASK_SIZE; + if (flags & MAP_BELOW_HINT) + info.high_limit = MIN(info.high_limit, addr + len); info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0; info.align_offset = pgoff << PAGE_SHIFT; return vm_unmapped_area(&info); @@ -141,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, 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 = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0; info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); @@ -156,6 +164,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, info.flags = 0; info.low_limit = TASK_UNMAPPED_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/sh/mm/mmap.c | 10 ++++++++++ 1 file changed, 10 insertions(+)