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+pWKfGnLEwoxqmDM6GK52EfPuh5IG3an01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: 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