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: 1977651 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=WMrFr1U/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-656-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wtwk03WZ7z1yfn for ; Wed, 28 Aug 2024 17:18:16 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Wtwk02Gm8z3005; Wed, 28 Aug 2024 17:18:16 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::633" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724824219; cv=none; b=BhYqfxJGUR+ZUMiPSbQVAwe2G84FWetulilpjUbNP1suV3fWczG9m+jXdWT9UBJe2SIjr3yVruE/LuiT7oCCOCwbdrfplV7Izn/IzbHESAIShs76MSvVmkJsMDX2JSIKAW0aG3VJ9eqpmqodlhJGS1nPwZbP+mh3ecNQ8yiaCiLQ7NcPMVBnyn3sd0XccIqTU4U4bv9DE9/ckuEKIYFbRWsmcVcYwEQr/GOPa0jUt0pMbBTkQTfwMTIA5pnwUDlOJ10Vd0P9oD38/a8eKnYfATpQq+cZfjfgp/0uQv43LFR+PcE0MVV5k62CjTYfMpeN+r4oV96QTDxARnzhekjuEA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724824219; c=relaxed/relaxed; bh=N47VMRtMS+23qmQV6QvpGjMmEbWavAKSyy/PH2d+fuI=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Google-Smtp-Source: X-Received:Received:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; b=cm/wcU8206RsME5L+NQI90T0LC5TwJlXaSwiqqWdyi2UAjevGO1Yp/C7tfYopxyByllVeXLLj5crj1+wZk/YtEwG58k3yxyZNgNSRVgcoO7FLsPfPIZlVvWe8Lm2XVvTv0ipHNVLPZ2VAaOggOutvCpv10a7U8q6FTp1Fc4G7QUJYTUBliMTUci4DFQWdhaBqGRQ7vxniL6NKB8B9GNOoCLaEUHy8pKeSFZR/ss5itBq53NkjZuXMdbxasWzWKJpmk+o4xNeKRIEXGthakCsKQs2oSeASOSj4vdxpVoVPdsR0uSUPD51L2uA8kbp7Yd4s5OEi6JmE1vC+dT4fg8/Mw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=WMrFr1U/; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::633; helo=mail-pl1-x633.google.com; envelope-from=charlie@rivosinc.com; receiver=lists.ozlabs.org) smtp.mailfrom=rivosinc.com Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=WMrFr1U/; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=rivosinc.com (client-ip=2607:f8b0:4864:20::633; helo=mail-pl1-x633.google.com; envelope-from=charlie@rivosinc.com; receiver=lists.ozlabs.org) Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WttmW1zn4z2y8l for ; Wed, 28 Aug 2024 15:50:19 +1000 (AEST) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-201f2b7fe0dso54344695ad.1 for ; Tue, 27 Aug 2024 22:50:19 -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=lists.ozlabs.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=WMrFr1U/Nqda3GLL/15+bSRmqbEuwdjHmFIoc08hjlfuDSSyUkOS+QjcMwRli2u44E 3/GHyaMa5YqRmc88/0VDofPNpUN4qxzuOqjSb8mswp6FrLxaHYbniYpQAgNzjBWtU1m6 t6osqTObtv9wx3ERgYhBoquFtgw1UKKZSeA2OX1aan7HU6RNMYRWyzEcrC9424r/e6+a 4o2z1qOxYRf65E9xWCNgEQFurk39/ds9nswvf/R5ud6iwzJn37sY5HXrWNm529hmJljV mODy+H30DIiUf0ya2/TpCkPgQ21+poWRtU34jx37Vvl+jxuxTyKmg1jGS1MomT6y7tDp jUtw== 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=UL09ka0LcY5M4iPR6QZtJik4AE675XG7H/urJqFAI3o+H7VOVGXWXADC931S16OzkV EzC7QH+8Vp3BbTYI5I9kDHMQRtMqK+KicLyeLW9HfoASmXyvJ4HQlL4Up0Y6ZwoH6dli Bhj2imwrgs1rqGVKiaXhrTpqojBVQsDrmZB+a5vYPyGbXHoKRltSgMC7tKNRLd1glayW iANI/+UheGC452gvQi9/q34ftf/pZKYvPJpDNf+ET2DGXkN6VnRHPNjW/A55GLLSKiX+ tuBnYMdG2a/EAGBSvS1ZoXeiAvvhC6VPtrV0+EgSn4X+XdgFQscAAMzb0XsvLWYqCdCi egXg== X-Forwarded-Encrypted: i=1; AJvYcCUCnXa+QTK3O5sofWY+xU9V5X/aCx5CNE03aQ9ZZ+L3c22Xjbygbdq0yoyyxGqSPWBNpeuiHTKGzRLD8RM=@lists.ozlabs.org X-Gm-Message-State: AOJu0YydMHG4klH9co8n+jFV3ZFQ8KGgT8VgZKNjJxG61BPXB4n7uXmX K3pvXkpMp4tGX371R3Q8bT7KyeGGw/93WfbXHQNJX7Rgwl9NjCN48u00ZVSqxRA= 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 X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: 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 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); }