From patchwork Wed Aug 28 05:49:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780621 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 EECEBC5472D for ; Wed, 28 Aug 2024 05:49:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80FD26B008A; Wed, 28 Aug 2024 01:49:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BE4E6B008C; Wed, 28 Aug 2024 01:49:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6383D6B0092; Wed, 28 Aug 2024 01:49:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 447A66B008A for ; Wed, 28 Aug 2024 01:49:40 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EFA2181D97 for ; Wed, 28 Aug 2024 05:49:39 +0000 (UTC) X-FDA: 82500577278.11.ECF4657 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf28.hostedemail.com (Postfix) with ESMTP id EB5D1C000F for ; Wed, 28 Aug 2024 05:49:37 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=wwam0zlw; spf=pass (imf28.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.174 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=1724824090; 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=TGbwsGUaSgh3SYkS7pHaMfmAZns1s9a6v7xPbD2XVAI=; b=ia/eQim3UTGRrcP/8fJ9HlANJx0kKsOrZHfVkFg6ubY8IAawkTa2/lKPb5shRY6CK0Jv92 ZF9TBoO2ODcwDIBueWpFhW1bhxTFUYjUUf/D5SNBzhmg3CREq4WQCvcB2/4LUQqLrJGb5W G0r79CgKsiinqApr7jLpKzRL4zXhsoE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824090; a=rsa-sha256; cv=none; b=dUktQEkdHN++PkesIlLo5ju9lOLD5JSemTvdr6LnyPWvYM3RyAx8vVzHPLXK93eqhtSjQv NQUmtro2csfDZKyhEyIWeDow0PIkG3K4uNrO5FRWQLmrkDHyi0FZNo7LDtG+ViChXgrQVD 3Cs5u80D08/cxO6jHrNA3v5yLOPnIb8= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=wwam0zlw; spf=pass (imf28.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-201fba05363so53069315ad.3 for ; Tue, 27 Aug 2024 22:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824177; x=1725428977; 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=TGbwsGUaSgh3SYkS7pHaMfmAZns1s9a6v7xPbD2XVAI=; b=wwam0zlwTp2/KeLoAUDqOIAZmiHXpklKOyxfn9QWb/8yPj6r6SnBVuWYx6FNkpyp55 ef3ThZZwzwuPucInTyBM7uu1mEXQ4Nh7oKZodV/bFzGnJpfIgkFW/dD/4AN3pJx/7pTl LiGijGlg+fUPoZ9j1EwnPdRwN3qeKWffKq2QemVcS+4V/X2vooUBhQ0IsliXs66rf907 Y9mMb5dV0te2AC49NmCMAclKgzB1LXg1itgPMHorLKd0iyUJACXxGlrUE88SxLgYdL4o lnqKLWGbg2ef7tyQ/NbfEgHELKeCSmegF94G6OoS3EKAqOy9+Kz8ytgUdksjVPzbsUAm CEIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824177; x=1725428977; 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=TGbwsGUaSgh3SYkS7pHaMfmAZns1s9a6v7xPbD2XVAI=; b=La1iW/HdMM+8VHEXibl5jdze0qvXPAdFZ8jPKIf9SpGDKLP8DERunEjnzI2ZhjWBk0 8Y9I7ojJC0WKStJZJSPHtQRgyitmbFH7jHRwBYBw7AH8uSXD7REA4nbHmZxakjY3sAUp LrgfG3N2lYpJtuJ4xt43IhFcTb7KMNkSfI4Z6yBL0idg3RqIuKr9yyhdBLxidzCjsdF7 2/8eE6i2P7ptXAaK0WFQJR8D5zccL2Gc61EHFwbjJRg7KK4a88EN30XP8xEp7Cl5BpOw 3EWFFBInmkxww58n3o0lvKv+8ITif2x9QRA39rOf9NrEQeYVVLoHjjgWibXIl3odU+h8 xEXg== X-Forwarded-Encrypted: i=1; AJvYcCWAsO2oa1zZuxvn1Jeh3oDj/5hT0Mi0yQdarenB6Vx9ZQ8ALGykIQitDGDuEH0ylk2y10sMtDXuQg==@kvack.org X-Gm-Message-State: AOJu0YyBZezSuiePQVpBjEMiRkVT2nnFBda58epxk9uLOE+dwNGj6qKm tuoR1UX6bJ1ygbsmfPiDLTRXVC2kwVc2j9AF7Eno8AkiiWWLRxOOo4E0liXrIF8= X-Google-Smtp-Source: AGHT+IETeUynSugovs7+A+AN20czg30Ola2aofBrInbwTCbD60I4EWjQ5oF17Pp044tfVMlW9N70GQ== X-Received: by 2002:a17:902:f946:b0:1fb:6ea1:6a with SMTP id d9443c01a7336-204f9bf6b4fmr8673095ad.42.1724824176426; Tue, 27 Aug 2024 22:49:36 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:49:35 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:09 -0700 Subject: [PATCH 03/16] mm: Add flag and len param to arch_get_mmap_base() MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-3-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 , Paul Walmsley , Palmer Dabbelt , Albert Ou , Catalin Marinas , Will Deacon , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Muchun Song , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Huacai Chen , WANG Xuerui , Russell King , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , 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 , Shuah Khan , Alexandre Ghiti Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3681; i=charlie@rivosinc.com; h=from:subject:message-id; bh=deEFSUhsRdIX0bdzxWoQYKSiKJBAsZhcTOjbVXT5+ls=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XbEKPQVKN+QOfCnd/vQAx7Mm0aicnIfvMk/aT/p2R eLJrUMHOkpZGMQ4GGTFFFl4rjUwt97RLzsqWjYBZg4rE8gQBi5OAZiI/GeGP5ySTrLnNmwQmXLz 8w+bnE++e2VFjGTvdAadNPbzvHntw1tGhs53DbPX/utm9fCf+JHzi+Xvmwkm0w5eV/OMyrFcaSf ykBcA X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Stat-Signature: dsnb5ypksda63qq9ersew96jndycom93 X-Rspamd-Queue-Id: EB5D1C000F X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724824177-12916 X-HE-Meta: U2FsdGVkX18q2ocuw2Qc0lfhlFMmreDjkoG7GUgBkGR9FQj1pY/MlMV2q7z1ha9Oak082G25hJvXAOiqCaAsdah6a3fYZkWGzDLrx/zG2wb2GMoFRM2ZCIegAah3kBw5mAx1S6CDRD0shPU4CgEkZ3c5f/qQlg+I503BBKxZeS3DrwT3QTCAclsFFjeIORbmyAWnD+vD7sNE2nKH0V0iGXzvaMaMGyT05zJJrZNL5x8vlkqjK0EsYLYAYTaDeH+knEvhYx44PO5df839TlytcusfQG0ndk8O0C+sW9QEn1iMcQIxjyyg+hyGJifNtuZQN4iS+PyNEcHV+aZwfulm1bH3cCC4elZt36m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Eg== 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: The flag and len param is required in arch_get_mmap_base() to implement MAP_BELOW_HINT. Signed-off-by: Charlie Jenkins --- arch/arm64/include/asm/processor.h | 2 +- arch/powerpc/include/asm/task_size_64.h | 2 +- arch/riscv/include/asm/processor.h | 2 +- fs/hugetlbfs/inode.c | 2 +- include/linux/sched/mm.h | 2 +- mm/mmap.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index f77371232d8c..a67ca119bb91 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -95,7 +95,7 @@ #define arch_get_mmap_end(addr, len, flags) \ (((addr) > DEFAULT_MAP_WINDOW) ? TASK_SIZE : DEFAULT_MAP_WINDOW) -#define arch_get_mmap_base(addr, base) ((addr > DEFAULT_MAP_WINDOW) ? \ +#define arch_get_mmap_base(addr, len, base, flags) ((addr > DEFAULT_MAP_WINDOW) ? \ base + TASK_SIZE - DEFAULT_MAP_WINDOW :\ base) #endif /* CONFIG_ARM64_FORCE_52BIT */ diff --git a/arch/powerpc/include/asm/task_size_64.h b/arch/powerpc/include/asm/task_size_64.h index 5a709951c901..239b363841aa 100644 --- a/arch/powerpc/include/asm/task_size_64.h +++ b/arch/powerpc/include/asm/task_size_64.h @@ -72,7 +72,7 @@ #define STACK_TOP_MAX TASK_SIZE_USER64 #define STACK_TOP (is_32bit_task() ? STACK_TOP_USER32 : STACK_TOP_USER64) -#define arch_get_mmap_base(addr, base) \ +#define arch_get_mmap_base(addr, len, base, flags) \ (((addr) > DEFAULT_MAP_WINDOW) ? (base) + TASK_SIZE - DEFAULT_MAP_WINDOW : (base)) #define arch_get_mmap_end(addr, len, flags) \ diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index 1015f2a49917..7ff559bf46f2 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -19,7 +19,7 @@ STACK_TOP_MAX; \ }) -#define arch_get_mmap_base(addr, base, flags) \ +#define arch_get_mmap_base(addr, len, base, flags) \ ({ \ base; \ }) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 9f6cff356796..05a52f85dba9 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -195,7 +195,7 @@ hugetlb_get_unmapped_area_topdown(struct file *file, unsigned long addr, info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len; info.low_limit = PAGE_SIZE; - info.high_limit = arch_get_mmap_base(addr, current->mm->mmap_base); + info.high_limit = arch_get_mmap_base(addr, len, current->mm->mmap_base, flags); info.align_mask = PAGE_MASK & ~huge_page_mask(h); addr = vm_unmapped_area(&info); diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 91546493c43d..265b43855d0b 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -174,7 +174,7 @@ static inline void mm_update_next_owner(struct mm_struct *mm) #endif #ifndef arch_get_mmap_base -#define arch_get_mmap_base(addr, base) (base) +#define arch_get_mmap_base(addr, len, base, flags) (base) #endif extern void arch_pick_mmap_layout(struct mm_struct *mm, diff --git a/mm/mmap.c b/mm/mmap.c index d0dfc85b209b..27a7f2be3f68 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1861,7 +1861,7 @@ generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr, info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len; info.low_limit = PAGE_SIZE; - info.high_limit = arch_get_mmap_base(addr, mm->mmap_base); + info.high_limit = arch_get_mmap_base(addr, len, mm->mmap_base, flags); addr = vm_unmapped_area(&info); /*