From patchwork Wed Aug 28 05:49:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780619 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 607C8C5472D for ; Wed, 28 Aug 2024 05:49:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B43626B0085; Wed, 28 Aug 2024 01:49:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF2A06B0088; Wed, 28 Aug 2024 01:49:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 945EA6B0089; Wed, 28 Aug 2024 01:49:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 743186B0085 for ; Wed, 28 Aug 2024 01:49:33 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E4A56161CAF for ; Wed, 28 Aug 2024 05:49:32 +0000 (UTC) X-FDA: 82500576984.22.98B80C0 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf16.hostedemail.com (Postfix) with ESMTP id D5D61180007 for ; Wed, 28 Aug 2024 05:49:30 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=AAHmADj4; spf=pass (imf16.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.172 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=1724824083; 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=s842qMNTVJPdnaHjTgUH53HGzrqC8L35w1DIbWpmxjE=; b=y9qXoUCyfnXHtIEgbc6VrAwqW+IVpreh3ELHtccEwIA2tMgnblBewi/fdEQk/ehaBZhiQV nZaRyj7LoVu1NxzZWrJOpcFTxOY84linF9oieKTQOTEWi8O6+RngP47XanR0YriFghXQAt /CzRkaU1Xj24h+da7HHqUw8F628MdoE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824083; a=rsa-sha256; cv=none; b=coLZMycSzRr5JYDE7DLtCFQcWuABHpQ8IC3jrdWF8rbD3/LqHe1J6fuzbuoSaQ8I9Pqj+S bln9L2bwpfH0D1n7orThiQOjSs5BKA0pjj32J4G5rP6hFdo4aoHoAyQ3x7mepKcAxloLYw oPHuCj/daAaB4VDPAJIDQR6lWoEKT60= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=AAHmADj4; spf=pass (imf16.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-201fae21398so44795045ad.1 for ; Tue, 27 Aug 2024 22:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824169; x=1725428969; 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=s842qMNTVJPdnaHjTgUH53HGzrqC8L35w1DIbWpmxjE=; b=AAHmADj4lmFcLEMMjr8kV3b+f5EgFZ9KjXz7vC3AqSeSOugK+l3wo/GRj58iir7JpB u+L4k8fsFnfSMxk6XuynfhYoRYo3fHF70F0kzyhkM8V6WO/V+Ds4fOXrhR/N/yBchA9v PQXjg+/IS5gE8UcfBuW4Slkp9R6WsNyqRUcB9L9Op9+L2SNzfyvOG9A8O9JFGnGxlopf JBTz2oLIYcwzgP4M120gybd786F0/zlU8co6W9ve51jUy1H+Kzx8KRQqvUSyiub8u0X0 /AyqOTGy1smDIatWdC4kyGGFf4Q7e3MlaJfgPlbj2deWWVFZAeDKRRIOuno5JOwGPIld cPSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824169; x=1725428969; 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=s842qMNTVJPdnaHjTgUH53HGzrqC8L35w1DIbWpmxjE=; b=S+4iSqaOcZT50FmeK0GQd9Qzn5KHEZEzQd3Fln3zT08FqsagCv6mz1mRRlaHn/9DzG /R2bzOE/frwkIS0/MxnQzutEf9iWDotNoclWld8Y8L7T1ZFmJxu32nZAyZZCI7U4wy/M rnAjItD1MD3G+JTu+C+RvphDmDUbT3kGLCMGTLx87blMVWq5SERlHUw4L5rJBAV3cGqi OEqvNese+0d355jQEj4YoVrNLtreJ7gnwjecgkuPG5RFECHEi2Y/nwWAaU6+GcOsPVen 5FRpI6XVGeZ+gQzehF1ALaDCvXkPOVjUhpJJiJmH2mrnKsARqyONWl8BEHTdXm+g+ZYg 3U3w== X-Forwarded-Encrypted: i=1; AJvYcCWOtOdsbGFKgoxtp5YTMWhe6ekv2U2hG+5nfHwCgFRF/ygJ/OvfKw+1VeUbge6L0TkqGBavR4mOiA==@kvack.org X-Gm-Message-State: AOJu0Yy2JPzaUSZRo+pBwvNV88aIw5P4hHlHwtqRsZbCEOsIIZlMFXZk EUPQ52K0jn2MUtOz/bGBq5d5kHco4cm5ctielu9eMsjFqQogAkjL4t03281NFTE= X-Google-Smtp-Source: AGHT+IE7iBIF/ncsUM+UTT7p6QlENkfnsLUglL71vzMDiTXQo3W/0gxhDidIM3IPRiHs8W/EU5lCPQ== X-Received: by 2002:a17:902:ce83:b0:1fd:92a7:6ccc with SMTP id d9443c01a7336-204f9ba22b4mr11347335ad.30.1724824169192; Tue, 27 Aug 2024 22:49:29 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:49:28 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:07 -0700 Subject: [PATCH 01/16] mm: Add MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-1-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=1656; i=charlie@rivosinc.com; h=from:subject:message-id; bh=tmMz4K99F0U2eFjTmXZPsRyQ5BJlKhVYtlPfqgJsjxI=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XbFSzP1yPpXBlYea467kRPvaspyLaj1+ty58k+rfy b+vtHB1lLIwiHEwyIopsvBca2BuvaNfdlS0bALMHFYmkCEMXJwCMBGZFoa/UreElT5ecG2dxnH1 4+SJG05OW30u9uBl4X2J5vXXMs59v8LIcOvZs96dRZxGwS//rJlxOfEru+W5B7X39RYcjRI4YV7 3gA8A X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D5D61180007 X-Stat-Signature: fnemwqtcdimb3p9tnso88ay6k9sucjdd X-HE-Tag: 1724824170-21897 X-HE-Meta: U2FsdGVkX18gXkNxMrTP7a9wTaCtY5FDwOzhTd7BtIh2HqsKUg3f7R/tTA8GfRU5wRlJawX/7bPDX3srrKOaKWWgNlzxoBppCEFoapPSEMcYhkYA/NcgieBhrUZk02nkpwwmt2O60uklS25GopiWEd3Dt+Pcj5C4EJLZLkg0fiH5+xYfLL205MQw7XQRIpen6d8gbqadxOOZT/nGzXjeMfi97R5U5NoImhWg24EtoHh/yyHATBoZCpsBPQxJ5L9tJiGaUa/77Ozp2hMVQBocw46I2juqJn6zIvbcETjeGNl2BmzaPuR2s97lBmKi8anuzAEfGPwiOArEhWC0Dpl7JctXlo//e9ci8FPeMafR+pWKfGnLEwoxqmDM6GK52EfPuh5IG3an01CM3HkvTibPDCnGbpA/sjJofNwoGjdHo4nJNoDhu0Hjax+nZtd2FpBmK1WFx74FWgGpkhMnAlK6xHg4gO50c0a+BOsByFYiCEL4BBeImkWxRA5B36An0ZfmrBo4C4sHyvffQpmqFrCn5dQDTyrx0IIH9fGq3hXLH3bwm/KIsVwCiN3A3iEO7LE9Crf2Zuq984mb5FJhXHYbM51BQcWE12ZPKvxLBAi/Gt6RByke4xLm2ZNPHNYqrOyTceyHVk/TkhMBOa/uIrMKFBAMECVMml9sbP5Bq32O+zjQ27mxdUZrq9l36qlIa+ulPk279S/mosPzGncmUp+s1VawyQDVjg7fpLTsoeheEoMPnU2MbohDR1BIRv9w5ZWws+w3wqsST7SiRZLmUUQiIIQlTQ+O7cgJbJqlDRSOdYU3jJVxuPsIz/vbAIwylV4CACG1jjC+WgB0PJAUqu6A/sppDfuMAzKFNlBKNcbfBI9zAu8fpxLBdlxHfCGwEmyutI23IoLh6KjWO0s7tJwslma3+e2BZJ8maZIEfIxeGYKTboCmVdx2tAaa7pG9LPTEX0TCVC1L450GPMC2k58 O9jbHaKP P/j6Vg5BMClyeSLvOBKeuUxc+8mlO1H5bQk55IXYdpU4sYeXOTYgjffC00+SWyVt9bmHfyO+jK6x0ypAma2uANSpq8DwhkD4E+jOn9DnSBChUTDLh4zNnUA+CUo7Ouq3y8bnW48BNe1Dl8y8mEypc/3HatG/ttSWB5TqcSqHsyxXH0ytInIim6jDKvEfjq6c8oULSjiSNgSAUDkKcSpVR2QudBz5p3PpHLoNAXP3XtpwHpOSCancJlUN7pzyYcv818ulxLtzjuLOAO6O/rTatct+0DITV7ks9H3HdETvpgv6QikVT0LC8Cli1whWHtbMdUo2oVNLRwtt3QkL+LNkUacDTAD4C/MNOJmiNtT9YYj3xrpPjdao+BR7jZe1F8HoDXAWOnrZwXWBobqI2Cdb0+BZcU+/nnuqtneCxBIKI5s+I0pH7J6XeHPhhWg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000037, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Some applications rely on placing data in free bits addresses allocated by mmap. Various architectures (eg. x86, arm64, powerpc) restrict the address returned by mmap to be less than the maximum address space, unless the hint address is greater than this value. To make this behavior explicit and more versatile across all architectures, define a mmap flag that allows users to define an arbitrary upper limit on addresses returned by mmap. Signed-off-by: Charlie Jenkins --- include/uapi/asm-generic/mman-common.h | 1 + tools/include/uapi/asm-generic/mman-common.h | 1 + 2 files changed, 2 insertions(+) diff --git a/include/uapi/asm-generic/mman-common.h b/include/uapi/asm-generic/mman-common.h index 6ce1f1ceb432..03ac13d9aa37 100644 --- a/include/uapi/asm-generic/mman-common.h +++ b/include/uapi/asm-generic/mman-common.h @@ -32,6 +32,7 @@ #define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be * uninitialized */ +#define MAP_BELOW_HINT 0x8000000 /* give out address that is below (inclusive) hint address */ /* * Flags for mlock diff --git a/tools/include/uapi/asm-generic/mman-common.h b/tools/include/uapi/asm-generic/mman-common.h index 6ce1f1ceb432..03ac13d9aa37 100644 --- a/tools/include/uapi/asm-generic/mman-common.h +++ b/tools/include/uapi/asm-generic/mman-common.h @@ -32,6 +32,7 @@ #define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be * uninitialized */ +#define MAP_BELOW_HINT 0x8000000 /* give out address that is below (inclusive) hint address */ /* * Flags for mlock From patchwork Wed Aug 28 05:49:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780620 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 83EF2C5472D for ; Wed, 28 Aug 2024 05:49:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EEE506B0089; Wed, 28 Aug 2024 01:49:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E9C2D6B008A; Wed, 28 Aug 2024 01:49:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3C666B008C; Wed, 28 Aug 2024 01:49:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B4F2B6B0089 for ; Wed, 28 Aug 2024 01:49:36 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 721A9161CB1 for ; Wed, 28 Aug 2024 05:49:36 +0000 (UTC) X-FDA: 82500577152.08.5BA4EF6 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf08.hostedemail.com (Postfix) with ESMTP id 76806160007 for ; Wed, 28 Aug 2024 05:49:34 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=NtqiHepZ; dmarc=none; spf=pass (imf08.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824103; a=rsa-sha256; cv=none; b=7bP5NdzqTC68edkJXxHXpzHjuTW3GqzAc9iJVJbX0UYkeFpei8CeXXQnaTm7cWd8+AcHq3 3dQrNJMwBSqWe39KUYQmRespl61GIhOL3XsWP7+iKxxVqwFr5tu+o/Fh1O79OwWJjS0Pml 7Z/u8Np2JjKumbKtWYxKiEtmHa2u8gE= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=NtqiHepZ; dmarc=none; spf=pass (imf08.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.174 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=1724824103; 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=moiMY/9kOk6Xzt0Khn1FkF8wyTL4BDNBgOSp+BMugag=; b=fQ1rZVB2be76I9U4XFaIPURPNnHvmxFHaIusyIQgeBA8CS760BVByT+ZGcKXz2QjnT0x69 QkzRlGkIvFl5fGrXWBY17sPJXvwr5l/UdQZJNu7Ir5Q0JTzhArFoDJxhuhhrGf8Eekex1A g65m++POUrhG7CTJBr9pd6iu+gH9esU= Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-20219a0fe4dso62940865ad.2 for ; Tue, 27 Aug 2024 22:49:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824173; x=1725428973; 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=moiMY/9kOk6Xzt0Khn1FkF8wyTL4BDNBgOSp+BMugag=; b=NtqiHepZMNG2HegPNMXUXu/mW1UI1sR15n/WrBka9HM9YeL7NAFrZ/R3D0TYNnq5I3 KdRABvakf1xcSTMLqEqCxdaS8pE1biCUjE2SNDxB99d1c+yUM6mMLeYBKEPvqoXrFMdP 0uSTjUGf8z0U8uyT/fVXyDUKiLNO5PXpBVtuuIYFY3cjePMSDa9zK+ElpFLnF6MCZFkm L6v2DUGaW1njZ9nlrV6HVkB0ZyiJmmzlidOb/JU7Um0jnshkQ1jmilwScXnH4BvuGnpO s+wDIHBDKNmOeIRv0ZMvMFFTwOqRW7ISfuoIQ+HugrL/ry3CO5eHTaE9JlQ3Im9uwaKn WA1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824173; x=1725428973; 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=moiMY/9kOk6Xzt0Khn1FkF8wyTL4BDNBgOSp+BMugag=; b=wqDzkLK/zsjeQsTQpcn2XhJaMqVzt929dXI/RBBlXrr/iO298QxZDINaq/JL24k6Wn 7ybpOb7G0wUn7ByGuAycJQWRQHO4w/trOUKF9af1oPx4jcAlR/lSowL/wsGbi5wqXfNs e06mIQ0oLuR4MqZWYyXlQZcPmSDUfxugQtpk93CMM9M/IgdCr+k41yukuqxAj9APERd6 mpvKCnhVyoxKY3BpUwWSPMyqRTiXouOQanG4Rz2xjsodk4LUjOwmqpco9Zpfy+9gVScF HVlXDCR2lQiYkHmPNMB9dHxzaIUNwz/9bypPjBp7FTGlJIh+Tqi/yi3ZrBKX0VG5+99Q TMGA== X-Forwarded-Encrypted: i=1; AJvYcCUd88EjYnigjrb8GnI4wjaQ1hOaBY/ZmEAqON8765SvHVOdRZpQsKqrWv8yiNClLe7GOFb89hbeqw==@kvack.org X-Gm-Message-State: AOJu0Yw9rRTC2JvTXxaaBswqE/MGsVXRDulAu0sa2pKkLPIxNn6aXIrM kiT5oX6JuFE5ANwQZGDm9whutxzsSiXyGQA5n9/tR+EoRA7ztjWhpM/Bwnf8UHA= X-Google-Smtp-Source: AGHT+IE+xcDspGauSp7IVmRnQSeJseOyw+wVLX4elXR4/BGbU1fHY0MaCzZG4/pxtEucaF+r97Z9DQ== X-Received: by 2002:a17:903:124b:b0:202:4079:1c19 with SMTP id d9443c01a7336-2039e47589dmr164242605ad.14.1724824172722; Tue, 27 Aug 2024 22:49:32 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:49:31 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:08 -0700 Subject: [PATCH 02/16] riscv: mm: Do not restrict mmap address based on hint MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-2-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=2260; i=charlie@rivosinc.com; h=from:subject:message-id; bh=YMF9irkRUC4sRvnkdcE8hTIaJNmeFPHDQEKHg4RlOyw=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XbEGN52ULpq4/39venW688upWgwFDj9spqW3rOd57 Wdme6Ooo5SFQYyDQVZMkYXnWgNz6x39sqOiZRNg5rAygQxh4OIUgInoxjIyLPq831JpspB17kOr jRV1b1+9OjXz6TVOvZStd2IFbrHtWM3wV9buiFXmKu3sWVt1RJfzLlfjNmD+lbK6aQ3rc0+mG/t jOAA= X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 76806160007 X-Stat-Signature: z3xgg1dgtxnrr7unafrbzdxjbt4xxyni X-Rspam-User: X-HE-Tag: 1724824174-390674 X-HE-Meta: U2FsdGVkX1/D3NBC1K7TFD/HK4LutTkhi+Qc3pa9QHk+rZYQwmwu6pLIcruWBNZ9/pkgP0RbaaWpZouXs0qA3IGyzBBHzuQW2FWMx12nsxF9X4ARSbCzZrkpPtg9XYJAztqCypTfMf1MyNzm+zEgTAVXaaBpD/SiJ+edmhCtnnw/q8QKphg1gRaGs++zc6Vs1ENx96AEmPUQXRsJUdm0z4yHzma5cxz1aFmv7kGiU7ArevolPkosPLWFXvYKRKkwgY/jfjWgFowiGh+eehTlqdgA/jwhoJMEwrPmtpQQB7aAUZSD+2RzoM9ZtuuEH8/9pnPLd6YLewIpB4FQceQZNc8LJg6hwUbKaR8Mp1TT2JSiQ6D7oQGcp+ZEBgdkukFwGic0OyC+Ghv5kVHXmNspdDZ9CjjUVeva3/sjRgEuGzkSFNnmWbiss8JAUQWIlrqUU2+RfrAQGrfMIUI90gM9xVuEYifi3R3nato84VKX0ajOpRdqiYMbhDjincbH+nkWqULMljEobBOaj4SL8/cH+aMYoEEVlIsJpM1PzDeiZg2SKV+EfX5L6kjyRkL6J69qqYcr44hVSoPYhndTP48QWlrTAUkEEOBMuRbWpTmAbLxJkHWbi4Rm9i4rKU9lfO4Pex6PFiES307Z1cjyw0q7Dy6rQdYCRtkXPzqZdTi8hwRgVzHjtemLONjqp5QB/sXv5SstPbZRfRj2qHEIF+Q6RT7IcH77d9XaFBx/vx/XxF/GJ+CrShUuqh//TyWWo/nC22ijFAuTHwcQm5CY78qkG4/z7n81krYgMSEsh3UEyFnN1ULn/yJvpY05Gd8jxxyl493bsYqSny0I/dPt8d32XYwW79n1gy7fcLWAEbY/AHSnU6o18yVocdHmD+Hf3ZhYYx7DGNeoFb7u7+Hemv8xekg5pAYqHmBS3EfvadY8GbhULq45HBdJ0fYICJTzyc8vLDmYcyJNvLwlwr56Nta exoC3+Yf fjB4W5qSqGpOM4vMN1IlmQB1qU6cM0GGyht5BFhN7guuJnLv1e17jRgb8ve8vxw4v+XNcuvgs4EdSBbmwBNJ9gB9d5S8gBMEyxVD+P9i27APzGRe/g+fF3QmN32yiVSZQOwDIYnsk/ulXxe2+5iY2PrLTyJf328s05eqv6slj563M0Lq6pVyYkLPOC9992JtY7hEOsSMTE8WUfh9imIxuYj6VkJEFFLTIYxn6R1h9YurcVqyTOw5zXCxAJCKyKilB4p+7s8oZpWnc0mYXjiXhR+1LdTe02ZN1qSg4CKOyE8JMPiGu/17jMV4bC1TfbgJcT2cUY+g6FJZstq950/6KnQ/wAi0Vyt1Hd6GyEmSlQhCMifrZz0ZHFpbVzyBBNfJbWge8i0kAe9gPHyNdW1QmKzrk4yqTTciJm6ZEmgEaAKTnze3c9eRNCf+SDnMJjEeZVfvt X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 hint address should not forcefully restrict the addresses returned by mmap as this causes mmap to report ENOMEM when there is memory still available. Signed-off-by: Charlie Jenkins Fixes: b5b4287accd7 ("riscv: mm: Use hint address in mmap if available") Fixes: add2cc6b6515 ("RISC-V: mm: Restrict address space for sv39,sv48,sv57") Closes: https://lore.kernel.org/linux-kernel/ZbxTNjQPFKBatMq+@ghost/T/#mccb1890466bf5a488c9ce7441e57e42271895765 --- This patch is pulled from [1] for ease of review of this series. Link: https://lore.kernel.org/lkml/20240826-riscv_mmap-v1-2-cd8962afe47f@rivosinc.com/T/ [1] --- arch/riscv/include/asm/processor.h | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index 8702b8721a27..1015f2a49917 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -14,36 +14,14 @@ #include -/* - * addr is a hint to the maximum userspace address that mmap should provide, so - * this macro needs to return the largest address space available so that - * mmap_end < addr, being mmap_end the top of that address space. - * See Documentation/arch/riscv/vm-layout.rst for more details. - */ #define arch_get_mmap_end(addr, len, flags) \ ({ \ - unsigned long mmap_end; \ - typeof(addr) _addr = (addr); \ - if ((_addr) == 0 || is_compat_task() || \ - ((_addr + len) > BIT(VA_BITS - 1))) \ - mmap_end = STACK_TOP_MAX; \ - else \ - mmap_end = (_addr + len); \ - mmap_end; \ + STACK_TOP_MAX; \ }) -#define arch_get_mmap_base(addr, base) \ +#define arch_get_mmap_base(addr, base, flags) \ ({ \ - unsigned long mmap_base; \ - typeof(addr) _addr = (addr); \ - typeof(base) _base = (base); \ - unsigned long rnd_gap = DEFAULT_MAP_WINDOW - (_base); \ - if ((_addr) == 0 || is_compat_task() || \ - ((_addr + len) > BIT(VA_BITS - 1))) \ - mmap_base = (_base); \ - else \ - mmap_base = (_addr + len) - rnd_gap; \ - mmap_base; \ + base; \ }) #ifdef CONFIG_64BIT 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+aZwfulm1bH3cCC4elZt36mRQEFUOayB8jd8oO1UpOmL2W6soAMTSx08UrinNY5wczfOBn+zC9PRZEsqhSzDKF+AtzF1neteokpGwQVEsTojAiuacrVH6WrLEQHCUFnab+cmBVahZGLsLNnwVoJ6+R6eZkJpRPccHVrdoRN/W/leIvZJm6LBTmoxD5I1+1xzHMTz0DQNYqCIpvx7GsR0GF/KnbGuZXZQh8KPJZDy1rScob5jARgagr6Xk3dDJQhZAbjChh0HYnNtmAr5GLlEd+acGYF0k423sLjzBmmBfy6wjBFixtLxBcq9EeI4lZKaPibM0QQ0GAX5joJlnrdJgj9p2BiRAUB6FATe1YBg6ktQ/H1TgRrthk8B/p0UVbcbodNSjiHGrBe1GerT91igFeKIjGQdg2UvU33VwSbUxWOLymN1iZUtZQG73nwiPUeRMsAw8jYJ7JCbWmTgSF6ovPnBj/gKpBoE/gkIaKD8CnaitIdke1f99j/PyMnxl4xW32wT5OwGmkMdVxIQA4GxsCYavMGi2L/b+j/N4606exp6lqjH3tfic5lFjAJJckAhvGY7bvX5elLgZeQd2f+rZ0IwvJ5y6l+mEihiJNm/Gaxoppx6f+AMRJ/sEKWxqubMx7oQyTE iI6mLcdS SqKVKYxOzjeReCrHpM27PjpJUGBjds7LeB0VhBVcdcN6/9/YxyVkSJ+ZEi2MY/DxoScQVAPBbUVU/bLtv9DfCnG0oswGOzvC7rZ8S4OA3e87ZsYAnZE8duWlYJCjVz1AzG3XqPX9W8JEU4l7QUoHnqhPgh8mglSXewiCxB5UdNRwSitXLVDSoSPuf0nuhirgSjXfDTGIkRsFMQY2rYI8uJNiY2Dzoqg7yP1yfQJkwglNctC/M36JSV7bxjBKP8a+igMbJbbEVFmom2Uc+1b4FBb2F2/t0AISOeA+RG+rLnHA5OOP1mWOOLrjsLe/EwHzVQ3Tc9U7bDYFHqGRVxDi2PaHEVR3bFH63c03VLhmF4ix1QzJcsuVyMZw/Fl3FxNaOi3VA+LZVxB9b8VbDeHHAlhwhIdcBkq0rVTc1dNk3LZS/d6YWL0VNz+vqEg== 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); /* From patchwork Wed Aug 28 05:49:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780622 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 BA2AFC5474E for ; Wed, 28 Aug 2024 05:49:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32D0F6B0093; Wed, 28 Aug 2024 01:49:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DCB16B0095; Wed, 28 Aug 2024 01:49:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 156E66B0096; Wed, 28 Aug 2024 01:49:44 -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 ECE926B0093 for ; Wed, 28 Aug 2024 01:49:43 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 763FE141CF1 for ; Wed, 28 Aug 2024 05:49:43 +0000 (UTC) X-FDA: 82500577446.17.3E55809 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf11.hostedemail.com (Postfix) with ESMTP id 6BE9640006 for ; Wed, 28 Aug 2024 05:49:41 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=VwM0UOSr; spf=pass (imf11.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.210.176 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=1724824094; 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=g+f5iieqZfHqFwlVhHOpYZvOeyZcJe//7AT/XT4juc0=; b=vjRXd7rz0JM3s5YB0HRyxMx1Fv3BliF2ObYo7rKi0EsvdsSHtQaLBAQz3E9O9RMooeykFv Sofl5oluQOvAc2pBoGnGnpWp2acDUwmZzDuq+XfnhY67Q7EfCVfBwOzf7xiS402YMa7JvF N+Spq1q6zE2r03LP+8HwlVGVsrLagrs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824094; a=rsa-sha256; cv=none; b=O51P5i/JsjUKaiGiB5xPpKGNhbEkSFOjvQKRMpfj0hjp7OaSr909yX7I9PLbG8m7zgLDyF dK1zMT/eTKXrbGglRWr1P+aVJMPcFAr2i7ilVH68Ypl5fu1O1vg8Ou9yMSF3ghU3fXNShE c67MHK+QrWAINTXdDud1p8ly0MmtkIg= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=VwM0UOSr; spf=pass (imf11.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-7141d7b270dso4851312b3a.2 for ; Tue, 27 Aug 2024 22:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824180; x=1725428980; 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=g+f5iieqZfHqFwlVhHOpYZvOeyZcJe//7AT/XT4juc0=; b=VwM0UOSrbPhfyDksylqodnvRjlEj31NlduKkgxwBrMsyzoMvOvXN7gdDI4mzNNiyAo wixaHGTDstyigOITXATp//nNynAo4GT3cWyTIdRRvBGticMWuxjDQ+DgPCOyhQUW2XCP zL5o4ldnvTdMyzT+xuGedWvrdbIreiEYjKZ330UNmAZdek/VHZuzFM9UC26n4AvZ+bZH gvcs9tTXBOrzVlBCq47i8aJV1fAIcPHH96Elf4a1RT8C0cBMjc51zbwPAeCnPjghD/v1 4oaPTlHo93UxFtAY2qPyGkJsUjekkjYoD9r+ypGoo4oia7aJQ6rlBDixuez4orFDpE4L Bfqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824180; x=1725428980; 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=g+f5iieqZfHqFwlVhHOpYZvOeyZcJe//7AT/XT4juc0=; b=vqjzO9cQXwKMQe1fQoCeBLwxDvEACBC1ZUFVcSOx1mW3+xUkAM+iWByDNlaTeqwP/B VY4KlmS8xqXrkZrOfjaPbE0PF6HzOUqOU4BABygebP7YvZah8lucvkN+DlCAD92vzthN sCnWqAxuFoN2ssSPBXKM7SOtRvs63YqPkdP0JBUsWlHbGreueF8pjL9puMcnsN80BF/8 Ws9Gw6b4eF8na5Ra5epEgZlJEHmZncME1TG99X6vLgfly6P/bcVGMsHbPIQllxgYISxM HG37CN0Sm38PoKg7gUou3nioi+cs4XRKBl2vHEFVOi2v1F/7P6LLDUzMXpwe3KZIyuuH /MDg== X-Forwarded-Encrypted: i=1; AJvYcCWp6dwoKRegjehSBG2FTYIijYiEd4IiaNZ3JAqe+CdKl+9WTHhclfl2ciwVk1qX2jpzrF4Wne6wvA==@kvack.org X-Gm-Message-State: AOJu0Yw43lQgjVqnEh7z8iiL8iz1ziJq6bvdzKu+i26qN8seCDEmSMZE JG/RciEkiEs75qPjQnhA5PF8iVA9MrRPybyxJMcuLkfhIQKGfoyndIZoZn2oiww= X-Google-Smtp-Source: AGHT+IGKYEbmAbccdwLglj8Rtz7Ncms8BNc+Vjhrih2XUvI/cV2bfefpghFryVXCiPvCQUUiKdRNjQ== X-Received: by 2002:a05:6a21:3401:b0:1c6:a777:4cfa with SMTP id adf61e73a8af0-1cc8b475035mr13030363637.13.1724824179851; Tue, 27 Aug 2024 22:49:39 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:49:39 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:10 -0700 Subject: [PATCH 04/16] mm: Add generic MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-4-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=2165; i=charlie@rivosinc.com; h=from:subject:message-id; bh=+G9/grHdHxL6H0Lnh65S6ISh5epJb2mrAov/AP0hs9c=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XXGZXkeVtgeold2b3dqjkt+vEXMu6H6oc1bJNYtbJ 3aetlzTUcrCIMbBICumyMJzrYG59Y5+2VHRsgkwc1iZQIYwcHEKwERWFTEyNKap9S5rOHHkFBPT SkUp8yq1Cd/4ljyftDBFnmW663I5b4Z/RluSpK/6drw7JD8vOuPN75znwc73OQp/v/2R9GK2Tfl mPgA= X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6BE9640006 X-Stat-Signature: 9xrqjbyy85r3aisdt9uy4osrg56mpziw X-HE-Tag: 1724824181-658656 X-HE-Meta: U2FsdGVkX1+o7lvWxXlUdLhaDJLguY1SUPIi87DoHCkjTq1kcL+sTuVfSLt+Ths977UjwZGr/mAd8o6fuAiy5hg5DFXXutnJBfAGjkC+BSh25wSZjOSHGYNRoDGoS9TpGJ3Jh021Gbd02bb56WmkFY3466I4+6wCnQQ1aZjDs6fwgWmG7MSHNXBbI19sFdEE4Fj5dX5kapOS27poHaPnkrnDHhhVE+P42MwaRW3JnVqWuj3/PtX2zPj7SWEHP+Yhd7LXtu0pgWHFm/4gwaegyqMAFTAzu/rCSaMbmb1De5NnZ6CnUCnctiwMLyK49DtV1peXLBo/P3ubnRDmpu5xWsF2+sa/raq763CBAkJtmF7PDKkDItZQteMJcIjHkyxYAGz/W9G5nedQJudGePxr4x+j4GCS3gI8rr3bH1DaniEkmaG8KiI+PG9SRrZTZIwk9YAFWNeFIg19/E1YWHqdJy66yoxC1QcD7tFxR7PUO60/UmGzY3TiuOj6Nx/osaN//4f5GYGVaPVMvj7Dqe4JIWHGoudmVIPKuLgy/c/pDK7Eiiv20Mfe1Fw12JfL2fHb545b1gdlvgwqBehUvgPhgR9sLPlTWAwR2TqvqcoaQbrGei7HROzoIMlamTbU4agIdA0lhgeOCXs1s93QztlKddi7ZuuwVJeVp0IgtMmUCYIrsIufm1KhL3wRdBFb2tAkfW9lQbJY0TZJltRet69nRnL7txdfur5bgc89G/RtWFNsBG73RT95u1VH+LRQYjInS+A+0LVkn9FQaJVv3nijaGX4u+VhFqr1y7/aX8bQRf1p8KA79i8ktyfKbBxmLfo5MdfljLJnqoHn+b9LBxYv6VGK2nqFU/c492ONkO8i/yDW5EQBu5mEz2KnzNo9cwEnR9HhBfZ1003GQZexLaJihDXEBCOrtgWT4w1dyTIvQ3Ucu+HOwN1O2yCobqBw3d5T4OQ/al67ekKVWzTOQLA H9jQFbgN 8C3QntELKb0hmcJspazJTmm5nZZcu8o1EW4gOkNGrlsMh8ULoxKEUw+DWZixWZQl2LldalIDiu34FghIkQmflD7vKIoWf2A0+rW/oHpwXuB6JJgsGkczXDHV/91uNGHAvbfTjTZdwHDOJSWJJmfyKyfJz6e5tgXaJwL63n9cGXTTZ3rkbVo0FnuYvoQNk6i6S7OEbdoS5Lg05Q1YfXlEwKBlHp40GzzIkUKZy/Cmcl8OJWPoWrYYvSystDSTV/G9VoRU4hQodTM6l0W56Jhta+V5PuvyW9Cg4Xm2r86THBYYDQXJqkzFNSpv53M3GH00roggjPGQaT46fh5wFqQKhOJ6JjXZcOPLwJVTjpILEfWtCZum8ob6NXvNMIWKQlvxVpj6TwurgJChW5/tF+yj2LPKxvI3SQdIDRzROhg0r2lTBOCgL5KZLqCIbUoDJnZ+VsTp28G9hfPA5FoJ+zL0Cx+3vNA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Make the generic implementation of arch_get_mmap_base() and arch_get_mmap_end() support MAP_BELOW_HINT. Signed-off-by: Charlie Jenkins --- include/linux/sched/mm.h | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 265b43855d0b..c350bb5ac0a2 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -9,6 +9,7 @@ #include #include #include +#include /* * Routines for handling mm_structs @@ -170,11 +171,40 @@ static inline void mm_update_next_owner(struct mm_struct *mm) #ifdef CONFIG_MMU #ifndef arch_get_mmap_end -#define arch_get_mmap_end(addr, len, flags) (TASK_SIZE) +#define arch_get_mmap_end(addr, len, flags) \ +({ \ + unsigned long mmap_end; \ + typeof(flags) _flags = (flags); \ + typeof(addr) _addr = (addr); \ + typeof(len) _len = (len); \ + mmap_end = TASK_SIZE; \ + if (_flags & MAP_BELOW_HINT && _addr != 0) \ + mmap_end = MIN(mmap_end, _addr + _len); \ + mmap_end; \ +}) #endif #ifndef arch_get_mmap_base -#define arch_get_mmap_base(addr, len, base, flags) (base) +/* + * rnd_gap is defined to be (STACK_TOP - _base) due to the definition of + * mmap_base in mm/util.c + * + * Assumes ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT, which all architectures that + * implement generic mmap use + */ +#define arch_get_mmap_base(addr, len, base, flags) \ +({ \ + unsigned long mmap_base; \ + typeof(flags) _flags = (flags); \ + typeof(addr) _addr = (addr); \ + typeof(base) _base = (base); \ + typeof(len) _len = (len); \ + unsigned long rnd_gap = STACK_TOP - _base; \ + mmap_base = _base; \ + if (_flags & MAP_BELOW_HINT && _addr != 0) \ + mmap_base = MIN(mmap_base, (_addr + _len) - rnd_gap); \ + mmap_base; \ +}) #endif extern void arch_pick_mmap_layout(struct mm_struct *mm, From patchwork Wed Aug 28 05:49:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780623 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 C5233C5474A for ; Wed, 28 Aug 2024 05:49:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 576B26B0096; Wed, 28 Aug 2024 01:49:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5274E6B0098; Wed, 28 Aug 2024 01:49:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C7A16B0099; Wed, 28 Aug 2024 01:49:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1DE2D6B0096 for ; Wed, 28 Aug 2024 01:49:47 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BD40D141CBB for ; Wed, 28 Aug 2024 05:49:46 +0000 (UTC) X-FDA: 82500577572.02.C98FD6E Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf15.hostedemail.com (Postfix) with ESMTP id C87FCA0013 for ; Wed, 28 Aug 2024 05:49:44 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="IgSu/Pbh"; spf=pass (imf15.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.177 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=1724824141; 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=Q5srBcKEXlmg65Adrhp9lVjL7ktMhhBJWYWob6ko31g=; b=tBnK6/tVY3seYnhVH1Yxu5gOdVZi3wS6H2I/t+3Tp8sSluzGv4rPSGTGJ5seW4yjOPadZQ fnJiGm/b/VarXSFfFWC6o5dhVeee60B8VKGK5iuNiGnYnuq/0ViiNEDmBSOTi1DKMVNKZJ XBzJlp2j1/1BzHx9w5IYXFsDkTDuCXc= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="IgSu/Pbh"; spf=pass (imf15.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824141; a=rsa-sha256; cv=none; b=jn/bAF3Sg2Amid+kReraXEMgwP7pxz6p0+351ZJWUyxgdsOVgCTXxqHyU0obc5xxW5fj0t 4IjoTHXoDZ90FaVeO6qHHzbzzz9CFNWVUfPEWuJifB5bT2Sx12gvnkbnQXLsp4bAQPvwns EOzkloXOUFYuoqblgJiDBsxlS+eQZYU= Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-201f7fb09f6so54511005ad.2 for ; Tue, 27 Aug 2024 22:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824183; x=1725428983; 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=Q5srBcKEXlmg65Adrhp9lVjL7ktMhhBJWYWob6ko31g=; b=IgSu/Pbh9ZtcXpYereWQDkMMoS/8ica9w/m80YJ+jDKmGMcK5tixPqYryzuzfmIya/ 7EHjW8eeIe7W0df4YVu5nZc0xzSVnroWNRsFa42dInDBbu3KPIF0OG2GMCDmxDuM2Cl0 hpXjuHwOtwhIVkXTsdDMfuZydf1JZRAJbP6uO8zUlR1ub2f3g5T+GrpRjmrp+Q5WkdcX hSQvJPoQY9nPOk4t9j25NTp/eXltYoJlo3ZFPHXZHvOMIxjUD1ZA57lVdhQ0Sq8N04Xx pUYrdJ/gcny22miBgeqz50b1PydkF1uzFvCOZ7F8LVxBAj4AbWruwxrDkjdsSzGK/PKv MeYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824183; x=1725428983; 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=Q5srBcKEXlmg65Adrhp9lVjL7ktMhhBJWYWob6ko31g=; b=dYp9dgtU/MFVXaJrmdYTeFnlf8Qh6zPR0vYhya5md0/b9vgJWvIlrnTP0AKJttB1R7 XWChl4sxlZ7NV5sNnJDKwg/1TTyej/921dLbivSMsizeZGTTJQM8Np5EQQ57jJRANeJU 5VaQEZszrkztg6KVb7eLD/aiL/PrmLOcYhdwJU8rVnp2unY1fjOmtDdl85VG1zH5e7zq ZieSxLpxy2+jhA8IJqejBg8BrdYgRYlGaDVVEIoRjLtAglVgzzSJFwya/7Su//aAUGzo HrC3KgebaqMht+xHjhb/lzqfxloRR/IjlAmf4uw1/n7c3FZLUaepLxmnQjXVGUSu7c+e 7eTQ== X-Forwarded-Encrypted: i=1; AJvYcCVHib1JbjDzTYYe0lWB4zsKYevQpmQ/W3NYQuRqinCnUC7Tk/Zuh7nIYCava1MwY6g/KOFpUpdGsg==@kvack.org X-Gm-Message-State: AOJu0YwZ33OzoemVe4UFEFRMVJLL4O83N2eUwihVZGON3/HcB/LIhzUb 9mVzbEL20Sm7Siz0c9IsDzvFwyJig+9Gl3W/IzU4YyIol6a4+r9oOgqRI9J6Msg= X-Google-Smtp-Source: AGHT+IGHu+eM9GywkA2KKhkiXH1gwQVKDtYtrmu0o3xp962KqVz7yKVZ3UFfIj7ogPOJug6LrKMhnQ== X-Received: by 2002:a17:902:e54c:b0:1fb:3474:9500 with SMTP id d9443c01a7336-2039e4ab846mr148619915ad.27.1724824183237; Tue, 27 Aug 2024 22:49:43 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:49:42 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:11 -0700 Subject: [PATCH 05/16] riscv: mm: Support MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-5-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=921; i=charlie@rivosinc.com; h=from:subject:message-id; bh=h9Jl0isly8hfO1RunVOJNqZoeZvdanuDoXET0lufwJg=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XXFHufOLGl2Wf1oQkLR82ZWndTOfPt314eCzeyv3r BZKWtO7oKOUhUGMg0FWTJGF51oDc+sd/bKjomUTYOawMoEMYeDiFICJNPxjZOjefGX9Tl/G6Irp nxS+dN0zOpEeMVEk78LzG1JnNgQw8RYzMpwwaro+TU52Snefw54npdeqTGoNrXMnik1KMY5Wjl7 KxwgA X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: C87FCA0013 X-Stat-Signature: yi6wpkxa5yrwidpmzt186ohfis8kngnu X-HE-Tag: 1724824184-688803 X-HE-Meta: U2FsdGVkX1+md+gMP4GPWc09i1xn4PXMtji90yTnYeIHnFGMUh/NdQw2HLaEBrFt55v3anHigOMce9RzCnC2wbo2SW9AyQC28LwnfH84W7IIP92NilCay8IPJINOzHB+MhYAU/OttSSHqZaznv9yvqJwmpYCdJ3CmEppuNpFdo+dk1sqin5DW61xBClKDEuC4Aq34Q1wB83xuVW5kDpC2enwwNawlkkjWhcbd0vF5GdYZgiZ/EI7EwIdC/cB+2puA9NR79JX4SjCztb7USiBfC7pCAw8FPOrn0QMbFaofsPqwKkL3R7QktkuDV4qlk0aoMR7virzVPGh+Y9iPyuPZ8C01lKewcecO/RWiAE/YcPAcgl02N62g8+rvReiAAOCnDpwrqoK5GvgULi6z0yOl7fFF+1yD8WB+WCbvEUZzXwaZoC58zqSveZMVjIBaiPFkMNuFFQDPUftV49ogMefootrlH/YJj4LHr5fAGPhaRO7l4nUp5XaY7xdPLOIT4NvgUoJAYLukG4s9r+6O7GeTuxvBGrg4PiZteCUoKCJhdrVpeODXvbx7mw09O3My05hJexk85p9I1tiDT3zRHz2/YR4Xs4ppq6R1DXl6pSd+l26BqOGiodxt9H/0rtCWcwbbAvVxA2KdoPn9JkX49vzfYTFaT/rYpvEYb5anFYs0k8xOKnzkaU0i4lbfQWYarrPctKT91/tiqCVGSo1DQcih1rjIhiYmvXApfZxoHFK2mLQhEbhkEj3xJirjwXUs7H+LU+61Wl2Rv4I1UgnoyOFM6faYF+wVNx5FWS1rXOv3x++Uz0bvBL361xmsgeL/ZFtt3lGByQ3IhIwMaJ3/L00o01pkD8bOXCsa0qxXPqodpOhW5rSpreLFbHTRrXEEUZDPLMaF4Rs729GX0PXpsZIUFCUVkICWlCdJ9YTnmX5Zju6ZPAC3sXNJirbkHmDAC8i3edrjeN57504qsNOVpG EsklB8u+ Y+wW0hu2S6ig4fZmDxSEVZnOseF+9nAOLup8PLVenYHZoDaTMl3E+u3EkTX8L7p4C+rjjj4d3LW7zHP316Yq6AufNJ7LXX6DCJTEK4+r1pg6BM12MFJiSpAboLXJ9EMf3hjdieCeEhJlj+fn83KLcGDMmUFgxCPuOlwH/rTD2eaq9oYe/D1/Iax2gt9XWAah4zAcGCFegbO0VeNu0QrUuFoEyLhIpweoZhljX9+qdJ9RHL8aOT5WIvCsrxydpFJCRlMb6SlP8r/OrKLnqnN9CWa0scE9TI3MRd6mUyn++9CmOnL6NuOv72uRlMeY4gcK7EoIul0WXJBB1iMH9+QX/uHxuR5wZ3uHA5f45qQrOWZeVurgyg4IcUZF/41pXIEs1oyWzERIsnhAi7RQHgcBarew7EVpOyRoyMwkHM3ZHjVl6c4AcN4oml9qmdg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000369, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When adding support for MAP_BELOW_HINT, the riscv implementation becomes identical to the default implementation, so arch_get_mmap_base() and arch_get_mmap_end() can be removed. Signed-off-by: Charlie Jenkins --- arch/riscv/include/asm/processor.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index 7ff559bf46f2..20b4ba7d32be 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -14,16 +14,6 @@ #include -#define arch_get_mmap_end(addr, len, flags) \ -({ \ - STACK_TOP_MAX; \ -}) - -#define arch_get_mmap_base(addr, len, base, flags) \ -({ \ - base; \ -}) - #ifdef CONFIG_64BIT #define DEFAULT_MAP_WINDOW (UL(1) << (MMAP_VA_BITS - 1)) #define STACK_TOP_MAX TASK_SIZE_64 From patchwork Wed Aug 28 05:49:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780624 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 4C899C5474A for ; Wed, 28 Aug 2024 05:49:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC9A46B0099; Wed, 28 Aug 2024 01:49:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7AE26B009A; Wed, 28 Aug 2024 01:49:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B43B66B009B; Wed, 28 Aug 2024 01:49:50 -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 94F5D6B0099 for ; Wed, 28 Aug 2024 01:49:50 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4D2A4141B4B for ; Wed, 28 Aug 2024 05:49:50 +0000 (UTC) X-FDA: 82500577740.11.8908573 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf20.hostedemail.com (Postfix) with ESMTP id 55A151C000C for ; Wed, 28 Aug 2024 05:49:48 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=bK98eUWD; spf=pass (imf20.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.173 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=1724824100; 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=fVwUzK3Wi136bLF1beJbPIYrhSgOvSQiUtDec+6VrAU=; b=ScetaDBbKg8hrsy4v/Hx98BCGFTU9lhwQeUMeMlFjDLCU06wUC/c8Jf25HYQXVpOk0K2FW A3zKK0KExmUJEZmneDKIn63lOejfgPoUG05fMcjmkVklQBsisRlumzqUZ5vglW6maXXUgv 5tdzK1LnjIgrT2ST1+RyaWSkGXRPSRk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824100; a=rsa-sha256; cv=none; b=OymIizH3qjEn39F0NQ6KOtyD2Fmx1zGfq4vU4t3vGPfBfKvTI5JZwNEdawDCvz94AuGq+E YZrcwwQyWlVqOjTEeqWzTiIXj8SYCew6SB45e9kzu1msYFOPLBjmwxuOTwuMGdiqtc4ggd G1K9b5T2VCxK6FRmIQrPrSOumWMUb+8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=bK98eUWD; spf=pass (imf20.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-202146e9538so56959995ad.3 for ; Tue, 27 Aug 2024 22:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824187; x=1725428987; 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=fVwUzK3Wi136bLF1beJbPIYrhSgOvSQiUtDec+6VrAU=; b=bK98eUWDhraghirmXrccseofkpAs1+014e9lRvIzXoWzK4U+Auw1mQ0yWl8KOfSDXr gLY547z8trff9m4Y++5Puxpho2+NqpCPEHskXnqc17B6g/hdgwh1RfmrJmaL9tyGqVDE 9MuwDL7ZN7bZULszYX60nwdsD34d1/rA+72GA8e1I9ruxnzTfRac1GQ6dNWAKO7SnyMm eeOaMQpO8UytEdg5/4rxZnoCv9QTdPRbvFUoo7e+w3eTbdeLdXYg86GhBfhFY7mLJncC kx+dDmQYiUmlp1kBDwwhTLXOF3nyA4BelCPv4UW0d5DX5gEnBWA1RMrhjnydSuNwnMM1 sXpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824187; x=1725428987; 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=fVwUzK3Wi136bLF1beJbPIYrhSgOvSQiUtDec+6VrAU=; b=UbisWFQGIbusWWuw6kUnlIVyopV1IG0zHlj4efoCrxEPkxpGGd7oktDCwqkQT7RFsu m+7KuV3B/H2NCpFPCt2P6LWyls9e/hhMi3DlTTz/6Ywdw9s4wBQfZQEjCwmEPxBRLfJo KsnYiDz9jGWlOcj8RUlrc0eh1CnxYPmCsyArRvJ+V3qRw23nc+0Q3ekIrR1faWDD6TqK VIiXZZNJmAQnvmXLMCE+Q6jGAV062/UFAm1Q7LDpyB8TCGwK+bVJN3wTIHC34Rd8Ru0N zUw/aZh/iKNpEcU3fnfrUIiqcx9QDLu6qfdxaGnIc+sloxxWXCz01YEXTP3t3vP7ugT1 kQoA== X-Forwarded-Encrypted: i=1; AJvYcCWtf2B3k7xIOW8UzwxPUJc9ZjVA5J5iUAX0e/YJ440BI1a4GK9t8WrClFG8cnYQEMvLFfer8C85gg==@kvack.org X-Gm-Message-State: AOJu0Yw7Bvk0poBC4zLylakK048HDhaNA3hHzcRL6dffsKvDRTOlVZfG +zRnb0WHyjN9Tp1dqpIuC9P+CA5ffgGA3e4SZ6VoYPWLRrB89CQZJUdXT2GJl1U= X-Google-Smtp-Source: AGHT+IFs6bhbKPqiE/XUyq+o9y28MS2XMnZalJw5Zqf2sXjfONhgRAKfe8uENwidGpxKTHXbXFBJcg== X-Received: by 2002:a17:903:41d1:b0:202:54a5:deaf with SMTP id d9443c01a7336-2039e4fbd80mr220740285ad.57.1724824186699; Tue, 27 Aug 2024 22:49:46 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:49:45 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:12 -0700 Subject: [PATCH 06/16] arm64: mm: Support MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-6-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=2070; i=charlie@rivosinc.com; h=from:subject:message-id; bh=ib/vcnYDgaY2P7lUbSF3YkIC17EmCG0vvapvjDW6XVw=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XXGJ67WyV1982VXredvh0ENd1glLC4s4HJVXs9RbW X20a7/aUcrCIMbBICumyMJzrYG59Y5+2VHRsgkwc1iZQIYwcHEKwETa9BkZOnYYvlBTj2FUnbDH vODh/SmrdzHc++GxrUXG77agmXy8LCPDkyuNIo53Hzx7czND5bWgC3vzEimd+TtdNE+3T847GKz FAwA= X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 55A151C000C X-Stat-Signature: xo9jix58sjjwkq4w4shx1r39eneb7bma X-HE-Tag: 1724824188-485463 X-HE-Meta: U2FsdGVkX196MmPJAw1ZssqMW51oaGl1KyykLFaqanMTksTo79ZzTBaaRJIdOiuYvGm8zqJiuyFKuy8iXIplbiOl+1Kb1tbIityeYY1HbT0DOBl2y5tsvmhLdXPOEFPFx2vw72Jb9zzzu4yzoE7xcNwquFXY1Z4IocLXm+AllnYz2x0Fab7dYU3rlClgLQuvND6599OCWsZT0yvhF4bZL3/Orgri16rU2CJb10ElowTH9YheAizuhG6FfXwF/DE97GRTj5eGihtwSneE2zCdjJglO+sAt1da2hRgoQlFiAwnqodujoV8fQq2Yt4nG6QEAXXoKMaRy/HwRoT8sJqx+5RVeyqY4ps/b/U9v3rynsat2S092NvIex+kX+mS9108nO5eDRCu7aBKhroLxmS9ex8gXM5HjNohIbvYiLuzxiet8ATdWakdzGAzjZtdrdjleK685luPiXj8EMMp9lF2P1aWVBgkXbMR4xmDu3fOlM6awMcvnx15fwEqJUFneOKYiwAzJi25gP8CSA7whdQZ+jxBb5dNti6TJcao9nH5xD1yjR4d5Tpe0qi43JOBuXATck6x0sXzWer0TmAeACFtPheknX6M0qOUkW+auRLYrLnTbL5nzvv0TP4hjVIEZfIBgfzvfGgjn/AKKPIsz82Skx3DrQD5dEhWJ+o3Iq8aT+rY4eXofvnixgnNpbjhPm3yWWy/Ff31L/l4DJKxrw1L6CAqN3AUItpi0FfgvVJWecd323Vx/J1dv5V83nnmioK8POMU1uwqPLSp/nMx92OMk8SrKIw+OHnk35v/0TiuKczwgl9xbCd16UmUyxMQY3MRxvBwLy5R4Jt87ktkVgp2hp2mPN1GhhNRfNR4XoVjzWgSLm/bO1kDHErkYWvM6NI3m1Td8bD23Vu3lCLGASdkqwTS6r3MPSyLpAN0WR+9+tLyPi80xe4WS44vKRbeISCyCSURSbctusIz9SYbpgZ 3+MISK8A O+9m9SSQEuUAVJa549AovZ/X+tdP+d/EyVHsi1CB9VSaQFtN64jN4yopnXJdpbV95YuDugXS8cRsnk1007X0ytmpsqD3okjly30/FXA21jq8/HGNffwPxe74OxOy75aXc96j4/LzuiMpFBU7+eNLhUPfuWNHEQdTRStL412WpDHCuwRFu69MaBvPDVJS6KftfLEc47/p1vHwpvkDXKj+9nJiRMd+IRNey3G28Q9bxUI+Eax9QmJaQsptOr10oMSZ0b+AsurgJA+xnSr47Tif8zDSi2Kvb3xRTa8drvf/g4yU+wUAJ9b/gxwX3sY3InatZKrpwQg6aSSq7i7+I47RQOkZ8CJig8zTXGPSU3LlLATL0Cjr1eC7zAADOK80h8H5wtTm66eVyAEu+C88bC3ujlYWal6r0oMsUfax5n+qI9l0+tX0OACC4eeWTZw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000057, 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 arch_get_mmap_base() and arch_get_mmap_end(). Signed-off-by: Charlie Jenkins --- arch/arm64/include/asm/processor.h | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index a67ca119bb91..39aabb1619f6 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -92,12 +92,36 @@ #endif /* CONFIG_COMPAT */ #ifndef CONFIG_ARM64_FORCE_52BIT -#define arch_get_mmap_end(addr, len, flags) \ - (((addr) > DEFAULT_MAP_WINDOW) ? TASK_SIZE : DEFAULT_MAP_WINDOW) +#define arch_get_mmap_end(addr, len, flags) \ +({ \ + unsigned long mmap_end; \ + typeof(flags) _flags = (flags); \ + typeof(addr) _addr = (addr); \ + typeof(len) _len = (len); \ + if (_flags & MAP_BELOW_HINT && _addr != 0 && ((_addr + _len) > BIT(VA_BITS - 1))) \ + mmap_end = (_addr + _len); \ + else \ + mmap_end = ((_addr > DEFAULT_MAP_WINDOW) ? TASK_SIZE : DEFAULT_MAP_WINDOW); \ + mmap_end \ +}) + +#define arch_get_mmap_base(addr, len, base, flags) \ +({ \ + unsigned long mmap_base; \ + typeof(flags) _flags = (flags); \ + typeof(addr) _addr = (addr); \ + typeof(base) _base = (base); \ + typeof(len) _len = (len); \ + unsigned long rnd_gap = DEFAULT_MAP_WINDOW - (_base); \ + if (_flags & MAP_BELOW_HINT && _addr != 0 && ((_addr + _len) > BIT(VA_BITS - 1)))\ + mmap_base = (_addr + _len) - rnd_gap; \ + else \ + mmap_end = ((_addr > DEFAULT_MAP_WINDOW) ? \ + _base + TASK_SIZE - DEFAULT_MAP_WINDOW : \ + _base); \ + mmap_end \ +}) -#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 */ extern phys_addr_t arm64_dma_phys_limit; From patchwork Wed Aug 28 05:49:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780625 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 9FC89C5474A for ; Wed, 28 Aug 2024 05:49:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32E856B009B; Wed, 28 Aug 2024 01:49:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DD956B009C; Wed, 28 Aug 2024 01:49:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 156EA6B009D; Wed, 28 Aug 2024 01:49:54 -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 ED00A6B009B for ; Wed, 28 Aug 2024 01:49:53 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B9D8BA1D2E for ; Wed, 28 Aug 2024 05:49:53 +0000 (UTC) X-FDA: 82500577866.24.66FB0EF Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf08.hostedemail.com (Postfix) with ESMTP id B973A160007 for ; Wed, 28 Aug 2024 05:49:51 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=1VlX2SuN; spf=pass (imf08.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824147; a=rsa-sha256; cv=none; b=N1tctbx4x3Y74kbAu/G97ieh0LsiWDvaXs3q1lE0R4XJitobU+3GyIojpDIL2P7NzGqWx0 GPYma61W/fQfKe9C5X2aF+jGk1IfZkVRdOfSGOp2kA7gtGsXpL1DlpNEoxr8riBKBkBrd0 GRxepXgIwchXl3H3qoAKslGtyKDw7Ck= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=1VlX2SuN; spf=pass (imf08.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.177 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=1724824147; 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=01svQ9ue7Mr4CWZ3Wn0HVoOhr4xAPnLaZCO9CnTXUgc=; b=wO5Q/Qvz+yaVD2vnRy4QIZB+MEnjWzrUJgwmGPVoFVO2Epy7cDCg7BHdyTT19MQxWnQIjW WivIbepCG2YYhIjE0ysOrN15dxSiyd22zx+UVAWZovpP9CamuCNIc0uhbtIodByLOlyU4k oZh78vQvUSwwUOpTTsVW1EyFJD41AoI= Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2023dd9b86aso50366465ad.1 for ; Tue, 27 Aug 2024 22:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824190; x=1725428990; 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=01svQ9ue7Mr4CWZ3Wn0HVoOhr4xAPnLaZCO9CnTXUgc=; b=1VlX2SuNInfqdTxyPZCtRFkDu6p0d96KBYKOutsuBD33teCH5gDZ4Ao63EuQbQjHeL 8rT5R//Nsxl9X31ur9Qnvq7IexBf02QzmOXkeANUyg+1o3QE2lRIgGC4y06cxrngnFDa vc7i8fAIro0B96M2M4bLCNQERkx8CuAAaZrRxhyzCBh+cf+8rS3qZYfa2vrEm3lNF81p OZZIg0gCi3GqJPGrXHb6+XtFmzNC7dtJWO+gqhnZBVToNLtssndrq8EZDBCm2TAvIijv v1w1XF6VMDHQKH2WP6Zz75fFWQc0dcjWLumuGPRZmfmKG16Ww0RV/tInwyKTYqCm1NFm ArkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824190; x=1725428990; 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=01svQ9ue7Mr4CWZ3Wn0HVoOhr4xAPnLaZCO9CnTXUgc=; b=QBOE8VrynBcHdZY7OVmJGodIQUT6pbZslb8qhwQpcmsDOnhutitCvyRRI+81aHDU2V e2Zg/eCDxuOde8eBtoStehKIaeP/pP5C4pVhZSbsSbG8oWw5tHKzw72EihQwNvep59BX xvdIY43ePbFgpR52YtyhCYN4NNCCHjY6Eb5+CZ2e84gdlGrRY2IZgOSexdmRjHaQfOKr iAoemp4tPOCMqEvUTetNYYqV+LJcme6C5YLHRytzAMU8SLzROk38UcYEaQdUVpZXOmvc xzzbyMoMEPmwVdZcZ7WEOWy/vjHpToF7kb9dt5szS59OmLQqk7rDXAuD76Aw3NSJ4Wlk HzEw== X-Forwarded-Encrypted: i=1; AJvYcCUcljKZWZtLYmkq51k5qu9cYxdtFAWROgwgbJBwtwv5pOqy6JkjHgxFys1TeGKQuaAfHlYRNNkJmg==@kvack.org X-Gm-Message-State: AOJu0YwtG/bqSpZFGLogX4ok7rSKThz8XbPw0WUeqnPOGp0ATbLN3QM6 lG/zbjUJhjl9+DPrSnCiMcA5Fef5jm9kWF6JBFBjSGRDiEGwiAzr6uKi0nZ7Drc= X-Google-Smtp-Source: AGHT+IFEjwUM/ElshIB7y6tneVtatsCyua8fDLSA2/rXWwDoWBaTV3bT3kKjnxkFupcj6i3KTQazzg== X-Received: by 2002:a17:903:41c6:b0:1fa:449:1dd6 with SMTP id d9443c01a7336-2039e510e6emr137316635ad.48.1724824190164; Tue, 27 Aug 2024 22:49:50 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:49:49 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:13 -0700 Subject: [PATCH 07/16] powerpc: mm: Support MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-7-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=2284; i=charlie@rivosinc.com; h=from:subject:message-id; bh=efrv8gA6WD0kUzxMoz7FX/k/QnHAbRwwUgR0y2hEUd8=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XfETrh9IO7T/uFjUxMhNQooG1iuWi1pdtJg6YcLD7 VUZ209HdpSyMIhxMMiKKbLwXGtgbr2jX3ZUtGwCzBxWJpAhDFycAjARbV+GvyIzjrH36plzvXDr 3H/Wo2jj7SdL50ufO/vC42XF9noOjvuMDF8DvSaxHlpya2VRHMuNXyrdOxW6nj44wHJxyn8TwWv XdrEDAA== X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Stat-Signature: 1ogacjzsgoqk1skequc5ptnqdt44ft9b X-Rspamd-Queue-Id: B973A160007 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724824191-720981 X-HE-Meta: U2FsdGVkX18HbnLlLA8jnXDMjnKXm/q+/220Xnm6DuieTKZktZ72jE0GTwHHOlwcLfp10tijv0Lr/gB9cpVs32KIbrECb2H4+cs9bYpJjJxX6e3G0vKEqNOUEOebtMMRZbVFDcYTyb71eg1pnLS0ZvXVVQokk3LfP7p0y+/E+BLomyOlLjUUrwqkvIcKIPSWUzWxHMk4kZFmy4bA23J2nR8jI1wHWEz8JK4feDCRVG0sOow6r8GuEssGphSS8GZUlLO3ubK1nJB/JQIWoMCmsar63Lr8kgNCTiWNojpYQXWWnLZ9XO+7cxtyo3Mb5+7XPRJAMaWAVOxTjsLC5cySCqdpVk/f0OwLTJgyq8ZmQeL8oqH0ApmVw8ZxZqcIWU51vl94AIKvvpZq6+4nz6C0tZEBKn9cnNPI3yDTR9x53kr8u/4GEZYrlOor72dqQH7EyYo8Y0eyenBxbPo2ND2cNZtjO4VlXul4+j8Co1apGu4Q31z4SPXoEE784OvkKj57ydrZv6zkTfbw6FvPFZToUyWluyfU9Qm2KFY76yS2t7cQqJ5Zf3nOUZ6ZOeR9340hQEWnKlHYP61cR1wJ4I0GxgYruqgZWxdDrPDtRWcIQvBpbvquTdWypOKlsg07Zhiet6q4ZxNDQLMPb4cvSGVUIaDPbSvdH8OHzsbqKsQSV5NImh2rUFzycstJVRANL6FzVJ9AQRuGhd6hHnEi9UVV3KZBExwoaVwzQ0Sejva7F9toVWvmKjiNmrc0LyFeRvvEYfDhapDppJaRoYM5FE8fpl3ZYJlurpytrRu9nIJFfoZg50NGNi0FcRjG33ZbtjHBi4affi90PyHtKmiv3nnpUrJOgmz2VGeoQvg7Yx5ks0z0U08oGT7zJdM3962yAVbm99+7wHZ8dnqybaP+OThdCpOudPlFMAaOQrXdO2dOyTiAJTNQ3OO4pX5Q0ZiIEQn096Lnc4ttI50Q7eSJ8G1 JA7EutGX 304gInrysS3ESDI/4BSIuzDqS7YzHq5tMWlo43Kj/sQ7k3GzIx39o245EFWFU2esJmWNJD8VRvXGmj8WUA9jifoiKomyx9YKGwWo5ufEcoHAaNIsHurbeg01zbWOrnRPGoT6XLSqD5sHhAMk2y2xFeNCGcjhJznby78WiHmlo1ekxsj2HfhA2QlkASDPt8e+Y5f6QaDT9sedqAWFY2Gtpft+Y7X1e3rPX5nkLKi0ffDklfJ78wAqFlVISTaiNwZ6y97djeuTLS0uKbS0O9O4hmS7ZcZgeBZ6VQ5VM1sSccIpbAdn5qfQeHJtJcC4V3XnsHk5jSqUPqGTCqJA//af9HBKxQDV34Ow2AsO9i+jXdiP5+v3NPWC5ZdxFvyUPJs/ot9caM8GuHXlaOJlHZT9srs2DcbuYim1GIh5Ozm4uxsVBLctphwkycL/EWA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000031, 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 arch_get_mmap_base() and arch_get_mmap_end(). Signed-off-by: Charlie Jenkins --- arch/powerpc/include/asm/task_size_64.h | 36 +++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/include/asm/task_size_64.h b/arch/powerpc/include/asm/task_size_64.h index 239b363841aa..a37a5a81365d 100644 --- a/arch/powerpc/include/asm/task_size_64.h +++ b/arch/powerpc/include/asm/task_size_64.h @@ -72,12 +72,36 @@ #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, len, base, flags) \ - (((addr) > DEFAULT_MAP_WINDOW) ? (base) + TASK_SIZE - DEFAULT_MAP_WINDOW : (base)) +#define arch_get_mmap_base(addr, len, base, flags) \ +({ \ + unsigned long mmap_base; \ + typeof(flags) _flags = (flags); \ + typeof(addr) _addr = (addr); \ + typeof(base) _base = (base); \ + typeof(len) _len = (len); \ + unsigned long rnd_gap = DEFAULT_MAP_WINDOW - (_base); \ + if (_flags & MAP_BELOW_HINT && _addr != 0 && ((_addr + _len) > BIT(VA_BITS - 1)))\ + mmap_base = (_addr + _len) - rnd_gap; \ + else \ + mmap_end = ((_addr > DEFAULT_MAP_WINDOW) ? \ + _base + TASK_SIZE - DEFAULT_MAP_WINDOW : \ + _base); \ + mmap_end; \ +}) -#define arch_get_mmap_end(addr, len, flags) \ - (((addr) > DEFAULT_MAP_WINDOW) || \ - (((flags) & MAP_FIXED) && ((addr) + (len) > DEFAULT_MAP_WINDOW)) ? TASK_SIZE : \ - DEFAULT_MAP_WINDOW) +#define arch_get_mmap_end(addr, len, flags) \ +({ \ + unsigned long mmap_end; \ + typeof(flags) _flags = (flags); \ + typeof(addr) _addr = (addr); \ + typeof(len) _len = (len); \ + if (_flags & MAP_BELOW_HINT && _addr != 0 && ((_addr + _len) > BIT(VA_BITS - 1))) \ + mmap_end = (_addr + _len); \ + else \ + mmap_end = (((_addr) > DEFAULT_MAP_WINDOW) || \ + (((_flags) & MAP_FIXED) && ((_addr) + (_len) > DEFAULT_MAP_WINDOW))\ + ? TASK_SIZE : DEFAULT_MAP_WINDOW) \ + mmap_end; \ +}) #endif /* _ASM_POWERPC_TASK_SIZE_64_H */ From patchwork Wed Aug 28 05:49:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780626 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 25BAAC5474F for ; Wed, 28 Aug 2024 05:49:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ACEFE6B009D; Wed, 28 Aug 2024 01:49:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A7FE96B009E; Wed, 28 Aug 2024 01:49:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 883896B009F; Wed, 28 Aug 2024 01:49:57 -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 6954D6B009D for ; Wed, 28 Aug 2024 01:49:57 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 229121A1D3D for ; Wed, 28 Aug 2024 05:49:57 +0000 (UTC) X-FDA: 82500578034.14.2FFFB0D Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf10.hostedemail.com (Postfix) with ESMTP id 3166FC0015 for ; Wed, 28 Aug 2024 05:49:54 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=zCp3ItAz; dmarc=none; spf=pass (imf10.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.175 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=1724824097; 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=WPJ0dF9cF6J1lv0FlFvR4vKxUsSQiAia4h2dvI+DMjw=; b=TqXdoLO3yxfIjLpRdOblWTGBkHJUGKXljCTB0mo016nsxa2LI1JddFuzjUibygA3v9W70/ 5S9qbzyxuCJ4AjiY6ImYag2dbZ6500gc+KEgjDa7bNhen1SUFNuEVaW20YIPSkiwOt0T3H X3vcTjYg1vNZ7NLBFG1WMqZOnD85F08= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824097; a=rsa-sha256; cv=none; b=4oqXsidjASHhoHgfvVei6U8D73TWKLS2XLIU+RQgnpbuH0E3WNyvNc7eZtrec692dFPAyM SE7R+IAUkMr7UqXgjHxhFjgR6jADvA7j9Hi5EGjMQKC0LOn38Kx4eDkctLQObPe5F3aUIs 9MQ0xERe0YlOKpOcZRYdaadVfW52cnk= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=zCp3ItAz; dmarc=none; spf=pass (imf10.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.175 as permitted sender) smtp.mailfrom=charlie@rivosinc.com Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20223b5c1c0so57718915ad.2 for ; Tue, 27 Aug 2024 22:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824194; x=1725428994; 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=WPJ0dF9cF6J1lv0FlFvR4vKxUsSQiAia4h2dvI+DMjw=; b=zCp3ItAzVWgH6YUlikxo5CJvFQms+kn25YXdtfPS8pm0MjIoofadzlWOcuDPzAg8AK KJGNMrA7+KyIXTXRB+Bi1uAyJ1jdqGdHlXDiTMzB0UQLZe8PIOftwWFQ9s3LCsc9gdne L3NzuFxacGgF0fZ9yb6GvFPqK4lHJGKR1zAl/eTO/gbGW/3zJ96oiZHXdcJKm+0JH1SY cUMRmDRdTxGmU90RELlLAgd3/Vbk8gac4zD0aL593jsCjQEVgX+9Zd1Sk5GwTphqYQfN J9kGJcJi/ba/NZ8AvCTZkpYs1JD4Rlm3cKpdF4sizzbkfEsNnFkPoI828808GhR5bTEL Hkzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824194; x=1725428994; 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=WPJ0dF9cF6J1lv0FlFvR4vKxUsSQiAia4h2dvI+DMjw=; b=OmMHA8oQmE+HNqA7s2GYmXVERFDppKi+MIjmzwKSO8v/f3R3LOQ0KmkhaC/kZvtjyX 1ylmxrQ/0jibyphHrdQwnmliGl8TQDq82nzdQfNb1pcUkDfur07uVWopxFcroFoUSVcW xm2G228CO3xSyGBNgdXJcALvPre+wwUAmZVY1wR2wdACSkAz/Sys939fSLI+mJjTvi5t jWW5nEey7y4bGolrHaGo5E/hD+GL4q3Ve0FYL8BKCCNdGTqth+tjnlClMNb4s/oxgXaI do8WaEg/f01Qkcsxlj0orYdm70RAYaWGxpq5fDT+bJF3lAVzCC/t1WUX2h677uaXIUGp X97A== X-Forwarded-Encrypted: i=1; AJvYcCXcCFZ3vGSbF91XJrhFPKt8+R71TW5gelq3b7Xv0c/6lHoDGJJx8LJuAqHKKsrwK84eCxDIO0BGBg==@kvack.org X-Gm-Message-State: AOJu0Yy7DsLPk8FSXA/F31x24Qum86/wxSM8GYOA6h6W3GRyxvTn92zs UXH3fofp1OuXh7UEae5vokTmAvbLzWRXNklMd0RgbcVdQoX+yfOgWRizxEl1iq8= X-Google-Smtp-Source: AGHT+IGIwf3MFbsmI5L/nn36QcLF0tw2dizRywserImseYHkgoEBii3QkvkJxB3CCAhauX+R+NVkZg== X-Received: by 2002:a17:903:41cb:b0:1fb:90e1:c8c0 with SMTP id d9443c01a7336-204f9c50d18mr13883795ad.63.1724824193604; Tue, 27 Aug 2024 22:49:53 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:49:52 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:14 -0700 Subject: [PATCH 08/16] x86: mm: Support MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-8-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=2933; i=charlie@rivosinc.com; h=from:subject:message-id; bh=/49vITxLNj+RJRh4dWyqxf17jS8h791m43d/wmsbi4g=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XfH5mu/c9Rrzlz8/vq1gj25AnkDItFvB5j/EjQ7d2 dgpWufVUcrCIMbBICumyMJzrYG59Y5+2VHRsgkwc1iZQIYwcHEKwERiehj+Oxm+8In6am8suLjK Qbj6ukzK61nfEx9q7X3ecc3HVutSBcP/QCmOFDVPG+uvAsGmtk+sN15sO6WrIvn+0Hvj8ITPYtt ZAA== X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3166FC0015 X-Stat-Signature: mnwms376jdcij3zm1o86wqjxtc83g4qh X-Rspam-User: X-HE-Tag: 1724824194-267933 X-HE-Meta: U2FsdGVkX18eDDS2HQ2QMCz+aYS5xH5n0YzFkxU9DyjkeMElT8BbgvU3hEKgx2tNPjlvWBDfaxnTTTY31qIu3NF10+Y/d9KR8A4UN2JBvOZwQ5SY8TNOCIqz829e+oU+dw9hPRfE1EvOHd/Zo0X2yCvAbp5VWJyzx/do2+2+AB8MtoPv9wcbJv1j/WIIPpBkJjtFeHGtZ49FDaoMaqsMLXYbnBVxqrcB+PTlSxE17hBXwI0EMSKraKh5I+H97poMNlXYp6iKEbROEOp0bVdtjrxmgxU1ynv9bmyAksi4fAECoFiQ/kthEk4zatNbuARrG6pXdYk9sRXUwBoZQTDIL65N8dt+IJsqcseSM7Yzbq+tcmvt9pTnnI6y8cAaRiF7rWyVhe/Q8qrDBsrzfLeAf9yLWIZQHZzxYCpNOov7/19XykAmEVatXU+SFGouACS6KlQoDQPWMC8VQ09YOhuGs8K4rzAqMUNPulldKycYA2Lp0VR3Jz3Al5w7MjpbN/9Ed5Av1j4FSiaB1Er17Hx4L7B8gdqaMBmXTdqWSic1Wi6SyTRRorqPQoVW/iQKyiBn44CbDW/lgOahvsdFohaKH27GheFaGsnS0B3sbz2c+4ugASqoCeixiPv3xKJiULZfqdVNrnVL9PpOhAllzfPqznqxUcy+7vCuZqgq+cbbcG55j028LHhtzOxUvkViZHaxsMEG15jV3/uYryNqcdywakzTPvCUYd74bQI1QpuqzRmNLz9B7deNdOLMLtqLgYvEH9d5vA5zT4dExZExrl9cBmsjntWPO5ol1qX2fRYVsIaq/5nAtJU+3Tn1HO4yL6TO9E1Sx6QLoVN1xBmT1q+jqJ53c74HFPM4hCT0w+EysCAQ8gyCYUaCKOCWvwbtp2z+RQSeLdcizClk3NSfINKkm4oI1/WJxyk56uqQRKdWK0T2GB3fjPzUtGBs8l/EuTMAIIjLaPHhDDatbBvyO5B x8N5CneO OR2Qx5txnOiH7i/yLNYSiG3/j53ScRlThjXFRaz1K4kAlt+fzq35txostAg0dIVKhBSU4alI7Dlo/VHaDxejkg12GilBRlx4BojrP9lIIaB0shfa47DMjkFhPuqEL8/zwDyo7vs1Q1qSBx1eoB7LdD9rmaEVGSCR7lrOMJMmxCUMHOXdcY4naxaJV4rD6IgSNEZXy+V8MxoE9FHch6A7AT03mdfBHE9yogF9bCjGhBKsvSFB1SvyDsa3FODR6j0aSFyjVwQlP7BLITByt1DptfZqL8RPSaXM79adJAJGhZOtI2ksA3+kNPCsaq2i8d70HJIW1RYfTKq+3KtxUeWuhHzCkXqGRQ9eX62EczqxR475sMTuYpQrLRgI8B4s8LMmrm9D3QFmXrKPXI0Z/VjvqP1wO97zpLoMq7eMBtUOHMQMKyXuPLR+q4I6fvg== 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/x86/kernel/sys_x86_64.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c index 01d7cd85ef97..fa16b38f3702 100644 --- a/arch/x86/kernel/sys_x86_64.c +++ b/arch/x86/kernel/sys_x86_64.c @@ -86,7 +86,7 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT); } -static void find_start_end(unsigned long addr, unsigned long flags, +static void find_start_end(unsigned long addr, unsigned long len, unsigned long flags, unsigned long *begin, unsigned long *end) { if (!in_32bit_syscall() && (flags & MAP_32BIT)) { @@ -106,10 +106,14 @@ static void find_start_end(unsigned long addr, unsigned long flags, } *begin = get_mmap_base(1); + if (in_32bit_syscall()) *end = task_size_32bit(); else *end = task_size_64bit(addr > DEFAULT_MAP_WINDOW); + + if (flags & MAP_BELOW_HINT) + *end = MIN(*end, addr + len); } static inline unsigned long stack_guard_placement(vm_flags_t vm_flags) @@ -132,7 +136,7 @@ arch_get_unmapped_area_vmflags(struct file *filp, unsigned long addr, unsigned l if (flags & MAP_FIXED) return addr; - find_start_end(addr, flags, &begin, &end); + find_start_end(addr, len, flags, &begin, &end); if (len > end) return -ENOMEM; @@ -166,6 +170,7 @@ arch_get_unmapped_area_topdown_vmflags(struct file *filp, unsigned long addr0, struct mm_struct *mm = current->mm; unsigned long addr = addr0; struct vm_unmapped_area_info info = {}; + unsigned long task_size, mmap_base; /* requested length too big for entire address space */ if (len > TASK_SIZE) @@ -198,7 +203,8 @@ arch_get_unmapped_area_topdown_vmflags(struct file *filp, unsigned long addr0, else info.low_limit = PAGE_SIZE; - info.high_limit = get_mmap_base(0); + mmap_base = get_mmap_base(0); + info.high_limit = mmap_base; info.start_gap = stack_guard_placement(vm_flags); /* @@ -210,6 +216,19 @@ arch_get_unmapped_area_topdown_vmflags(struct file *filp, unsigned long addr0, */ if (addr > DEFAULT_MAP_WINDOW && !in_32bit_syscall()) info.high_limit += TASK_SIZE_MAX - DEFAULT_MAP_WINDOW; + if (flags & MAP_BELOW_HINT) { +#ifdef CONFIG_HAVE_ARCH_COMPAT_MMAP_BASES + task_size = task_size_32bit(); +#else + task_size = task_size_64bit(0); +#endif + /* + * mmap_base is defined by PAGE_ALIGN(task_size - gap - rnd) so + * subtract out the task_size to isolate the gap + rnd. + */ + info.high_limit = MIN(info.high_limit, + (addr + len) - (task_size - mmap_base)); + } info.align_offset = pgoff << PAGE_SHIFT; if (filp) { From patchwork Wed Aug 28 05:49:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780627 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 AC4FFC5472D for ; Wed, 28 Aug 2024 05:50:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 355036B009E; Wed, 28 Aug 2024 01:50:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 304EB6B00A0; Wed, 28 Aug 2024 01:50:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17F186B00A1; Wed, 28 Aug 2024 01:50:01 -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 EC98E6B009E for ; Wed, 28 Aug 2024 01:50:00 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6939DA1CDD for ; Wed, 28 Aug 2024 05:50:00 +0000 (UTC) X-FDA: 82500578160.27.165104E Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf01.hostedemail.com (Postfix) with ESMTP id 71AAF40014 for ; Wed, 28 Aug 2024 05:49:58 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=mkPmlJJp; dmarc=none; spf=pass (imf01.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.172 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=1724824101; 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=YNQglkp2lEnIf2YsbVUEYoAS4AW64pe58tBCUjsMipk=; b=wwIFdmFaSyGXX9Xc/5+lo93CFPKY2dr1aOQpyd3DcTwh2Ah4vsxYXKVbADlDVCG6drjWwo zbu2XR8ayhrC5YP6utq8rDBJgskBerYnpkvcf0WdYpTixUwsKjOhU/rEjoP1He2enATGNX lLVdQKq4XYKiRxXZ4wkOApLpabzjeM0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824101; a=rsa-sha256; cv=none; b=JbDd5VIdb91sTukhHdgznVmoyw5hxULwG2yytx2ypLxC9+ttGMUtI7xK3HjkYBIun1PxgO amyhdZ//yaTsrPfexIqkQYFVgFjlAmS4f8vpt/bGbnQ0kp0kmYpcMcYl/5Scj3CKhsN4Lg s5A7yxUijc+doKrhpHzvFPOahQrwv2I= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=mkPmlJJp; dmarc=none; spf=pass (imf01.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=charlie@rivosinc.com Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20202df1c2fso1730705ad.1 for ; Tue, 27 Aug 2024 22:49:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824197; x=1725428997; 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=YNQglkp2lEnIf2YsbVUEYoAS4AW64pe58tBCUjsMipk=; b=mkPmlJJpvyv40A98N9H+Pg0t8Uatlpn6STaJUiGm+rYpfK30cukRkzEFrPrY4hqj2i lftgRKxDrDe97VQ/qNCEDjeJTQgZlSeaTIk+ptelDKXm9r+JCPZ/uesLnabhM1QpZaGc Lwvq6s39LtfSRIGLp8tezCGN1WIbRBFyfln+3CNYz43K7b+E38mkx8nI36ZDtKXPo2en HBGp7pfsTR9uPb8Xyg+kGw5tFGc4uvkTbgpZsIeh2oNYHz9++uhbv0vqn7jvkButFkIo 8Bwdfwz2SiECSFtapRyLR7ukXAYG824BavZIVN2OOl/1sYbzhjpE2wG7EG0rsKO4OvIq Kvlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824197; x=1725428997; 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=YNQglkp2lEnIf2YsbVUEYoAS4AW64pe58tBCUjsMipk=; b=Z+5cQkWAAtkmci4HCyxtA/UQvulrjzO97F/MbnjibQcvtBe86PcGhraB+YZOMBKwWX 7vJuLlZgIDXPc97mAj9m+m+SmDlT7WxpoNhVl7l2fha/11GpbURCmuHLbfgItqVoyUL5 j0mNxSQHhC6ubt1dlzahnLU95ftqfEEQrCHykqFboNQo9EYAG63PI5HQauGjXo8NWtmb R0RtkU5TEC6lcNUgP3l8D2TA3Q0jcirsBKWSz6PfPcLT0LQ/wr7CB5zIUSmKKWOcjGow MO88VF7GtjGsVcO5HdnSMnVWgdlBQHdbIGl50+7YWtQ+ZeuPomzGFGOJ2elYrjWm7NKx izpg== X-Forwarded-Encrypted: i=1; AJvYcCXRKkh9ZA/6v3qb7OuZXQAPfq02sKpjLL8WgUA7p2XpkJ/PnRp4oE+yXekVVqbTsYRNquCsSxo0Qw==@kvack.org X-Gm-Message-State: AOJu0Yy9w0emq2LoPib+ZSdUvz/3fT/YVFNa0WbnDr83DiNtzAe4bYm2 b+eQBHiyOxO1B9fHJ1V4v90DkJZVYYTFIAui8PhiP8JAtCDLx7wuk1DWyhwNMDg= X-Google-Smtp-Source: AGHT+IFNvFc3w8ZqIqMUtm2tpVZkKTF+VkfsFh2Ia3nc64cPU9VogTthyuHsPbt4BWtQWf7nibqVyQ== X-Received: by 2002:a17:903:35d0:b0:1fc:41c0:7a82 with SMTP id d9443c01a7336-204f9912733mr19643175ad.0.1724824196945; Tue, 27 Aug 2024 22:49:56 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:49:56 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:15 -0700 Subject: [PATCH 09/16] loongarch: mm: Support MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-9-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=1259; i=charlie@rivosinc.com; h=from:subject:message-id; bh=mXZWgvc5d3nCYQqiz9PUCvFecQkJ9kp2ZooPsTsZSyA=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XfFl5t2npeO1W6ydtL9v1qitmfF53Tr5I+FmGy5eX hv8Y0JgRykLgxgHg6yYIgvPtQbm1jv6ZUdFyybAzGFlAhnCwMUpABeJZGTYs2fGyX1L7U5s/pDP 9zI7cOPnH9u8t8ZNYFCaqKg8I9+uk+F/YeihTo3z92Iv3r2a7r74pUGE/VYuj+S6OkvJ82tdPk5 nAgA= X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 71AAF40014 X-Stat-Signature: mdddaxc81dwtgeqjp3s9ch3r53ree7db X-Rspam-User: X-HE-Tag: 1724824198-572794 X-HE-Meta: U2FsdGVkX1+UQsnCtVtn7/hwlZkY6FtOkd0dCqkcGSnpa86GkLXS1Crm42IadRGEmSdPA8Y4TrXbvLgG/NRiF9+7puMLUE7U8wXNEuheb7H02fdNg2zWbkpHDV2e1vERgzduhGMcyEWufsK8YQjwbj3F/xYsAP2SzFadHp3xpPb2F1PP78w7lKDM7GuBY7bevljptISG+hA3eLBciZmw2LzQJSuFln4YzDyOz3RvgtGJLaJWsgA25zlMA3h/o54DBu+nIevnI7N19JjrPIpaOyZSgD+WjowzxnM4feTtS6QvI7AaRlhsTO+2IgCPvybBDKcgQkKPm5cP9xjB/faD5Ulzjn8GVEFWK6Fk5AD0XJ9oxDMQ6OSMIZH2EsaDPO+MKmz/1CUAY7mGHBlesf0nezs1b7tq2KJtUdZDDyYb7nGCyVmK1DRFs1G/dlLpE7AmQGlDIPnMDtdAUmdyMe+a7ZM0y46aWUaWZxGImjU6a05xgJxOpJVCgVIONGcIbH951ofrNgTP+25++B/jdaFLabq5m+gUBRtMx9XhnHrqyeEDUW75tlxYNJKJcotbAW9DRkjxxAtLBUmqFKYN5ns06bQmZl0bmDJ+IODG1+qvmk13ALOmBrBf5SVr2TkFcGTlkbvbB/dKml/SOPpGB8JS3P0Ch+mzC+BknSpB/mu0AcMacHe9H7JMr8CY8tACJwyo4fVbGz7w30R+UxmCHyZVyhExvn/XIw2fB2FzZiyKKCvpvh16439WkzzYZisZweZdLQvksUbGQU7xkfeW14OOdh/X+2LQEVOzrtMxfH+NGY946st+V82ma2Z8vR6xHBgziuazG/FMNPVpIiJnSNwRbjDrBLNlQzlRaD5WpWw22LGIztiMV2nrjM56uBMmePPzhSBwEw8tb35C8XFOOPnJR27PpeBaDO3EEeaY8p6UFC0Z9nJeG+ETUDTWKGefWDPn/+F3aJN6Giohd2290rK mSgPmDl5 7EthyaZBW3d/1faiy1lKclFR2GvsvN5pNz4A8X5ANvJEANaAFT38l8qfCghweo7MChALPjQjDMhOjVML8cJkOM8yYigVnJNEg+AYFAEHALoBhewR4iw64Az/FfJZu7RnTjEIaa2HyrH2q17oYnUqd1ZFJJbnT9luIHbrQ0iXjxBv5n8e1Z2aVIYPlaoZUIwZHkmwm07YnuQWRvPdy2+zrPCcSlVVY3muevTMW9tQsP7oex4QM9eqWjdHJmKO5ktWmOtMUgcsUrPOlLU7JkzcO3IrIu15vQW2rvSiOPMNgrnilABg/Ixr/MatRh68r5kFZ+EyeRb9pvyx19Gpa5GToklVkG5KwWKl5uUl9MLP+96DpgxItKBU2RcbmiMccXjtMWC3ZqiH2eRrrn7hg6zz37DP+zJKs5jqXgDWmoIz8VoLl0ZOszEh9wo/A0Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000093, 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/loongarch/mm/mmap.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/loongarch/mm/mmap.c b/arch/loongarch/mm/mmap.c index 889030985135..66a5badf849b 100644 --- a/arch/loongarch/mm/mmap.c +++ b/arch/loongarch/mm/mmap.c @@ -70,6 +70,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(mm->mmap_base, + (addr + len) - (STACK_TOP - mm->mmap_base)) addr = vm_unmapped_area(&info); if (!(addr & ~PAGE_MASK)) @@ -84,7 +91,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp, } info.low_limit = mm->mmap_base; + info.high_limit = TASK_SIZE; + if (flags & MAP_BELOW_HINT) + info.high_limit = MIN(info.high_limit, addr + len); + return vm_unmapped_area(&info); } From patchwork Wed Aug 28 05:49:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780628 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 06F76C5472D for ; Wed, 28 Aug 2024 05:50:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8845D6B00A1; Wed, 28 Aug 2024 01:50:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 833B46B00A2; Wed, 28 Aug 2024 01:50:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6ADD76B00A3; Wed, 28 Aug 2024 01:50:04 -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 4C1696B00A1 for ; Wed, 28 Aug 2024 01:50:04 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0023D141C44 for ; Wed, 28 Aug 2024 05:50:03 +0000 (UTC) X-FDA: 82500578286.16.B8E71E7 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf03.hostedemail.com (Postfix) with ESMTP id F17AA2000C for ; Wed, 28 Aug 2024 05:50:01 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=Hvq0sks3; dmarc=none; spf=pass (imf03.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824137; a=rsa-sha256; cv=none; b=tAJ7cYjBBBc6y41sL3xtjTmX1eT+4eRfBDolwK6jlI9z58pKPVRItghi0M7p0pmqVVLWH6 qR2JjZ8vNbecxRQaHeAL5rVgzVh2D63eSgEZ2T4oQgB/cElpQ78ti9wrTNimErHp47wS2a f2OI4Go1chOKPl2FUDk+wQbDeawtX3w= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=Hvq0sks3; dmarc=none; spf=pass (imf03.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.176 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=1724824137; 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=hfZJveM1parb4u035pYGD3zTISJbrOiZGzu54vNwlmI=; b=fZmu5yD956R3sqSSVI1iLK7QOoR6tHaoErJDLNgS2KXyBGdn+/tEm6s7mVv6Yi+d/5RmtI ydyb0a0b/jOnUSt+XVhjzn5ZN0vqGjHTEgQbYhYZlTIYqWZFD7oeELGOto4mGDDPgNsho1 PAdU1Qg3CW+EVGOjG5VE41gjh4hDEHM= Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2020e83eca1so60935445ad.2 for ; Tue, 27 Aug 2024 22:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824200; x=1725429000; 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=hfZJveM1parb4u035pYGD3zTISJbrOiZGzu54vNwlmI=; b=Hvq0sks3NMvvxy5zVyMaPlgU6StF24udUWJICG6PkXQX1jWxO2tiSrrpZ+0GZHYH20 RHkLnJ2wkSjb7YdL3aXdrpnnTyqlAhwbt02K+LXzzc6iGVDH8Rh+a3K41BZCEhw9+5Il Z6c9RjDJYCHUOS5HNtsYePQfHqjnCKMfmK0ssQ2izm08mCFFkfCZol9i94w0MXJi4zwL YFQjFvw1yVafzHG7eYyj/OW3wG0NWks8eRoWaumlnAOT9X9BfS1u0BnV1g56if8BMAis XyCFcsKVjvEewW7rX3dIF1zqdjl+82ATluJmwq1MgzNxXgDJCGBDA/lHeJeAHt6ZvEz5 FwSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824200; x=1725429000; 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=hfZJveM1parb4u035pYGD3zTISJbrOiZGzu54vNwlmI=; b=NPtHsVCJooz/a1sxBxaYSjjkP3TCwy1xEDXYBApo/rX/Q/Y7EHptAD49d6NoHzLqGr 4o1sgic1r78LpX2dFjBVmS0AphL94BkqB/uAGWDqcoGahtQsx5iJHIXH7yI+K175ByPi gICDoxLAfSpSe/ywMhGquOk2x1UDCRggTjDyo5UNpiqADqWVFKJNTs0wjDO2J6mRKl7W Da9g4blGVkTU3Xhbbbz/plfxKgyy1byq32Pi73piD911/eRNiavFPMGpMKr4trMe1R1e Rt6F3S6Tp2XDElowf9T1YUvSKdDlsQ72Cr5/RZt2U5uOx2S6xmeKwVQM161TfiP2OPgN sq9g== X-Forwarded-Encrypted: i=1; AJvYcCXxohvg+mbd9Pfd39DD3TxxqUh2K87CDZr2BO+0HXUGVgQXh2erPBgNBnZGKpQT+SDi4rDBA6xDNA==@kvack.org X-Gm-Message-State: AOJu0YxOJXPai/uWGMMnofAFvTV3po4OtqujY/VEjAzcaFZ0ggEuaTgt dnnGVNpaAMk320x5WvrYNvwoYAc4hhM9BZ1ZklFVvDl5y1VO+5TwSidL+AWSEdY= X-Google-Smtp-Source: AGHT+IF596NtgPi2otbs5poJBgAoGUDj9IXzCrdKWZMEp8cIFyXQZx8MxZQO71jW2zsopg6SUNTImQ== X-Received: by 2002:a17:903:2352:b0:201:f065:2b2c with SMTP id d9443c01a7336-2039e4fbbe2mr155506935ad.55.1724824200296; Tue, 27 Aug 2024 22:50:00 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:49:59 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:16 -0700 Subject: [PATCH 10/16] arm: mm: Support MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-10-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=1701; i=charlie@rivosinc.com; h=from:subject:message-id; bh=1syBnrvTSOlOGGJG9VxttpQivuBkydj5+eNQ5N/relM=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XfH7+5/NObdD1TC7as2nnrut80uYIpiTE6QKMsStV jRo9UV3lLIwiHEwyIopsvBca2BuvaNfdlS0bALMHFYmkCEMXJwCMJH3iowMbzKLnvWynRbmDQrg 3uNwlaGFp7De9nT0tCfZV9Zxzb2swMjwZeP9u8Jhqpz79ln+TNZVkXSd3DxD3/DEm3BhhnWsrp8 4AQ== X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspamd-Queue-Id: F17AA2000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: r5x4xrcrwt9fscn4gp6eaw4oi7gfhkzo X-HE-Tag: 1724824201-80306 X-HE-Meta: U2FsdGVkX1+cSVXTY8ZQ5HvKZOYQoNUlA36pV9gAScy71BlPS3PLudTnTOV8+fY0KmTMVbqRMeHkOgqj6GJj4Tt8CAc97gClU6A5KV3VzJvDJdCuCsACNc9owUm/gbd7pRECFw9J2fgmWd7dQncil7VgwVb/WXomtFqTMVgBb0FUPPm39Sp8niIbVg5DD7TcFt13OqnkbBf0jkEyatNwdOcx7ExE4QXvKNh7fCv1kZ9RHxMHLvff4PHR6Fb8uelwk/pvXetRoU9IoVUfFBJ20QtRlL2nGVEuf2GhCgRoPvW57jhj1lcEfJRc2FwsLiLlzL5Xb/zxClm0yHlIqCzEAgGnkDHaT1LerQygFR0Wv8oKZUAYBd92Cln8o6v08WD8Sk1jF4nRaTmkQNYLrnGwDowsjYIY1v/ZUWeOzrBKdjljqgTFgKXNwrujucd2xkwzTloiWtfEwmSoP+NEvmaCDDMIE6tqPYpyhk11XoHk1EyO42l8g4EASXSlAV4CDmzREhvkagqr8l/AAoCIuWM23833dLmemkjGktz4nweJ6i8QHJmSzEUDXU7nXiMwqMIFDmeVzpDW3B8MWqGgf2qu5ku8jbMZ3ReA+wry7IzwHu5ZzyM8m0vfH2NgcLz81MIrFpWSFs68Y+vw1lP7a/jIU6GqRSa2fAdrUWzJb29Ca5YE4JdML6RcdlEM7H/exB2iStfQdSURHVpeG4HSkxwxd4PmSpKZgoWQ221RqlH7GDoCYUHTTAH0etsIcTkD+c6QIid6v5yUhP3qCy9epolxACXWO3/G+bxig/S1HBd2cRF7fUYcZIZcSwezI2WCbF1UXXO8T2kkXLBzqg6uIrDQJASi5hyGWDhJ3E7TxmixTB2hPeWPFyNRakBjD8FQEgeSifPyMjAqfYWWssAJzoDnns/EmuE5ThEQAZctxhM87XX9V3H4Ax3NkWgNuUiHNQZkUhUNaMNyk9ckLc/O+1Z QWOY3Vtm 1xYp/YphUMX+OyAG1A5jmI3gDAklpPCBhgm2vpzCaG2sQA8n3St5NDYSUVs4uRfbxy3L3es2aHqhzSY8h8TRV8NarIcbiw3WFZ9Swx0PBD9vLYXY5RyIqyQQ+8negSCrK43swpI0Z8xY5ewmo01g4S+0z2r4Z5JasVpLC6Btj/zRzR9eokmtsTYqnT+32UAbkmnBlpS48yDpmp0SyKtinYUMYNal99uYmQ0m1mqcwDjo6q1JeANGyV2f9oUCIPZNjewg0/4KBM0f3T1+zpi0pfakWGssj07Meo9nsImrWb81gWfitx1d5FMVtv4Ow0DUTPCVuFypUTTV/Yq5DQrxomNySpQOk4WOjDSsneFxbZUtvCowuhiwOIrlvz2fcsBWJ6rRjWjMbjbZAINdbyM472jDIdoOdjlM83HJ3MhxvrFvYD3wgXeu3pq0ABA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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/arm/mm/mmap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c index d65d0e6ed10a..fa0c79447b78 100644 --- a/arch/arm/mm/mmap.c +++ b/arch/arm/mm/mmap.c @@ -71,6 +71,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, info.length = len; info.low_limit = mm->mmap_base; info.high_limit = TASK_SIZE; + if (flags & MAP_BELOW_HINT) + info.high_limit = MIN(info.high_limit, addr + len); info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0; info.align_offset = pgoff << PAGE_SHIFT; return vm_unmapped_area(&info); @@ -122,6 +124,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, info.length = len; info.low_limit = FIRST_USER_ADDRESS; 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_align ? (PAGE_MASK & (SHMLBA - 1)) : 0; info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); @@ -137,6 +145,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, info.flags = 0; info.low_limit = mm->mmap_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); } From patchwork Wed Aug 28 05:49:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780629 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 431B4C5472D for ; Wed, 28 Aug 2024 05:50:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA3336B00A5; Wed, 28 Aug 2024 01:50:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C54786B00A4; Wed, 28 Aug 2024 01:50:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA8326B00A5; Wed, 28 Aug 2024 01:50:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8862A6B00A3 for ; Wed, 28 Aug 2024 01:50:07 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 471EA1C603F for ; Wed, 28 Aug 2024 05:50:07 +0000 (UTC) X-FDA: 82500578454.18.81AE56A Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by imf21.hostedemail.com (Postfix) with ESMTP id 4C7771C0007 for ; Wed, 28 Aug 2024 05:50:05 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=zVSxkCp0; dmarc=none; spf=pass (imf21.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.215.181 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824140; a=rsa-sha256; cv=none; b=mjtnLzpdCPMNMhEwy2HYcajMt5aEzoBmIEMSnm+jw9HgPR+MGbQoWLHJijBOdmdM/Svoa/ H8KM3VE/ebKBzWutQop/5acSTe1BLZKlqbWIYjJkPP5omkp1bhsjjdWePYwNNSKdp1IUEF caT1Hq2EYl/O/WriwHSPTVPbTrjTsf0= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=zVSxkCp0; dmarc=none; spf=pass (imf21.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.215.181 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=1724824140; 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=cPn63wqFJg/NhDtyE6TA0coeolvG0b692sVkrxs6h6w=; b=QjeLcBdgyIBVh5DCArLukbkWBqCb5oFFhQaT3c6H1Syyi6GcldovTGIel+AAZLOAMG8Qxx WWws/dsShHaee7aeAaKde1cbOyZRk60DyR+rwlHbiFE7J+sCoXsvUPS2v+p2EzCXmkX73h B5sxsfchgOuvoW4pWle0ZCdMVzFk13E= Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-7163489149eso3858573a12.1 for ; Tue, 27 Aug 2024 22:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824204; x=1725429004; 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=cPn63wqFJg/NhDtyE6TA0coeolvG0b692sVkrxs6h6w=; b=zVSxkCp03iFGmaWKpn8G+LVsVJT4d3xRbEM9Lj19/2F9ZFXM6NLMKFiIWUlyu11OMN OjD4oftvGr56cJ15uqtTR/jANPRFdqYdGSEg3pETUJ6D5YKa02WLBfoSxnGj++0x90pH YBjvtPefjI6C2LdC5g7yHzE/cixOZQtmKap9e7RjNAiichtjoaL20yprnI74Fh5dJ4zz qOumD1WtFSwFQTAKrZLKmeRNGEqUy5Z//xYboYTp3LEwXqwigbpF5NIqjdv/zIG6ELbk 2EPEmGB+B9xYO5G6uoBDJ7iWe6JR1bhqm91vSLH2f/jjeaGIwVZ5PsE3P9rgaKME6i6g +pxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824204; x=1725429004; 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=cPn63wqFJg/NhDtyE6TA0coeolvG0b692sVkrxs6h6w=; b=hy7DYZL2QLOF5ZujV/ReVTfsoptYd123yiC7Ycnk8DPyXZOr2oG+QGjz2ZX3jinoCS 71AwPgBgaUUERBbBWr7WQmVWHnFGNErZ5UAvHmygNik+lJMtFnQJfBBuwbhmVuUXHIin RTDVPaiHhy1guAazEBKu2uxe1ojvUF+SH/vdUf9Gusapa0rUPr5k/kI2fk/Kkss/LdZq jraJdzPEI+o/V5S+HGLPZRc7zQrWFKm7F2Cxww5iEJEyc8A4oDahuvEOp/jwfeo2dzkM W24mdNVnU+xt3Yw809xEchdzfQcNVNDTUfTY7oerWdll4PfP0DPIntKziC+sGq28SvyI WOUw== X-Forwarded-Encrypted: i=1; AJvYcCWm/mVZrFStOhB006Sf9VvIfMNdXnoJMQ1lv8LXhF6QcMvB6ADVfJEtLaJ7D52wFciLqWaANitEXQ==@kvack.org X-Gm-Message-State: AOJu0YzJ2E95yul/b3IoQkvCcZmeyFstT0bK2O4Kw5eGjClt0+lJyNC1 jPHYHvo7oVX40bHFK32Ai1WYgr4KMXQTC16unvm9ytBICbFdF5erAHOw5uUoxA0= X-Google-Smtp-Source: AGHT+IExz2l4cJy30WX6CK7UJnnTV99XpNodRNjqDrqaX9iShx7VT4aEy+MVWDHksfv413xg6BHqWQ== X-Received: by 2002:a05:6a20:c6c1:b0:1c3:b61c:57cb with SMTP id adf61e73a8af0-1cc8b63e7admr19641639637.53.1724824203730; Tue, 27 Aug 2024 22:50:03 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:50:02 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:17 -0700 Subject: [PATCH 11/16] mips: mm: Support MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-11-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=1222; i=charlie@rivosinc.com; h=from:subject:message-id; bh=hr+5sO+DwZ7b30hixHrcXcBJzkXJVKP+oyQ8pDF00F0=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XQkfk1qWxrKnZbieZ1K/6LSwKGjL0hcztOaE2KQe3 3vFh3FJRykLgxgHg6yYIgvPtQbm1jv6ZUdFyybAzGFlAhnCwMUpABMReMjwm1XqYMYTd7kZ029e Ywn89Unq1bGI6TwyXnVzFq65HWqvWsnIcHriXK9fRsZbv646duvxv8pFDmYGX/naxDT1E9+JfDu ykAsA X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspamd-Queue-Id: 4C7771C0007 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 1sseceifpssaomcy3x4h5sxaperrhw9u X-HE-Tag: 1724824205-413365 X-HE-Meta: U2FsdGVkX19HR9fiRIHazRsZuI1UMF5Hoj2rlSR83+7xcrOVAKsSG7pdyEF2ZRxG1/Yzdoc6PNL1y8Kh8rJwzTR+ndWgX0JZKXZWTlaoEAx4UAyfobW/W/Q1iMLK+jzJNHEBShJxVbshG0S/qv+ij+p/DcvCwffSx4MxzQ9rnkikHGZrgRfrHcaRyKldb5Jge5AgZL426SJFK4xYiZf8scQDr65pnnMFBvuDpAX0OwHcVumJKo5fLy6genTimMC6rUUtHafHGE3uLM2d0g2zLbg+s3mNCGQGpzJunL0p6i0sIHq0VXM7NHw3/XU5qhJo7NVM6sKdOFHPjWI76grVyFQXahaI7xl/llu2xOsQCXKkxVdU8BqTslpBsPDIHz5UIl0Alkd9XO555taT8xV+060lk8DUdx8kVVE4+5lLepMdDYGV+/XuMub/R1Q1bN1AUmDD08scZCAT7cvUoQeq9jR4wfxDflkDVlUt6EcPVvPWYA7gtO8PRvi5I12FnuUFIEe1TnEgKyQHtzRgAN3qSZNtNc6Kbz8p8iRFe9Nva9Fx3kUeyUSOAD+Tbz3A5pcNCci4qOGrLRmveH5K8h9zbwGu4qhXDtIuU2QjZplCdk9LT28N8d5Jh4qoduqxcOW6Mu+4KZQAEjf8JgfY4+MJIsrkJINMUKBICt/g83RfANzgRQLNCIpEPaukqNEsKPCL24uEN6U4TV2MW1zaarUbc+MdTZUqJKT5nAkSIYjYe1HMuniuh+belJm0i7n4xQcb+SoY2wwqm8Y3GKHVVoEgvWHQbGHCwPFgqRRcB3kqrXQCOliLiWZG2q3cIBHav+DvLmLHpewPuw5dkZlrRy7UWlG7AiWDTdlot1jkaGhz+2IY+pvhxkgiLBlJRZIIQ9t0qi/YRnozvu6unBC3ABSb+Mp5XozX6xfBFcGcz5I82xVccdRzo9Hl9RBURu0ejAuqIAfX/BizCtZ/JVQ1yoH bpdtfY3+ MZCzNJ5EzZ8ZUyo3L9QRKLcaw2hMHrOHiKsAKZEYGbWB+x7wKGqF3sysGJ3+nldADK5HturZWwozBnAIfRj02CoccTLl9wb4gQ8OFnil+v5uj/PS25qmLhVdynjeHslHLiEANe5xAth2xbznvI4uryw6kXmW0y+O0RnhyzebpzmymlqhifIs4pt0S/1+eQJj3KBE0FOdjaMTJXrho2oP7h6dvB4yBP2qsZklYxRNJebTl4WCl26KDF7raoq/ga6DD+ziKdB0EWbeNxfqy5uDiVAP04jccAg/1Q9uhgskEZq+/d+HdRg80Dpfv888c/vRyLxMJ7KDSrDeHKqOXk27b4e98vEwt1yugdhIONQjfS2yABfUvEuW99HEwkFO3srQ+nbVsXF5ZEi6a4pjdFeXotN9XqeH2QYRrk7WNzgcAjiBpwFIebljV/FO6Yw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, 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/mips/mm/mmap.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c index 7e11d7b58761..1595fda284cd 100644 --- a/arch/mips/mm/mmap.c +++ b/arch/mips/mm/mmap.c @@ -79,6 +79,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)) @@ -94,6 +101,8 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp, info.low_limit = mm->mmap_base; info.high_limit = TASK_SIZE; + if (flags & MAP_BELOW_HINT) + info.high_limit = MIN(info.high_limit, addr + len); return vm_unmapped_area(&info); } From patchwork Wed Aug 28 05:49:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780630 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 8A5E9C5472D for ; Wed, 28 Aug 2024 05:50:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B3C56B00A4; Wed, 28 Aug 2024 01:50:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 159646B00A6; Wed, 28 Aug 2024 01:50:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC4C66B00A7; Wed, 28 Aug 2024 01:50:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C9B896B00A4 for ; Wed, 28 Aug 2024 01:50:10 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8894E1C4F2E for ; Wed, 28 Aug 2024 05:50:10 +0000 (UTC) X-FDA: 82500578580.19.F06A8CB Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf17.hostedemail.com (Postfix) with ESMTP id 943E240003 for ; Wed, 28 Aug 2024 05:50:08 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="w9K6g5/g"; spf=pass (imf17.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=1724824165; 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=mnBGdEXd1SbkXIrtxJgk/JDNcWExLMEwccaijei9Lbw=; b=ndRT8mMbEhFiZrgyGUfh7nVSs7bMr2/PSaqZwcfj5wmcvXjbzOfK1OUIj274JbHhlBHyws N2D8/8bTDadgU0xpg+9A9m2Q+rpXYicMd+5LOLsjhVLD2VcOi3PbLnQ6JlYNBF0WNJQZfs RBhZ9vsRodCbeCHPyrxGaeCcH+llPBk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="w9K6g5/g"; spf=pass (imf17.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824165; a=rsa-sha256; cv=none; b=AhXtwUUI/18BbKRLRU6zsaGo69np6TELjDPB0hMQCw3qAj0jqABh2BZlabz3C2gl+1ArTe sJKop+n0dgJ9/HlHNnelFtEoSzlJph849ulZTWexzDrQ9SFDiDJQjUVXD3Bt816EulO23v qK/SFPE0cDcZVGD3dMjwzhnP3olO4AA= Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-202318c4f45so65337645ad.0 for ; Tue, 27 Aug 2024 22:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824207; x=1725429007; 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=mnBGdEXd1SbkXIrtxJgk/JDNcWExLMEwccaijei9Lbw=; b=w9K6g5/g7T0zcYjoQ1hHB0DJx1B6X3PSKlEJi+i7P7txn2cfT7Bb2+3Un9G6mHYbYK tDAJBBC04iLwLpprZaj9BE60Y+bYM5z/4DX4ZZotV0wrvqy+y3cB9MXIQnW37VsRua6K dvvusntN+K7xlb3esv5Bbk2O5VAtOmFtxbsjCB0aYSWaitkp24Wxbp37IJorBbw6PDAm 14/8FTtYgUnqW3IKl5ySDwr+fEM6u7Na/XsNS7mpIWeI4dbb9zusBCXpVS8MAZyAUs+R myGsb/4+HaTn551073zwaAaAQYqY3XZsTaVZBoThRePmK+n4sNIKo/zYz93E56/kYrcg ox3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824207; x=1725429007; 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=mnBGdEXd1SbkXIrtxJgk/JDNcWExLMEwccaijei9Lbw=; b=KUrFQXGGIQRjA9mlrnr0T7sFOEH/ER11UpRGRbSsF+edP5nmRph4qb5rjlu+ZwJJy+ MWfGXdYhSlIkrdz8KtQbSq7rhcvRmrRG3UVHjNWABt/3QrTfMOxuNxlaV7E/rb61HzZV W7FyzG9hGyMfsKW15Z3wQMV3Yewa2ggeOa2PWSbDRQcKEK7tjHCZnFXM+OV/GBiuznlP pQ6fcpiJtmISpGs7bHyewd7Bs03f6jVfezMpeVEg/c5Fk4qx9xIc28WKy0DtLxhfYkXU 9qyV9uRfrviAVjwABAZiLKOuhcOAOYzyboqAgix+28XJOdwYEsMEOi/1CrXUKuksdabC hqmQ== X-Forwarded-Encrypted: i=1; AJvYcCU5bNLPlIdLefVu1KmWLInHK8Z0kl9/wX5sZNsGxnKHLlBj2WahrOBlVjMm0fnM5kjp5Hu7/6Rhew==@kvack.org X-Gm-Message-State: AOJu0YxF0k4r6g8j/5EyrDZDeGu9yS7ieJ9VnZ69bMW9tiweJmpmQrE+ LQpctj3aPzHR9OfFvsWhOFBQV8RUTl+Cw19dV+MS5Hj6TUgsUvVxpZ/ySvatD6A= X-Google-Smtp-Source: AGHT+IEsQQCnEuxvR964+0rX/KlAEG5qqvky10H/EfSUq5MJAsWWGO7Ld//wKHkIp7XPnG+kf0G25w== X-Received: by 2002:a17:902:cf07:b0:202:60e:7700 with SMTP id d9443c01a7336-204f9a548eemr12735035ad.7.1724824207147; Tue, 27 Aug 2024 22:50:07 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:50:06 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:18 -0700 Subject: [PATCH 12/16] parisc: mm: Support MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-12-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=2500; i=charlie@rivosinc.com; h=from:subject:message-id; bh=RM+/CbqQAwiDfaQaSk6aR6JgRkcXqI3LycpAEGdsrx8=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XQl7j2395l162Zz3ULDsob8MjXdzJ1/bXx7d7Lq5e d+zLQfcO0pZGMQ4GGTFFFl4rjUwt97RLzsqWjYBZg4rE8gQBi5OAZjIAVaGfwp5ZTFJes0Kym85 OvJO+pR7Lg+83rfo09z/TvfTNed8SmX4751+T74tYdaFrpd5nh9q5rfzOL+4IN+53YNdoEni27c l3AA= X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 943E240003 X-Stat-Signature: k4mx8kkxbzns56bwxz5fo85qbbh3o55q X-HE-Tag: 1724824208-39101 X-HE-Meta: U2FsdGVkX19EV/SQT9eA2n6Fyf1hdDA5IcJEGKPLLyF847iHWf9+bJDkX+rN8xQMPk1G4bKg6k4t/NnPu6Yxmpo8Htlq0fJeV46jRwyiao5+Q/zQ3DC05whDvyTx+96atv+nIlKQEi+aqGpI4FTOpQAmafK0uinnRX+pZkIIeIbBiJpmp5qpNY1Y6Ip4m0nii837CCWILhKVY7ehsM3aGFrr+E1WSphXxXf+cLDHhcfevg748gHT0tH3TWHIkkENZkfeUaKJblLXGqWuJlKABPBaIEr5fXeuYL0LH7urG3hhTqbE9RYPpUqgBW6tifOGdgO3la3gDzq8mmveCecZjyUa1T7zlKaXzDfObebY1rqlYGZpCsfvxV4l74SIs9FOaM4okS4+rkM90RaIId9bghBoxpvRELFpaOKBWL7LesAJb4i0vnMPf/3NMN5llzLCMg2hnvT+QVeosAo+9vsfJspYJACnODjb5jaHxxDww9I+7B21W1YfeaYLSqdA16yfdShR1/X4g5Veea7+k19FMbBih7ViyL0oBV+surNwOZ0slAu3vY32Md4vCtboj7VCj8XsP52zsdwAReeQnvH/uB96nOa+wDtRGVXQPjUNTCZCOy0i+BFMpr7E1JKdAbpTKKJALw9/pBHSvhb+CL1qaAUSiY7Cw6FAAIXHZKBtKxK5LxUbLViwolquuE/qSKq3o41buips7Ok2TTOK7VWyVISKhyxxDwIDuUSNOfXMJwDyVF3ZJSIcUk3otKJk6r9RcyF+XXP5SK/VDxc/sIbqoEIlakzs1oq6ZT7r7c+16G8ORYyP65PmD1kkOLaimHyXUtcrMI75qWUExoKF3D2Ho+QZK0QDRUIwoqk9dkJeWtc0nCbPNnkm+bPqfwG+PWP/ss9IskRJOjbUveqci7SZ7V/+Q2qnVwCUR5wXa8RnLfU4uen1Herk91NbN5G4znSi3Y8VwoIut/lRiO15bfh 5JlVGjXq GaSeqZv2g8CWTxmP+pV7Jm98RLUx7vp7LIzx/whaz1I4VU34W9kNjMfy1KpdzWPmieqG9F1O3SkF/Y/YBZSLzapCRsG8kS+0Y980BhxU0+EzuMBDozh7HNsDhO8S7rjz71QPI/LHD/ODEhaKuXj/fzwhYq7L07e038kVH5Z2zXsgWmF8CQmAHv5XsRpGvY5PX6wKaeT/LD/DoK2Cgipp6+a+Q3i5CclhbZebj6dmUEUtxEijpSvzwGE4QEs7s8FEC/t3UIFf1tLSXyiAkprd1vKc6yZet0FlJAlwgYjKk8zWVVccpEOzzd6U9hBN8sA2FxVPNe6tuDaPuEoVKsUPv0dfBCrvhpcJCyrYXapBR7INpCXWN+1NWJIgrqLwwNBWvWqAFgw8YxWe3AVLoL/ic0ksU8OlB2bGCNy0PRvzUTo1CChFhM7WY1Vt7fQ== 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/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 From patchwork Wed Aug 28 05:49:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780631 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 13AE7C5474A for ; Wed, 28 Aug 2024 05:50:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9978C6B00A9; Wed, 28 Aug 2024 01:50:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 945636B00A8; Wed, 28 Aug 2024 01:50:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C0C66B00A9; Wed, 28 Aug 2024 01:50:14 -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 59E126B00A7 for ; Wed, 28 Aug 2024 01:50:14 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1D6541C4F2E for ; Wed, 28 Aug 2024 05:50:14 +0000 (UTC) X-FDA: 82500578748.18.B23E8D3 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by imf09.hostedemail.com (Postfix) with ESMTP id 18191140017 for ; Wed, 28 Aug 2024 05:50:11 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=dkOOoxLT; spf=pass (imf09.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.215.181 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=1724824124; 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=AarzQWw7jN5pNetRW1c1iMmZVGfhSNhFxAvdf8X4j7o=; b=QKh+WJ2c1x9cGIHcCcPxMYs8cN11ZE6nCTtE31AaC4WCOtY/HOlw/ou7/szZC88Toryi09 GXI1Q8eDm5D5ULwkRiUojw1EOMRgdDe6U3VRvFXQku3zDysNubZGcIJb9k7qGlEoPVic29 F7tYw3Ca0zE/P3yCOWw0W9PnQUSQRdE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824124; a=rsa-sha256; cv=none; b=oyPCEfKQGhXh9Kt08HhFfTNpi3J5shdULTDBl7rfpdImV2oGHSWZOf4qj6yQraIVEhfauh qvqvshX5plTjVMzSpFBrjTIrbYn1IjD2bET7covakw6KBstGQLzLdBA7xMyMD2+vHHuhAw SH/7n9aCF9vSKbE530YC+Ep8RBuKTFQ= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=dkOOoxLT; spf=pass (imf09.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.215.181 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-76cb5b6b3e4so3982702a12.1 for ; Tue, 27 Aug 2024 22:50:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824211; x=1725429011; 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=AarzQWw7jN5pNetRW1c1iMmZVGfhSNhFxAvdf8X4j7o=; b=dkOOoxLTutCC59wy8Qlun42bU3Vcnx/g3UsW79EIhUJeNtaW/Ju00YYvV8+Ej1wDEz mZp1GJTyUNNL9KzEQO4J30Dydi+u8aezzwTOpWJCnsyAvw1MZA0j0FIJEbyfJLX8nhoo CIO23kpBmVGkaGCT/vTQudAbHhveG9z3p6mn4skyws2hSJBDd6tl/dbavaUL4UwZ3ASZ F+h5L9Rf7rR5+s7hqn0YmodyK2QRPBL85w9CLjVGk1zZEu3CVvIjsAmSIM+qTx+m6fmK DcE7qfliCujiZWB4MX3oqmshNjiz3uxaVikMVTjebLD3CCATaGHbKTEA1KtL8oOELU5w 5zaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824211; x=1725429011; 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=AarzQWw7jN5pNetRW1c1iMmZVGfhSNhFxAvdf8X4j7o=; b=UBoOXVTkTDtZdtwkXb2uSZB045KbW53hhlogwGxwcJF0wNHuOJy/6THbL4NRtMCsnM hjLcqPGG0+NMCMskllPVKPCAa2POqqDNNEj3yBJoG30rlFyrz3teeKk1LARDmF8+lLyh NW7xcIuTRjSQv1IfYJKdmj282LjW1dMlr8kj1anFFVMGmUWGdzMcHTiWVPy33UTJ8Fl0 CH6G0iWbBK/ZaBUiaKZh50L3+1wf+HVWe4htOPxmj7e6img8NbYcaSCdYRcYMPiLe2Rj gkv9XNOYSLE0x4KuTMMlS2WwLruUbTdMp3Hl7Q0XfYdbX8U2DlIQuQxNEcpXw9cZT2nv aDgQ== X-Forwarded-Encrypted: i=1; AJvYcCXEj/L4GNc2WspdU0zBjbie62aZUsRNjgeoiu742oJTqE67aeGJJRl0f0bMR5g0ZLZM+PI+tzaPyQ==@kvack.org X-Gm-Message-State: AOJu0YyfoXFya8USBBInpnld68L/BHwchT3BWxooYOmTuL6NgmDwFIAT TNJ8qpJ/sFDLuNo+QsdtXCdfq5c0DW1FafRDnKK776hq9iaA8SkzN5OrGD+9WOQ= X-Google-Smtp-Source: AGHT+IGSDxOLe5G0EzaI75j/pi3mF3L/KyOur/N+gUKJdt7aHyrcvZDzyi6uPsaAVyWSE2f/rnhW5w== X-Received: by 2002:a05:6a21:2d8f:b0:1cc:cdb6:c11a with SMTP id adf61e73a8af0-1cccdb6c913mr2470861637.24.1724824210534; Tue, 27 Aug 2024 22:50:10 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:50:09 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:19 -0700 Subject: [PATCH 13/16] s390: mm: Support MAP_BELOW_HINT MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-13-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=1730; i=charlie@rivosinc.com; h=from:subject:message-id; bh=LDlOb3puh00G9LsastMFHCdP3tuzGW5CWMac22J4/f0=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XQkTzp+9JuBqJbUp4CZHz86P7jsl/+dUPtx28/aiw uJ/F77s7ShlYRDjYJAVU2ThudbA3HpHv+yoaNkEmDmsTCBDGLg4BWAilewM/zPyq60vOxt27XXL PhSUqxi9dMWuaSXlSf4nvq4JmxBdu5+RYfa1r9wzZq5YzaDtGr2m541pUMtOl1Xnuf/rbZGaqVf Eyg0A X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 18191140017 X-Stat-Signature: apeeb31gmwhya796syoa6fff5kzctep4 X-HE-Tag: 1724824211-533049 X-HE-Meta: U2FsdGVkX18qDko1cy5YpuNDHMsJPNxMZ5FEzIkw+o5cIvcnvPRGJEVaQWWieLD9G9l1CuVHaXqnJWEG1A8L8/PksdiK4hxEFXl1appL9aA4UXB27Lek89xV1zfkfOZmvlfTyrx2SbwwlJz5Yr2xjd0j10sX6FeptypuFaH3wRPHBrTyUPD6UdfVwE/AJJ+iwVlo8OQtVXkNXgHxBDQljuUzIsFTwwGACmv2W3qoT9r6AUQ6Kxztrx5rtopu8fvf3q2Mpz6PrUzNdO6lSADsJAwcwBHi60vpppsYXiNbFjYRRU7iGxiIy3l7yysRduhyJl0Jm/OeEAygG21rGcJE5Q8QNWXCNtd3HFnTL/ezy6J5HayyZCBj7rkoA3kZ3ck7mektrgeqErfQOxooHIbyDJIHOEf5HrG1J4fLPikpFuodbpwW3cH9hlEZ8qc+dM9dNqBf80vuthX1WKN7kedX3UnfO7MDNdjVXq6TQhe0ISOXrO+9XK1EVtH7XbVXstrebAJ4Are/h9BJ8hgI14nnttyV3U65qQNki+mBF0kYtsBlnAc1pfPggVqlxUON3UBEvx1zHfbWY7VyPre4L9uB8sIOrzx2vZy5uBFHLcL9rOnhXnaUJ1TPjOb+7C+3K3EiBmvxVvFuM2yJGnVKTtDC8Q8SPFiT0TRSaV0RrZg1DuJ1LLz9JixrycVyUuTI3xYalNWAC8zsisjHnFIOJoKl2B5u8mbA4MREFQgpSgDBpPwcmy4zECDxrEwriedI/hOfoDzET80vgr2iJF2e6h1j21rWynEaJMvM0FDweqvEaw0MQ4ycnB0NQzGn1As+7Xt8Npr3xNolR7An6j4rIHJGz5sEYslJznnJJ32epdFKAiuDdDhSgHttXZ0K8KUFePHKGd9CFCyr2OniI/0zxwlH6jr5h3y6OS1EGJ7B9XxkjCyigtMglZyPLMxgJBLn67CYesX+SjoMVKeEkCzLGOP Ib/k3MHr JrqSeoINjVGOmGR/6ULBzWpzNx41fSAzXGRGYpxEuYq/iCEEpOyI6iiHaTw/bATsqsddZIoyy5ft4bSsGCTn/fjbLJATc+OChj6sy9THf0x3GvwWWAEI26wnvhsfJaLjiKUiDt6U6CMTnt1uP/qnvQcLqyNsUbPTQdSi2BwVWLCY/8ZAyPL4DOVTnO/QjYmi1DPqcnwoPR1rCqJufCJ+RtQlTTq7JUEhYlGeI06czxDA2wWS8/XdHGppmxifidnn2h0ytIAzFjBqwb/laTh3DwocKGl8F3sOGZRnhVT+chI8O+VENX1mWtQsmGha/zEHEktuvNCree3D61UqO3s8ZsVef47sqkiAeKJTF/WzvFd8N7BGIZjzNys9AgS470z4gzDFHtNqGyxUOS74E0dxlD7k9N1rt/enRSZ10h8oIpjMucKTFiCGrk1J7lQ== 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: 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/s390/mm/mmap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index 206756946589..29e20351ca85 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -105,6 +105,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, info.length = len; info.low_limit = mm->mmap_base; info.high_limit = TASK_SIZE; + if (flags & MAP_BELOW_HINT) + info.high_limit = MIN(info.high_limit, addr + len); info.align_mask = get_align_mask(filp, flags); info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); @@ -143,6 +145,12 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned long ad 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 = get_align_mask(filp, flags); info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); @@ -158,6 +166,8 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned long ad info.flags = 0; info.low_limit = TASK_UNMAPPED_BASE; info.high_limit = TASK_SIZE; + if (flags & MAP_BELOW_HINT) + info.high_limit = MIN(TASK_SIZE, addr + len); addr = vm_unmapped_area(&info); if (offset_in_page(addr)) return addr; From patchwork Wed Aug 28 05:49:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780632 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 7CB56C5472D for ; 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 ; 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 ; 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 ; 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 ; 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 Date: Tue, 27 Aug 2024 22:49:20 -0700 Subject: [PATCH 14/16] sh: mm: Support MAP_BELOW_HINT MIME-Version: 1.0 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 , 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=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: 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/sh/mm/mmap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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); } 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+prE9W7Eul60oDZUKJfdf7UpRDQyrgnxlU6WMNcAvziV81JCZz2RwzfDe6EhmNiqqZe3TA3Kl8pBG4kO9pnA6yk8lmpy0AMoPvKLevvDm4aIjl8Vg8jJOWR/aIXEaHRfdDIZaCm0hL8rkalm1Z4io+uyBwZ61SdydAoLlIBe3bbzd8UoQpZnAS8+2Na4rSdb6yl4SDGbpZkBrDbQWqKaYIN/R3CBAQrtZpzPL5Y6meJgctNEI8HRObTZv2BoXdFdPqZeji4gKYptr646iDJ7Md0isBHf2XYblu3eHwfvNAxcSp6+5JpIDSDw5oe3bBkFojyZMLETnhvh54ievSPBPTIWO12fjU7v3qkwG3DKNGxiaUhF2tPDlCLPt4rDzs4+9XFII+UCyu1WrmkOZ7vbSEnGlyX5xGMWf1JniGR71CYRy6Mpa6kf73vFqBH2qMoNJuO1AGn5gT1BU9K1+XrJWMlKs88uMMn2Uz1x0KoP08P5fjEbb34JrWJQBZHdc98wyy2NPKYrQhRm/NIOVWQ/dO8B0pRzDnOmt1h3jfAbQNp0qiF/nnYQsl5238CnEWqmAQiqhOGVJAzCMmC0L7IPlT0UDZqwWVBCd3Uc0qtnIgVkjMa5u2R+LKuSscyvpRDIk6N5g1HdZQh+2mK4XfaRYOhUcP1UH7+cZymOO7++sY/Hrl2plMChxehAHzY1gDs6O56w0mnQpPAE iKMF3goq ypfRYL72iA5kkjpZzlrOmC2CdaDK/ZG5RazAjQ9pwrHN7Hl0yd1IVpiK6Bo9sMVaUTLuAiRoABu976jhHiI2+OCIGZM6FbD2MMbs2/lk4FlHlEW5qnppquKumfrl2A6xkskm5SQ9Pz5TyN3cy40HMIW33cqibE4Zi6dwICO82+VyH1mTyfNDAWF+LxvUe8R1s/jtqTXKMFBuarUHp+V/9QOkbWF/ZLAeZO5x9FkP2ICqebAF3+rjwJDy4pEMsGTicDYRIkY6UxDBMy9HaT1yMBGb+fO3XXNx1aO6yRB4SZNutVnF0c8M+DZGKUQHEIwdPUJlUvpeJ3+d7RvNDTG4FB7RzjaLgdZ+lfy3zzgbH3bF/S6CColypDr55bCzYdu0c9wCguRxz7ut9kWo5faciT3UHRfUC9BPkp/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); } From patchwork Wed Aug 28 05:49:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13780634 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 9EA3DC5474A for ; Wed, 28 Aug 2024 05:50:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32FBA6B00AD; Wed, 28 Aug 2024 01:50:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B7E36B00AE; Wed, 28 Aug 2024 01:50:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E57E6B00AF; Wed, 28 Aug 2024 01:50:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id DE29B6B00AD for ; Wed, 28 Aug 2024 01:50:24 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6CE19A1C6B for ; Wed, 28 Aug 2024 05:50:24 +0000 (UTC) X-FDA: 82500579168.18.75F69D1 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf01.hostedemail.com (Postfix) with ESMTP id 66BB940017 for ; Wed, 28 Aug 2024 05:50:22 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=1UttVT29; spf=pass (imf01.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.173 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=1724824106; 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=n1bnpMYTna27bSqlaeNn9zMkLMdTuL1lgzvNhNTdiTs=; b=Ms9hgy4CqnH2LOCFvZ6KySr9bkvGB9iLZGlOhXJ6EoV4c5lcEW8V8SdvbkcyeO0GYHOVm4 XOtO36+vHxboy0FgurVdoognhDZcPYyzPjq+4ZTTvj/NiQ+HmgIclmnJixn4Dn3mCwN6iV icbMMQJ/nhkhsUEMCfq5UoTHgN6xq0w= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=1UttVT29; spf=pass (imf01.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=charlie@rivosinc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724824106; a=rsa-sha256; cv=none; b=yWI0XfbbfsJhYHztiRsJUSrhEx8RmzzGKTxXX3TP8XPmRKo/ZpOMLVTMweJczw2qMfWW+w +DqOtekKUWh+hL4bnGRdFwoZV/xCg74Rur4rx+W6NU03biiryVQkj5dSNF0P1o4fxbR/Bu kXJuhuYVFTxE00AwXnQK7TASNWgdwM4= Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-20202df1c2fso1733085ad.1 for ; Tue, 27 Aug 2024 22:50:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724824221; x=1725429021; 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=n1bnpMYTna27bSqlaeNn9zMkLMdTuL1lgzvNhNTdiTs=; b=1UttVT29GIjos/tIx0WO8/cahE0cVSohVIT+ZqQLKdZ+vm6/XDhgnlFj2BmkJzxs6M Sb3NfMhomPFMDcvbdRVwyMywf7PmxZ+IiW6HtA6qy1uYNsxXWWhsrW7zb3ovy6yZ92vv MkuISmX9TFtV5o7B/kewnyfTIrwV0KaivgogH0xnQ87l4fjZ+Sy0t3Qh+c3i438kUiIh GXwAzFiqEDqrAMoheeut6vpyJxJiQvfKIiBFciDqK5dmTk7b8yLAie5XIlT/QpyMvYUQ PQCesxKnuyFvK/doNSJH1tACj+bzd1Ik+vYEJvLUFMjTmeRuIvQfMViOvd9lDFi2E79H A13g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724824221; x=1725429021; 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=n1bnpMYTna27bSqlaeNn9zMkLMdTuL1lgzvNhNTdiTs=; b=hDiU3HvjfwLFdPKsVLiDWmoC4za3BwNmlU/rIZ97LdH7wloWNhbl2A2R5W6v0ueUxz jLjArqXlZVX5Y8uJFMoq1Oll+5TZILEehOh/hQ0SFgvWVArOehdlXu6rUsAQbCZUg7mV SqBSEo627zax5y9REMjfJxbA8UhZuM8w1672U3ZTYW2AKBMmknLchLMwxJtazWAxgqA1 DrIVR+3WaTFM6NHQt8NGPHf18wKlsvsamPVscx7neyUBwhvfZhzueIogux//BhU6LPSc SB+pdRs7zxC/rbxpreyj9a9G7+7YmfMpRI5rL0GQizvQDh71jEMk0lWNq3+iw46doWmD dReg== X-Forwarded-Encrypted: i=1; AJvYcCVQDk4Ni5EiNB0AUw8KmZYegfHzteR2tCJvBfyMuSeTl1w6wk+E+sm9mmT7+27u3bwY9kNrchv6Yw==@kvack.org X-Gm-Message-State: AOJu0YzCG89vHvTI6HjNtF/qqL2HCpqUO1Pakz8qj0TW2C+ssy2v2q9+ yAlfImj8ZRCJi645L3KZX0kbe8hEFnO34spLAN17mdWvVd/xYIAmLKPB1mIMBbQ= X-Google-Smtp-Source: AGHT+IGQeeMMIWRhlzvEY447u73v0bcDYqggMB4NKbY4CT7iyrW8LbpZG4Gsc+7GkkDRX2iCA5iJHw== X-Received: by 2002:a17:903:35d0:b0:1fc:41c0:7a82 with SMTP id d9443c01a7336-204f9912733mr19656305ad.0.1724824220864; Tue, 27 Aug 2024 22:50:20 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 22:50:20 -0700 (PDT) From: Charlie Jenkins Date: Tue, 27 Aug 2024 22:49:22 -0700 Subject: [PATCH 16/16] selftests/mm: Create MAP_BELOW_HINT test MIME-Version: 1.0 Message-Id: <20240827-patches-below_hint_mmap-v1-16-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=1906; i=charlie@rivosinc.com; h=from:subject:message-id; bh=bFLw7L4BlwG3KLICmNgvPIAvf1/5Sm3GeWEQAkx1eJA=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9q5XYnPPfbbPo8yeWL66+yxo/N6BS8nd1/7qNQhsOWpf 3tQ+KzTHaUsDGIcDLJiiiw81xqYW+/olx0VLZsAM4eVCWQIAxenAEzkdAYjwwau79apS3QeSJmm 67cdPe+1+9TsAsXmhc0Xrt4+G6VRe5aR4ekEGZPT2yyYhB/f/i4QYfZn696jodpGS1YWP+X48/d dEQMA X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 66BB940017 X-Stat-Signature: oxubgedptpbui7i9hiuhiqh3bscu1h7j X-Rspam-User: X-HE-Tag: 1724824222-70790 X-HE-Meta: U2FsdGVkX185AeXsetzoJzXNRCwF2DBXHZcubgEMbcHrtvw2oviom6Ap/ocHPeQxtyyxZ/flHAPvuo0cPLKPvSY6HrymcMZlwkJQ9Qkshi1tP7uYgfIyf22FN70yaIahWVduxeWPolQORgp/Wq7rZUEWra23XvYpQ+q8okyw6GsiYW/N12ovjF/0HqnJqvciw+DurnwHEJ+AOAynT8lB0ZCGm29HauZ3hEDwV6Dh00kXmppQShGcE8OsHsxBUxdsCUk4Ic53OhUtYDoGiJcTjg/Ra8XffGIjitAp2YW5b7eyd1o0Yml05B7u8eJGXF3eft61PbuWDVOGpnaAofiMlTg5tlhABu3zQeDRCqCB20seWwayMOV6KLJY8LBnEkDw5jNifUV1Q9i4TvtiNAzWsd90+zO6mwzwlKIx5tnYbClsAhpjGILUJpFLkzJTtZLUhZnE+HITWr9chyTwr3xaHQq1VGqol1xHzwJyPPBTQgPXzUgiCqU9NMMKJzTbuOWrgk9ValQhlcVbgfXzvYIZYCPwlv9KER8uYWhrSL5YjkLxCA1Sx7oi6+uRnV9QfVqitdvJWJZCuCQ131Fg6PySyXVMi087FLZSqKFFgHa4Gjc4Tv7XgKTIvBbVEZvhz/g+A29T9BxcM+MpVbrlEyjGEk+V/YZ8YXR3GAd4HFPhqgBVIvTdpvjlVvIopjnxdrBV8dPJkS88zdJht591DuqXDu/Df++t1oUHEqu3RfbrdcuRZCPSpPhuHGHH28WwgTuCvjboeZTxAeKAD+Ulm7aYaaG1HSmFJ97uvR9umHSyt+C65uaTP5HLDJRJ6FfmZy/fmEJ0+yhLjFsYIjS4FAbKxB+nUCI92tS+AnDNmiDNSgC7merPzUOIVvBAJjhhsAwnrHYT0Asdnw4Cf4FMhxbgRRoui7djvLQYZGo2QetSnlnqf3eTSrH6OV7hjty9eEjDCEC2BNWeGT3gMtKIAJJ hN0iUyiD 5tur/N1MrSV2DxGUrcLr30T32JzgKiH5PxyLH0kDdGeE5UR18VtSIxa3yKiVLCil/n+pyo3DdNb39pKiKfeF1RXpnzqMNPGmWm45KyGlpkTll6QCAcOwkKwq0vZrJ/EIyg4eIoEuFsSAsldI/tvDvduU3xcrS2+p8lf3Uls6UCudPeQC8EeicgTDwODITMIJqnNdR0Dclhrj/WWP8PmAP/MF1+ZQj4dJdQR9GmSSpIAg8msHxgAWwfH7/DtfGk1dtNChovRJvtvC/AIlP8t2gYqjv6Z2h+xLZZ19hJ+P61va94uiU9kYM05gPpZRlolVfL0SHVGzD4RjBwi/gTHCkCF3XLfKNcBkdEG4KP4mJPa8z0BlEllgeUFLJnfX5EezQkpQ+e5n0CxuWRQBY/gkOnNMbLoFIOsZE7djypQpWAY4qKdgn6Nw2Kquxwbg+L5oFVMvgydmBX8toH5nJLixtYEPH5g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.001915, 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 a selftest for MAP_BELOW_HINT that maps until it runs out of space below the hint address. Signed-off-by: Charlie Jenkins --- tools/testing/selftests/mm/Makefile | 1 + tools/testing/selftests/mm/map_below_hint.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile index cfad627e8d94..4e2de85267b5 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -50,6 +50,7 @@ TEST_GEN_FILES += hugepage-shm TEST_GEN_FILES += hugepage-vmemmap TEST_GEN_FILES += khugepaged TEST_GEN_FILES += madv_populate +TEST_GEN_FILES += map_below_hint TEST_GEN_FILES += map_fixed_noreplace TEST_GEN_FILES += map_hugetlb TEST_GEN_FILES += map_populate diff --git a/tools/testing/selftests/mm/map_below_hint.c b/tools/testing/selftests/mm/map_below_hint.c new file mode 100644 index 000000000000..305274c5af49 --- /dev/null +++ b/tools/testing/selftests/mm/map_below_hint.c @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Test the MAP_BELOW_HINT mmap flag. + */ +#include +#include "../kselftest.h" + +#define ADDR 0x1000000UL +#define LENGTH (ADDR / 100) + +#define MAP_BELOW_HINT 0x8000000 /* Not defined in all libc */ + +/* + * Map memory with MAP_BELOW_HINT until no memory left. Ensure that all returned + * addresses are below the hint. + */ +int main(int argc, char **argv) +{ + void *addr; + + do { + addr = mmap((void *)ADDR, LENGTH, MAP_ANONYMOUS, MAP_BELOW_HINT, -1, 0); + } while (addr == MAP_FAILED && (unsigned long)addr <= ADDR); + + if (addr != MAP_FAILED && (unsigned long)addr > ADDR) + ksft_exit_fail_msg("mmap returned address above hint with MAP_BELOW_HINT\n"); + + ksft_test_result_pass("MAP_BELOW_HINT works\n"); +}