Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp134469lqb; Tue, 16 Apr 2024 10:48:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWtWgdxf/Dk5aE8tGJukjr2LkjaN0D8k8uDvdNFeVuwWF8qhb6eMnWzuP04eUb4dAA0t5V9gwZ6HFcQYpHophu+Etjk6+JBMZRpW5mRVg== X-Google-Smtp-Source: AGHT+IGaxZ49wfTU5KlQgzMhC4hheZNbQj9sddkpXQ5Bi+idnzxd8tlXytjREY687QkCNDZ6pR1x X-Received: by 2002:ac8:7112:0:b0:436:8610:3296 with SMTP id z18-20020ac87112000000b0043686103296mr12594229qto.64.1713289700733; Tue, 16 Apr 2024 10:48:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713289700; cv=pass; d=google.com; s=arc-20160816; b=fX+/EAf3BdmoxHPOo88dozKbEI8s5f2pRB7iVuxQ+bFagOYTX2bl0j/ywQdqJRL8vc Vj2OXjTz5nr8CDYh1eiMFLZ7nKEXHiy7CMIAOzwxEAMj9/q13d2UWibWgbJQA6iiyIXY yhUab2CaYl7dJzIm5GMACuaOTnSszgDucTBVM3ZdOutyOqjG3wWP5B85Wokzqga50RUA 8s/LI15PEqbOog3T+nm5QQfxcklCFRLjt1TPJ2mMtjcjyUjn8YAw7WSZziYVStuYi+xb DM5kVz6x1MvLAhggUcfJ45mHpHAAO4gW9CSDjkIXmwVBbjrGIMQVCpf+bj5G3oTjUTqk NB1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=cgxo59IYhnHPL9WU4YKhZaxzeo3fMP1MrECdS5RGdv8=; fh=UawllJjuP1xR8TRSY/1EiuVh2AytU2+8YkEqT5dQONo=; b=vwKHQIPKVvTtDDGAtwDtUB19CIHMJqWnM/Ek18ymbV+oJAoq5a/XwHSa4o+2P/bS9D hq+ftwEULeak/srrHh1B/KXScfkHYc7egMKPCOblbXB/3fjc6bT3DBSVs5ANK3H1JdQ3 ddTH0r5ELnxvrSA7Kuo7RJJYFuebwN8X00WVMV3NwF7+ba0okxtI6/cAw5ZfWdg7tmRR c0aSvoXTYPltNp//HiWTkxuiTX/0WwYdH0uMUKqEhENf9efi61kJJuHnZxdI2NENNk00 Y+67FIJTCb4K3dhYMeJFPsEPAMfnr1CxLMZ+OO9YCfQRjUVkXO+R4uS17ABLPFBEFhLr +5SA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@umich.edu header.s=google-2016-06-03 header.b=eUDKjTlB; arc=pass (i=1 spf=pass spfdomain=umich.edu dkim=pass dkdomain=umich.edu dmarc=pass fromdomain=umich.edu); spf=pass (google.com: domain of linux-kernel+bounces-147330-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147330-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umich.edu Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ha15-20020a05622a2b0f00b004376483d9a4si80613qtb.342.2024.04.16.10.48.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 10:48:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147330-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@umich.edu header.s=google-2016-06-03 header.b=eUDKjTlB; arc=pass (i=1 spf=pass spfdomain=umich.edu dkim=pass dkdomain=umich.edu dmarc=pass fromdomain=umich.edu); spf=pass (google.com: domain of linux-kernel+bounces-147330-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147330-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umich.edu Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 514851C213D4 for ; Tue, 16 Apr 2024 17:48:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEE8F1327ED; Tue, 16 Apr 2024 17:48:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=umich.edu header.i=@umich.edu header.b="eUDKjTlB" Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E217FC1F for ; Tue, 16 Apr 2024 17:48:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713289691; cv=none; b=cClQ2hxpDJ2sx/ED1RuP1Sv7QqE7QajZBpV5HOwSMng+zsAHHbYnToKZ5Nr1+NyUcfMSKXedGlIwx0q74jDtBzLzyrhFijTDqqMmjya73PEw6d4vn5taUmC3Lp3vY9qPYOZVnNP/+ChO8kZNKYgyE1/Xo24e39u8trSxswl4oYg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713289691; c=relaxed/simple; bh=CFLPbaTqHgy35LCkZ8/WIR4fdR8dupvDJeKom1cb3Tc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=t+08vVsPOnt/WUF45H7Z+uzmzQLxfbowlYAIv40q90rP1RGWnhJMw8KkNNxmJK8QtNPL6a1mb+9p+VtZ0k3AEo6aMiPsRQj/aYo3bBgtDukOoAjS1MCMTX1MOWLseezMash+X4DFBiJPQ7ZmX7pX8fUDdj7SXmXnpGKqcPE4LXc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=umich.edu; spf=pass smtp.mailfrom=umich.edu; dkim=pass (2048-bit key) header.d=umich.edu header.i=@umich.edu header.b=eUDKjTlB; arc=none smtp.client-ip=209.85.219.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=umich.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=umich.edu Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-dcc80d6006aso4636369276.0 for ; Tue, 16 Apr 2024 10:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=google-2016-06-03; t=1713289688; x=1713894488; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cgxo59IYhnHPL9WU4YKhZaxzeo3fMP1MrECdS5RGdv8=; b=eUDKjTlBT29qfAlDcoUy2U1r+7cY8RglJ/6AU7pb+GfackqEn8tjBT63fCwXj8r6ph vIHzVswQ1aD1xiHv3jXV5FyJALVltYXvFK8pgG/Ym5HtTIZHS++PW5hZah87Wml7yFqC b+ai5iO//SnTNatl1C9pDoSOlvT+H28FDhW0HH5ET4iHKkgFrg8EtXaQdyCG4Brk0rVw GGlB04Mij1r/0jNX2/DBE3PYmw5kSLimADJz4MjfJkwumGoGhb7HiAHFI+oih90oPeDW h9EkLvDAH3lmGV09U8//u6YmLnZk6eWYVlgDGIge1PQ0xs8gv8whaCKZ5MbPaI6SKCEb Kx9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713289688; x=1713894488; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cgxo59IYhnHPL9WU4YKhZaxzeo3fMP1MrECdS5RGdv8=; b=dDMzyS1AVRLKBTCj4BkBV2DDxcyJbTqZV1a5iKhAJ6AowkZxKn14xmYZBOYEgYzxvL sXHZedbEWjb0Ze/JHI6dENMEBJujuR/ir7Z6ziqRG6AooZbOci6EV+64Kfq2zSUwII9d aneMwCBOL85j+qiS8IIVlifBFEqwbZovvNzjk3zAT28uv2SHIOl8ePIGos6qLVsCNxZm AIR7h9sqpFftVgN9Sl7iS/MoUbWXcuGQlfU3Yzc17uYDrK6v8Bpeyxd6rDyxVBMzB+R+ IRK+vrkCb9yi79W+76SO+uSTcu8H0hwlsXRdTRPS5/0znQfIdNMxE3hSugtzkZjwrTAx LdSg== X-Forwarded-Encrypted: i=1; AJvYcCWIIcd+/eRwf4gd9MiIvwVkpWgMhQJgg2apodSDZc+1pqzMmrXrrwB5JzHvDxnpbbCv+lvzp0Xypl3NnQGwTM96/L3oM4B3v1WVVxf5 X-Gm-Message-State: AOJu0YzxwBlOstkOtNMayTgpNOFjuQ1smtV76CEXOdRcsdWPwJ4u17Os CoBhFj465yHB8+q0HKmbu+5G0nlxVnWHtkvnKYaviYW2E1xIgkhAg/UXA1aTU7R36ZmGkLbBsXL mVp5HZaWwZIYGSahbQvgzLOKIoeY5x54bvDuhYg== X-Received: by 2002:a25:2f0f:0:b0:de0:d728:1b21 with SMTP id v15-20020a252f0f000000b00de0d7281b21mr10940224ybv.54.1713289688081; Tue, 16 Apr 2024 10:48:08 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240416095333.1108884-1-aliceryhl@google.com> In-Reply-To: <20240416095333.1108884-1-aliceryhl@google.com> From: Trevor Gross Date: Tue, 16 Apr 2024 13:47:56 -0400 Message-ID: Subject: Re: [PATCH v5 4/4] rust: add abstraction for `struct page` To: Alice Ryhl Cc: a.hindborg@samsung.com, akpm@linux-foundation.org, alex.gaynor@gmail.com, arnd@arndb.de, arve@android.com, benno.lossin@proton.me, bjorn3_gh@protonmail.com, boqun.feng@gmail.com, brauner@kernel.org, cmllamas@google.com, gary@garyguo.net, gregkh@linuxfoundation.org, joel@joelfernandes.org, keescook@chromium.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, maco@android.com, ojeda@kernel.org, rust-for-linux@vger.kernel.org, surenb@google.com, tkjos@android.com, viro@zeniv.linux.org.uk, wedsonaf@gmail.com, willy@infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 16, 2024 at 5:53=E2=80=AFAM Alice Ryhl w= rote: > > >> +/// Flags for the "get free page" function that underlies all memory = allocations. > >> +pub mod flags { > >> + /// gfp flags. > > > > Uppercase acronym, maybe with a description: > > > > GFP (Get Free Page) flags. > > > >> + #[allow(non_camel_case_types)] > >> + pub type gfp_t =3D bindings::gfp_t; > > > > Why not GfpFlags, do we do this elsewhere? > > > >> + /// `GFP_KERNEL` is typical for kernel-internal allocations. The = caller requires `ZONE_NORMAL` > >> + /// or a lower zone for direct access but can direct reclaim. > >> + pub const GFP_KERNEL: gfp_t =3D bindings::GFP_KERNEL; > >> + /// `GFP_ZERO` returns a zeroed page on success. > >> + pub const __GFP_ZERO: gfp_t =3D bindings::__GFP_ZERO; > >> + /// `GFP_HIGHMEM` indicates that the allocated memory may be loca= ted in high memory. > >> + pub const __GFP_HIGHMEM: gfp_t =3D bindings::__GFP_HIGHMEM; > > > > It feels a bit weird to have dunder constants on the rust side that > > aren't also `#[doc(hidden)]` or just nonpublic. Makes me think they > > are an implementation detail or not really meant to be used - could > > you update the docs if this is the case? > > All of this is going away in the next version because it will be based > on [1], which defines the gfp flags type for us. > > [1]: https://lore.kernel.org/rust-for-linux/20240328013603.206764-1-wedso= naf@gmail.com/ Great, thanks for the link. > > Could you add an example of how to use this correctly? > > This is a private function, you're not supposed to use it directly. > Anyone who is modifying this file directly can look at the existing > users for examples. Ah you're right, missed this bit. Thanks for the followup. Trevor