Message ID | 20240805152004.5039-25-dakr@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 AAFA8C3DA4A for <linux-mm@archiver.kernel.org>; Mon, 5 Aug 2024 15:22:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D0F28D0007; Mon, 5 Aug 2024 11:22:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 381098D0001; Mon, 5 Aug 2024 11:22:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 222758D0007; Mon, 5 Aug 2024 11:22:30 -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 F3DDA8D0001 for <linux-mm@kvack.org>; Mon, 5 Aug 2024 11:22:29 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A9FE3A03A7 for <linux-mm@kvack.org>; Mon, 5 Aug 2024 15:22:29 +0000 (UTC) X-FDA: 82418558418.08.55E1500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id F31EF4001E for <linux-mm@kvack.org>; Mon, 5 Aug 2024 15:22:27 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qoHEC5Ud; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722871340; a=rsa-sha256; cv=none; b=sy+47vJx1bM02aNXKio9YJTe70Ca22lYDhnq/MZvAi7yCFPg3TzJuJ5AgGbhuI75XnW4qF 4GyeDOBFv2cajZyp+vvcYPFlKWJaL4hPXPO/kP3AvZyB+afbyoTirobDGM1CrUCcp3jVyX tZDnNomrK/EgSOaz+hfm0bo/FYyuI5c= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qoHEC5Ud; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722871340; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Zk4L0WSfPI0qo4KV2m6DiBmtrizln3bZhkW+ifFdOro=; b=7ktMlMuFAalPROs57iIqEzu5zWJu7G5vSBEIyUoxfPbLPs2ypUVv6Ox4h5Hb1FTSOvCo2T fAf2birsLLFuLBGs6IGvQ8mqksYuoUodOS5WIrqi2tIgzq4POCIU4SDzfIwTZSJDN2HWpR DE9F7hwpdN3cVDIhO/Py1acHDZahzyI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3EC0E6092A; Mon, 5 Aug 2024 15:22:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE009C4AF0B; Mon, 5 Aug 2024 15:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722871346; bh=Io2x+G7qKjrcvouOx2NWqdpFm0dKR4v0O7CzrkJKPPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qoHEC5UdKarefAWF6zWNd2LvFyyq/4wBYNZgs6miJ6rFtPBVvOsC30fAeL88n+Gh5 uZQNESyqL8aEbnOBYoCjniO/U2YgYO2ZrKTcn/Iy6ZJrdJhFF3xntpiryK9mUD5Z+l O5+q1s6FdysGzpYj+MpoBf4qKrVa3yUjrwqvN8gepAUkriIFx8hfj58N0LJT1RRfv+ a/Ro1u7l7plrczaR2exu4kVSBXWVNl3R3urzO/Yn52zdjxC5SW2XcgZjzoixC0Ix7x SPxqv5DDTj8XOdWvdLo+wRTff1SDyK9iT5KFg9Bx//qbpsmRKsw9ZLtl+GHe8C0Lsz ym3ShTTtCvHmw== From: Danilo Krummrich <dakr@kernel.org> To: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, aliceryhl@google.com, akpm@linux-foundation.org Cc: daniel.almeida@collabora.com, faith.ekstrand@collabora.com, boris.brezillon@collabora.com, lina@asahilina.net, mcanal@igalia.com, zhiw@nvidia.com, acurrid@nvidia.com, cjia@nvidia.com, jhubbard@nvidia.com, airlied@redhat.com, ajanulgu@redhat.com, lyude@redhat.com, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-mm@kvack.org, Danilo Krummrich <dakr@kernel.org> Subject: [PATCH v4 24/28] rust: alloc: implement `contains` for `Flags` Date: Mon, 5 Aug 2024 17:19:43 +0200 Message-ID: <20240805152004.5039-25-dakr@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240805152004.5039-1-dakr@kernel.org> References: <20240805152004.5039-1-dakr@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Queue-Id: F31EF4001E X-Rspamd-Server: rspam01 X-Stat-Signature: 547rjfg6onf5d3uk3miiu7gay98kozt5 X-HE-Tag: 1722871347-922267 X-HE-Meta: U2FsdGVkX1/dugEGtaU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6BbCOFG/jcYcjJYU4Ht6zQHcSpSvW+EdHvb2WGhADJSIfop6E6lPC2NJTXdDHJGGc2w7mh72qt1aQCw5FBPuwC5UDHbcFKmgZ5RNyOVlZQzpwSx1yQWQ18+L9V3gwwTbLHtfu1RCIv29N8cEUS2TZSL53BqAJ1Evnk9R6g+y/P9bgCZyfaeP6Vub9J1dGX/OB3yfE6ufJ0UyPDv0jfV9Q== 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Generic `Allocator` support for Rust
|
expand
|
diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs index 8a1cecc20d09..615afe69d097 100644 --- a/rust/kernel/alloc.rs +++ b/rust/kernel/alloc.rs @@ -34,7 +34,7 @@ /// They can be combined with the operators `|`, `&`, and `!`. /// /// Values can be used from the [`flags`] module. -#[derive(Clone, Copy)] +#[derive(Clone, Copy, PartialEq)] pub struct Flags(u32); impl Flags { @@ -42,6 +42,11 @@ impl Flags { pub(crate) fn as_raw(self) -> u32 { self.0 } + + /// Check whether `flags` is contained in `self`. + pub fn contains(&self, flags: Flags) -> bool { + (*self & flags) == flags + } } impl core::ops::BitOr for Flags {
Provide a simple helper function to check whether given flags do contain one or multiple other flags. This is used by a subsequent patch implementing the Cmalloc `Allocator` to check for __GFP_ZERO. Signed-off-by: Danilo Krummrich <dakr@kernel.org> --- rust/kernel/alloc.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)