From: Charlie Jenkins <charlie@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>
Subject: [PATCH 12/16] parisc: mm: Support MAP_BELOW_HINT
Date: Tue, 27 Aug 2024 22:49:18 -0700 [thread overview]
Message-ID: <20240827-patches-below_hint_mmap-v1-12-46ff2eb9022d@rivosinc.com> (raw)
In-Reply-To: <20240827-patches-below_hint_mmap-v1-0-46ff2eb9022d@rivosinc.com>
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/parisc/include/uapi/asm/mman.h | 1 +
arch/parisc/kernel/sys_parisc.c | 9 +++++++++
tools/arch/parisc/include/uapi/asm/mman.h | 1 +
3 files changed, 11 insertions(+)
diff --git a/arch/parisc/include/uapi/asm/mman.h b/arch/parisc/include/uapi/asm/mman.h
index 68c44f99bc93..44925ef8ac44 100644
--- a/arch/parisc/include/uapi/asm/mman.h
+++ b/arch/parisc/include/uapi/asm/mman.h
@@ -26,6 +26,7 @@
#define MAP_HUGETLB 0x80000 /* create a huge page mapping */
#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */
#define MAP_UNINITIALIZED 0 /* uninitialized anonymous mmap */
+#define MAP_BELOW_HINT 0x200000 /* give out address that is below (inclusive) hint address */
#define MS_SYNC 1 /* synchronous memory sync */
#define MS_ASYNC 2 /* sync memory asynchronously */
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index f7722451276e..feccb60cf746 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -148,6 +148,13 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
info.flags = VM_UNMAPPED_AREA_TOPDOWN;
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));
addr = vm_unmapped_area(&info);
if (!(addr & ~PAGE_MASK))
return addr;
@@ -163,6 +170,8 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
info.low_limit = mm->mmap_base;
info.high_limit = mmap_upper_limit(NULL);
+ if (flags & MAP_BELOW_HINT)
+ info.high_limit = MIN(info.high_limit, addr + len);
return vm_unmapped_area(&info);
}
diff --git a/tools/arch/parisc/include/uapi/asm/mman.h b/tools/arch/parisc/include/uapi/asm/mman.h
index 4cc88a642e10..297acc0f7b2a 100644
--- a/tools/arch/parisc/include/uapi/asm/mman.h
+++ b/tools/arch/parisc/include/uapi/asm/mman.h
@@ -40,4 +40,5 @@
/* MAP_32BIT is undefined on parisc, fix it for perf */
#define MAP_32BIT 0
#define MAP_UNINITIALIZED 0
+#define MAP_BELOW_MAP 0x200000
#endif
--
2.45.0
next prev parent reply other threads:[~2024-08-28 5:50 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 5:49 [PATCH 00/16] mm: Introduce MAP_BELOW_HINT Charlie Jenkins
2024-08-28 5:49 ` [PATCH 01/16] mm: Add MAP_BELOW_HINT Charlie Jenkins
2024-08-28 5:49 ` [PATCH 02/16] riscv: mm: Do not restrict mmap address based on hint Charlie Jenkins
2024-08-28 5:49 ` [PATCH 03/16] mm: Add flag and len param to arch_get_mmap_base() Charlie Jenkins
2024-08-28 5:49 ` [PATCH 04/16] mm: Add generic MAP_BELOW_HINT Charlie Jenkins
2024-08-28 5:49 ` [PATCH 05/16] riscv: mm: Support MAP_BELOW_HINT Charlie Jenkins
2024-08-28 5:49 ` [PATCH 06/16] arm64: " Charlie Jenkins
2024-08-28 5:49 ` [PATCH 07/16] powerpc: " Charlie Jenkins
2024-08-28 6:34 ` Christophe Leroy
2024-08-28 17:29 ` Charlie Jenkins
2024-08-31 16:30 ` David Laight
2024-08-28 5:49 ` [PATCH 08/16] x86: " Charlie Jenkins
2024-08-28 5:49 ` [PATCH 09/16] loongarch: " Charlie Jenkins
2024-08-28 5:49 ` [PATCH 10/16] arm: " Charlie Jenkins
2024-08-28 5:49 ` [PATCH 11/16] mips: " Charlie Jenkins
2024-08-28 5:49 ` Charlie Jenkins [this message]
2024-08-28 5:49 ` [PATCH 13/16] s390: " Charlie Jenkins
2024-08-28 5:49 ` [PATCH 14/16] sh: " Charlie Jenkins
2024-08-28 5:49 ` [PATCH 15/16] sparc: " Charlie Jenkins
2024-08-28 5:49 ` [PATCH 16/16] selftests/mm: Create MAP_BELOW_HINT test Charlie Jenkins
2024-08-28 17:48 ` Lorenzo Stoakes
2024-08-28 18:13 ` Charlie Jenkins
2024-08-28 18:19 ` [PATCH 00/16] mm: Introduce MAP_BELOW_HINT Lorenzo Stoakes
2024-08-29 7:14 ` Charlie Jenkins
2024-08-28 18:29 ` Dave Hansen
2024-08-28 20:15 ` Charlie Jenkins
2024-08-29 16:54 ` Dave Hansen
2024-08-29 19:36 ` Liam R. Howlett
2024-08-30 1:10 ` Charlie Jenkins
2024-08-30 1:00 ` Charlie Jenkins
2024-08-28 18:31 ` Liam R. Howlett
2024-08-28 20:59 ` Charlie Jenkins
2024-08-28 21:39 ` Charlie Jenkins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240827-patches-below_hint_mmap-v1-12-46ff2eb9022d@rivosinc.com \
--to=charlie@rivosinc.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=Liam.Howlett@oracle.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=alexghiti@rivosinc.com \
--cc=andreas@gaisler.com \
--cc=aou@eecs.berkeley.edu \
--cc=arnd@arndb.de \
--cc=borntraeger@linux.ibm.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=chenhuacai@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=dalias@libc.org \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=deller@gmx.de \
--cc=gerald.schaefer@linux.ibm.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hpa@zytor.com \
--cc=kernel@xen0n.name \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=loongarch@lists.linux.dev \
--cc=lorenzo.stoakes@oracle.com \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=muchun.song@linux.dev \
--cc=naveen@kernel.org \
--cc=npiggin@gmail.com \
--cc=palmer@dabbelt.com \
--cc=palmer@rivosinc.com \
--cc=paul.walmsley@sifive.com \
--cc=shuah@kernel.org \
--cc=sparclinux@vger.kernel.org \
--cc=svens@linux.ibm.com \
--cc=tglx@linutronix.de \
--cc=tsbogend@alpha.franken.de \
--cc=vbabka@suse.cz \
--cc=will@kernel.org \
--cc=x86@kernel.org \
--cc=ysato@users.sourceforge.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox