From patchwork Wed Aug 28 05:49:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780633 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 E0CB6C5474A for ; Wed, 28 Aug 2024 05:50:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C4346B00AB; Wed, 28 Aug 2024 01:50:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D7666B00AC; Wed, 28 Aug 2024 01:50:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B2FF6B00AD; Wed, 28 Aug 2024 01:50:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 269D26B00AB for ; Wed, 28 Aug 2024 01:50:21 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CD0B4141A6E for ; Wed, 28 Aug 2024 05:50:20 +0000 (UTC) X-FDA: 82500579000.04.B15490D Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf20.hostedemail.com (Postfix) with ESMTP id D46361C000C for ; Wed, 28 Aug 2024 05:50:18 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=qZhRoZEA; dmarc=none; spf=pass (imf20.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824154; a=rsa-sha256; cv=none; b=7yxD/RuWDAvCbbyt5ygwdyuN4ZfD2zHjLuH9wNceHyUW8q1LNJpdPfjZ7+9zY8l4uNTs98 1JKBEkHsbXWEOPz6BiCFOJvD3WeYAeu3+DiuRrRo48s1KbdXN0rFmYU3uG+Ax0eJ7Vd9kG svn8R84QNEWSslaUWueprSiNH0vT0Yc= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=qZhRoZEA; dmarc=none; spf=pass (imf20.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.170 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=1724824154; 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=N47VMRtMS+23qmQV6QvpGjMmEbWavAKSyy/PH2d+fuI=; b=Mf5Z2JQq1EdMh+zR+39K5cOQaiu5QWZO35QcLpGibQC7yH4a5eJqWOHZ3MJJ7oeLJSqGia JvowTcAypueLoJW/OK8L2D3M+ZcJGTOFH+YIqEtPMqRRSVg+oQmKUcbelYLC+CnI0BEeLR L/XmPilk0h2SWj3IdQ/m1VsofxGXJS0= Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-201f2b7fe0dso54344745ad.1 for ; Tue, 27 Aug 2024 22:50:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824217; x=1725429017; 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=N47VMRtMS+23qmQV6QvpGjMmEbWavAKSyy/PH2d+fuI=; b=qZhRoZEATzsgp8gOAIf/ntVCetpaj1lDr5XzKz9ojspiWrdoiD+0qRGSbRfbWXa3s3 +0oHfmpT2dnbREsB92/0puE2qLSSow6pRSf1GdFDQbaimfr8QdDFw4aAmBA+Bcr4TMka RO5kbHI5WXfP2u6Oi1zinb5xO2yK7JaupD+OFA/XTEsX9f70KvQMIx1Vw5rRuNJNGu9Z 2MN/p/CAwMSBw23x4EMjP5UVrDsMW98iD72Rbnfy2BHIz5Hc8+39AG6TCYbAo9W13S7s V7krkYUOsHrMajkOTf4NhgupyQhvZ49X4VhXA8PQACakruae0boXOymlibYZEq8POjcJ X7Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824217; x=1725429017; 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=N47VMRtMS+23qmQV6QvpGjMmEbWavAKSyy/PH2d+fuI=; b=l8Gd5eo0HmJxr1+mTP5FS/mLdRsQVOiJrRf2dRws5QyuWBIxJAc+z16rv2ZY4HQcUq HTEKgZNRYVtSx3xxfAtqoyEAWC042e9bnI3+DZ/TTfo/ZEN5htOwmJ8Hf0Wk3e+Ly92u R3DExDeP1tH2RaBBEVtTFGfykZqmnFAwZxEVp4IeNXZOyeqYHZ2Cs7bHbD5GmeItWT7C 3tgFUxu4a8BTTiq+GVTEKriNNSf+WRLEj5GfLJS+ySV3WSLgfHSA2tsJ5PD8nf+SuiOS H1ML+ZSkeLHkMbaatBpVVwh/RZUggEX3HQvkXpJPbbL5tHhQw0U/sCZ0aVPsIS9Lzphl v6Sg== X-Forwarded-Encrypted: i=1; AJvYcCWXCWyj/ioxGjwynqZCc9DaHCyNJ6wYcGwWR0VDr/4aIvh5bJjyos/0wdQQ63RTBiHlyBg5EWccQQ==@kvack.org X-Gm-Message-State: AOJu0YyUFRuynF9oJ14ylMlFvV7PhiX/Ckfsf7L48HQ6s+Z3B7QioAUx +kmYzz9UUqFr+R47ZZDXWZdqC3zBGPaZVvXNkpIxY9BniAffRchrVLkyRf4Sp+M= X-Google-Smtp-Source: AGHT+IE/8VPZ5WR+s//SHKXEyZvEaL/le/g9NWegqdCzDXKzmKgVVr+pZGJ3+/nFrNKyDvBxKE7OYQ== X-Received: by 2002:a17:902:da87:b0:202:18de:b419 with SMTP id d9443c01a7336-2039e544ea3mr139583445ad.63.1724824217429; Tue, 27 Aug 2024 22:50:17 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:50:16 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:21 -0700 Subject: [PATCH 15/16] sparc: mm: Support MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-15-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=2007; i=charlie@rivosinc.com; h=from:subject:message-id; bh=wabvkTSjqwqq+1cwlxkGF9sQYYmBw7yR2/kPTnsB9SA=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XYlrm85cSrl9L9mw2HGFibquxLlDQQX5BVPY7r2Kn Fj9yFu3o5SFQYyDQVZMkYXnWgNz6x39sqOiZRNg5rAygQxh4OIUgInUNTIynHcLq9918a3O8avu Dw03fBV2dVbdxHna5i+P48xVwp561Qz/s5amcHn+vlr756VDtfCFS81padcPXfr2ZkdR7ZMDnv/ PsgMA X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspamd-Queue-Id: D46361C000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: mha3zigkdo3ri1trdiinw59cnit4itmj X-HE-Tag: 1724824218-817634 X-HE-Meta: U2FsdGVkX19gCnxGKhsup3EDVagyWSWGCYItc2V2j2Yi6BroDFvwN+6ddklIAXmzOFVuH9AOgNa1IgrIKvt9jQnAKy9J9ohY0CvnJZDGmdtO6PFeFpvpxCJfM0dnWddz1dCl4WJJn622m9Ikf7HXw2BiISYrrQsgqxISYIoFZYV5/QlByE1MH1I76Plo/K/QM1zu73KHVapXzWiuPpMiZK7zXh9+WcmV6WQFZ4wpc2qANMfmMhgEn27omJTqDm9vI9XqyUe+prE9W7Eul60oDZUKJfdf7UpRDQyrgnxlU6WMNcAvziV81JCZz2RwzfDe6EhmNiqqZe3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HRfUC9BPkp/EuB2QbWvVcVBFWQU7ZcNZI+g== 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: Add support for MAP_BELOW_HINT to mmap by restricting high_limit to addr when the flag is enabled. Signed-off-by: Charlie Jenkins --- arch/sparc/kernel/sys_sparc_64.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index d9c3b34ca744..b9ce9988551a 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c @@ -129,6 +129,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi info.length = len; info.low_limit = TASK_UNMAPPED_BASE; info.high_limit = min(task_size, VA_EXCLUDE_START); + if (flags & MAP_BELOW_HINT) + info.high_limit = MIN(info.high_limit, addr + len); info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0; info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); @@ -137,6 +139,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi VM_BUG_ON(addr != -ENOMEM); info.low_limit = VA_EXCLUDE_END; info.high_limit = task_size; + if (flags & MAP_BELOW_HINT) + info.high_limit = MIN(info.high_limit, addr + len); addr = vm_unmapped_area(&info); } @@ -192,6 +196,8 @@ 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) + info.high_limit = MIN(info.high_limit, addr + len); info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0; info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); @@ -207,6 +213,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 = STACK_TOP32; + if (flags & MAP_BELOW_HINT) + info.high_limit = MIN(info.high_limit, addr + len); addr = vm_unmapped_area(&info); }