From patchwork Fri Jun 7 08:23:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alice Ryhl X-Patchwork-Id: 13689469 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 0BB5EC27C53 for ; Fri, 7 Jun 2024 08:23:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 938736B00A5; Fri, 7 Jun 2024 04:23:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C15B6B00A7; Fri, 7 Jun 2024 04:23:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 716016B00A8; Fri, 7 Jun 2024 04:23:48 -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 4DB036B00A5 for ; Fri, 7 Jun 2024 04:23:48 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0F2481417F3 for ; Fri, 7 Jun 2024 08:23:48 +0000 (UTC) X-FDA: 82203404136.06.A904AFA Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf06.hostedemail.com (Postfix) with ESMTP id 2FBA6180006 for ; Fri, 7 Jun 2024 08:23:46 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="ZQL/9UeW"; spf=pass (imf06.hostedemail.com: domain of 3kMNiZgkKCNs7IF9BOVEIDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--aliceryhl.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3kMNiZgkKCNs7IF9BOVEIDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--aliceryhl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717748626; 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:in-reply-to: references:dkim-signature; bh=jFzDLAm2JoetzCIq+IZooWSo9+/OTnrDCeqgi9Uf1Qw=; b=mjZbqs6mcb9fzs5tDg7SRQu35PMu94s+7HMVk/xOMWnpiQ+9ORTeI9MVVlgV9flIXUNEGw I6M6t1t2qtNOnmSA/tK89gLzHym/2eQ7y9dLOugRXbxF2VugpJohTpToP6cirp/5C6NCxY uB4AEGiCNDqW+4B0ML01c5FrQ2qJmHg= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="ZQL/9UeW"; spf=pass (imf06.hostedemail.com: domain of 3kMNiZgkKCNs7IF9BOVEIDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--aliceryhl.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3kMNiZgkKCNs7IF9BOVEIDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--aliceryhl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717748626; a=rsa-sha256; cv=none; b=dM4LSqIItHmymFABx8OHKP2iOFwndx2ccyI3AjaAujIYbRJBWWIRkFXQcNk4sEz+fsyvyZ toa3y119O8vDRMaI97L/iNZyWcNbshNvh9uJdndjT+jSTSdcigyfBuiTdbE03CAls9OmD4 IaH5KOGV1SoPufM4rhWDgzoK7Pz8Ke0= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dfa7464759cso2933733276.0 for ; Fri, 07 Jun 2024 01:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717748625; x=1718353425; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=jFzDLAm2JoetzCIq+IZooWSo9+/OTnrDCeqgi9Uf1Qw=; b=ZQL/9UeWbjsNART+aWLPphZDRCtCdx1taGa91nji40JNlX/rRaL9KyC1YUP3MKUtPW OjK7ochrOe50guKog0li7FyXYTXcwRyZ00u+LGeXlZjpTa+sJ64ZfuF9/UseT/mi8giJ Bl5tIqDyXc0tx5M8aGk6NkZBRJKSUuaxCGfLtCz4wwOAkmLUJ2Im4X2+2efM/Q83erkv GGxucEWQhobxVHG0G0DcRnCG8GzgAVX4JGFTsRJxqqZ9nzYW/pRAZp38PHRb7D92OJFb ewbnXGs1T0NB+aDUnEbh7vjhaRrGsoiiCRhllWthiYcc1ZD1t5KPUbEiFwXlgboirpt8 nFhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717748625; x=1718353425; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=jFzDLAm2JoetzCIq+IZooWSo9+/OTnrDCeqgi9Uf1Qw=; b=v2jad/b7gh6bf2lDeE9zeonmVmpjLRZC+H38L9Wt5cFn1ecTnMikwr5fVW4pUjLrsb 7dmD7fPXgcJuTIr6XNTiT4nFY55h8MfA9229cXoTH2zrrgP4H+8Et5VuwcGxuUf3TXpp ZmJLZK5nWfmVhDZZVXRWjHZd0fFtuRUgt0vuQiUw0A+fOIt1E4G8aOPVAkPeNB8EhEUv Gz/mJyA4BKxbyJrNYDbBxaPwoY5Cznx6SC27FJ2lbLdSQfwQCBM/3LogWYwpIUW85bud Dz3LeLL758pZa+Y4Fj5MB08fSCIBgN7yfie+3iKA65NML7qyrmeyWZ/wAogiJIK/+3pc 3l9g== X-Forwarded-Encrypted: i=1; AJvYcCXD8pQ/PlihDe4eMuYgEsuQ3hUt2880fdXQlpBZQKY5kusQbMmQXo04zL9F7W0MNdGJE6l5XtMh9kdZL8kAtDQg1xI= X-Gm-Message-State: AOJu0YxNkPxCaYxnfgl9db8aJgk4B/zn41M7QcCEtk1PyBzLex2Ik9WU 1SWQsaCV2PbJEULYZza5b2s+eMTDpBPVu7i+oonRaPcMFluTNOHXYsMAVjGmsMMtY26Gof+y854 saxIlzkd68bS7UQ== X-Google-Smtp-Source: AGHT+IEF7CwqKNpySd+6AuoFJi32vnnmAET+ZclCVOtY5J7qFDRYXcocHOA7xl/OSLW2UDLxrIJKMjnMqQ92lHY= X-Received: from aliceryhl2.c.googlers.com ([fda3:e722:ac3:cc00:68:949d:c0a8:572]) (user=aliceryhl job=sendgmr) by 2002:a25:6b08:0:b0:dfa:59bc:8867 with SMTP id 3f1490d57ef6-dfaf64d3340mr115964276.5.1717748624990; Fri, 07 Jun 2024 01:23:44 -0700 (PDT) Date: Fri, 07 Jun 2024 08:23:41 +0000 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAIzDYmYC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDE0Nz3YzM9Izc1FzdlKTElBRDU8ukVENDJaDqgqLUtMwKsEnRsbW1ABY H8rlZAAAA X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=2472; i=aliceryhl@google.com; h=from:subject:message-id; bh=Xgwy+VXx5E3JZbP4Ybw+wTF/Dg2wgJSpewPSloTt8eQ=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBmYsONk+jvByYL2TvCtGEpw2mG1FeLXT5tMEqGf QENb1/iRbmJAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCZmLDjQAKCRAEWL7uWMY5 Rtg5D/97pMiTip/qY8xClBaqwr63gv3MaEt8Te2hgLcwePAMnxTBOxvv7XkJAggvpaPBODWZyX5 k049GAOcgQykCCJI7lcBbnlCJcUgCiCqdvhx4+uSKHtlu2KqqkWvE7aadk9mtSK1LKEqWKzgw64 O+G/8qQ1/MuKgZq7UdXAS+W087EfyC2Vcy0md0dCvMBMPVS04ujRsvQsugtUswaomEh6/Y5dbIR CM/gobk6d+WYYyXfWuxWOA0Lahb/YcCndsQdlAYw4T+GRiOjvrNuewH7OFnQneS89yQGrvSOT90 twfceUV3O65lVsZI0EDrctFXv2U5iHgc1EJd1+ccoM8+MFOYoRuHgvJugMysWCJvuGZZGQq6tL5 9SYegBtv/YY0tDovG9l/XzBxbe0aTXwofemBpHJuH68g6B8INU2eTtl+ZPLMHY9u1Enw04xnnyW W55EPhsp1NDsYV5MVDi+RGq8YYNa1FdUfWeY/bjwLIJdzI9O02LuzZlAFAdEJ4+g14p9wb5ZIqz +Mcm2UIbJ/n6wBEk7teLnGTMlr0FcMFsyZTuZ0w/N/GMuoVn35L6vYWltCgRj+N03venG14qMS6 X2Htqv9BIwEe431MxLTlmrJmzFvO+gELPdL2jzLRgCvh2f3O0iuR63qjN0dRs7bEvjntlDT0l4S NhuJ8H3zSx1Z/6Q== X-Mailer: b4 0.13-dev-26615 Message-ID: <20240607-highmem-v1-1-d18c5ca4072f@google.com> Subject: [PATCH] rust: alloc: add __GFP_HIGHMEM flag From: Alice Ryhl To: Miguel Ojeda , Matthew Wilcox , Al Viro , Andrew Morton , Kees Cook Cc: Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , " =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= " , Benno Lossin , Andreas Hindborg , linux-mm@kvack.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Alice Ryhl X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 2FBA6180006 X-Stat-Signature: fjfkger1i1a1abmpq44qpc1q3tphbfrf X-Rspam-User: X-HE-Tag: 1717748626-627990 X-HE-Meta: U2FsdGVkX19MsUppdZh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o9Yfa9wmSfiwyXehldKcIc268U9Erv+A8Tsofx7XEZfo5gn+VF9lABI1aJG/Jb+aFT5zVyKixZIJ1dXZm6/1pFy0mThg6QZQuU9DZgPCZIz4MztTYFZaJAbHufKm+SyyVMgriYOlSpdhLwC3fQoxpNBWYAqYQw85i42dHt24bQJyRgAHtp/ywoVke6AqkGIDMXVicKOkURlaI/CG0WY+GrB8a63pAgSXdk2WlqmD+6Oi3SnMyPaAoxpeke9zdmSM5BMdaGSzRaUPAWyal1IYs/D1AQXlY3BFiHJscI5GGHMeV8ZuDpzs0IMmW0y8P3Fs5oLFuFJSNCQSJHOLPyUIEJlPRJHR0Z3oxmuuSjt34xiIJfFujo17zUnc0C6NK1P3SGz9c7QCvzvOncfbII450yLC1w/KfrCP77C9o8XSP2OupIRA20Iy1ddzrf/T1EyEp2hGSJ4ZU4VAKlv1+Nzxx+dJHk30yGymn7spxi7dL31Fm8nrNN5LG8sd2AJT/wtliCmlPQYq7DpFdlhpj/Z5zfV5LGQaBgbGy1wS6pj7vKEtFxF8pQWSC3aeyrMkUhH8NnRaeBioKe7gu/Xpc8Z0NBgQWsxT2GPVAMsvgsTKvX9fvW2LaGHCa/7UcDxfpxd7InJE8tlIjIQFxNjJgRSO+sKbRLhItUwe47IsKyEG0jWzidmB6fKPBRBEwpOj3gYIVMDkCegASvvNQutczm2K8= 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 it possible to allocate memory that doesn't need to mapped into the kernel's address space. This flag is useful together with Page::alloc_page [1]. Rust Binder needs this for the memory that holds incoming transactions for each process. Each process will have a few megabytes of memory allocated with this flag, which is mapped into the process using vm_insert_page. When the kernel copies data for an incoming transaction into a process's memory region, it will use kmap_local_page to temporarily map pages that are being modified. There is no need for them to take up address space in the kernel when the kernel is not writing an incoming transaction into the page. Link: https://lore.kernel.org/all/20240528-alice-mm-v7-4-78222c31b8f4@google.com/ [1] Signed-off-by: Alice Ryhl --- rust/bindings/bindings_helper.h | 1 + rust/kernel/alloc.rs | 8 ++++++++ 2 files changed, 9 insertions(+) --- base-commit: 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0 change-id: 20240417-highmem-dbadd159be11 Best regards, diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h index ddb5644d4fd9..52a1412338ef 100644 --- a/rust/bindings/bindings_helper.h +++ b/rust/bindings/bindings_helper.h @@ -25,3 +25,4 @@ const gfp_t RUST_CONST_HELPER_GFP_KERNEL = GFP_KERNEL; const gfp_t RUST_CONST_HELPER_GFP_KERNEL_ACCOUNT = GFP_KERNEL_ACCOUNT; const gfp_t RUST_CONST_HELPER_GFP_NOWAIT = GFP_NOWAIT; const gfp_t RUST_CONST_HELPER___GFP_ZERO = __GFP_ZERO; +const gfp_t RUST_CONST_HELPER___GFP_HIGHMEM = ___GFP_HIGHMEM; diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs index 531b5e471cb1..f2994aea5d8e 100644 --- a/rust/kernel/alloc.rs +++ b/rust/kernel/alloc.rs @@ -52,6 +52,14 @@ pub mod flags { /// This is normally or'd with other flags. pub const __GFP_ZERO: Flags = Flags(bindings::__GFP_ZERO); + /// Allow the allocation to be in high memory. + /// + /// Allocations in high memory may not be mapped into the kernel's address space, so this can't + /// be used with `kmalloc` and other similar methods. + /// + /// This is normally or'd with other flags. + pub const __GFP_HIGHMEM: Flags = Flags(bindings::__GFP_HIGHMEM); + /// Users can not sleep and need the allocation to succeed. /// /// A lower watermark is applied to allow access to "atomic reserves". The current