From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (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 7D9E215442A for ; Wed, 25 Jun 2025 05:15:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750828530; cv=none; b=nm2valWUqPAK5yEfEOhUF57NIGjJNA6mLnfdgYZ9PEto9HlLyaFLW1LqDcliOSIn9FOQfHX1MR9dojtnfc7zbZSq+Q7D+uOd4vh/yAPvmwNI2A/flUVAzug3474pawlL+VE7rh7vaqyulkYVuYjUKvYEEPxO9JRG2NNWGktTG+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750828530; c=relaxed/simple; bh=smxDLvsJze7SanW5jkLByGCvEyisY67nQWf9OhoWJVg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dXswy7t/ahZaK9Hsy09oiG54m9n9PFYXhMLwdy0cnXAl5NZVwGTRInuhDp+wWcRhRXx5lpDLT8XqsyysR5as94Bt9X/KEtdsLyO/mMmloR0g4XWmrwgYHbCCT8C0bqz9kzd4VK1WDjTrdB9rOG00YFFxOZTXbMzaBqz1s2lceoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bj4jcczq; arc=none smtp.client-ip=209.85.222.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bj4jcczq" Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-7d3dd14a7edso978735885a.2 for ; Tue, 24 Jun 2025 22:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750828527; x=1751433327; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:feedback-id:from:to:cc:subject :date:message-id:reply-to; bh=+kICsOE0yg2BTiSdXOCgN6mz13mvo6la/kJ0XkefREQ=; b=bj4jcczqhMbFSeeuWJfNH8tCWF2Hu2qsx4IZBsUdOIk00/ngw8UO1f5MTcuI2QOqAY O8o79fmogP+C58aKBR5gEDV8ON3JyEjm8suIji95ztWr98OGAT4FZq6SnnfgV2OrZ3j9 O5ho9NOEQ7HjRaaYukF6GrolXEZkzYF3g4Zx4+C3ljNA/x0d+dD7z888K+ZObCLJ21QN /xvM+isKhp/MM6ZUM1lc7cm0mU2DeAu1FLbdTIQPcXqn4kVM46MS9VBoP69GFD9vbFq/ 9BEboezAnKht+y61rE4pzwMjjG+xoRURQQ/a65glV5bdkB3WzwDr/tsLFKyTKhHwLkoU o0PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750828527; x=1751433327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:feedback-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+kICsOE0yg2BTiSdXOCgN6mz13mvo6la/kJ0XkefREQ=; b=HpmLEn2N9s6PaKuKpCNg36QUisJn4QlEqId4f9Aa5ZHbJYRSW5vvOSC7Y6oOhOGLqa ZQuOM7QfcurKmOt+4kudNKqCpeSVotvzFivPMDaI7Ypgt+zXJ4J4+3aNjC/0gSU28GNQ 5b6+FT9jyk/BSRfyH9h44E7hScAmHQwEWRAbFX7GspLCpGcR8fa0WjMqc9UvnyiSafbo YuB2WMOlknT0IVpC2gP5oX7Bv1QZzR9NkBixeaOeZEIIBKDZ+c9kXDa2wkfeetZlRbag End1P5ozA0BzjKXvOJtOWPB+A/CGB9FbNN8arOXrVbaA+k5QxbrpFSKJHaOCrxcRctrm BQBA== X-Forwarded-Encrypted: i=1; AJvYcCWAkkQ4DyRJbDJVQkh239sDSM8Y4fU8ZaAzFk8+jLrgylr7b9fqQjn6uRrdxVDb8ytPa7CN@lists.linux.dev X-Gm-Message-State: AOJu0YygA4F+SjThjO3eUPOzy5wkg3uq4aitjwk9t3jVTRThxp21yYWO J8FQ6keVMW7aFwzTYOEwfsiZbHGq6fIdHgDLlzyqoF9hCfOnmuc1cRZj X-Gm-Gg: ASbGncszf2cc23+GdKBoLjKbrOheSl7Z4OMgL4DXstJLd/sc2RrJEsm/zZnYEedVVg6 H14bUgykt+mhqkou/N521+UoRMICgf2JUdgIGbIaHLI2sk5R0I1heKQ3nCZJFERwqfDjmkpqBAP hd0DCoiKw4ObQid/EGwmAWdLIUN+az/AMlC0MRHTvzdsvkWQjAdzwopaLKSzAvyFPX/YX1FtbAy pQUo+Rnu0XbN4NhhwBYYFxMKb4DF0I3X21ULSJobzJ48IQtP7uow8OHyLhiNiMTzGrZsNBxuHZt 9Em5CdPbYQVOSyqgtada2zjfVGtarf7U1ew4hJUr85fR0Pms4tHrczQXLL7NlTrv4fm9XIvhF2c 6AgKWMvOM8n2ZcokdaLUw963ohGH0X03lUWtzcPXj73Kt8LC3TEn3 X-Google-Smtp-Source: AGHT+IF/eyqrfKOfuzaqpV3gyLsb6OnjZf7waUNYedNniJyI+yfxubomdyfc4MxIxfE5P6r1MYBDwA== X-Received: by 2002:a05:620a:40c2:b0:7d3:f193:6328 with SMTP id af79cd13be357-7d429797054mr285299885a.54.1750828527153; Tue, 24 Jun 2025 22:15:27 -0700 (PDT) Received: from fauth-a2-smtp.messagingengine.com (fauth-a2-smtp.messagingengine.com. [103.168.172.201]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7d3f999c07bsm581667885a.4.2025.06.24.22.15.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jun 2025 22:15:26 -0700 (PDT) Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfauth.phl.internal (Postfix) with ESMTP id A3EC1F40066; Wed, 25 Jun 2025 01:15:25 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Wed, 25 Jun 2025 01:15:25 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddvgddvudeltdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhnucfh vghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrthhtvg hrnhepteejueeugeefiefhiefhtdeukeegvdekvdeufedvudehueegheelhfdvudeugeff necuffhomhgrihhnpehgihhthhhusgdrtghomhdpkhgvrhhnvghlrdhorhhgpdgtrghsth drrghsnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep sghoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedtie egqddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfhhi gihmvgdrnhgrmhgvpdhnsggprhgtphhtthhopeefjedpmhhouggvpehsmhhtphhouhhtpd hrtghpthhtohepmhhinhhgoheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgvthgv rhiisehinhhfrhgruggvrggurdhorhhgpdhrtghpthhtohepmhhinhhgohesrhgvughhrg htrdgtohhmpdhrtghpthhtohepjhhurhhirdhlvghllhhisehrvgguhhgrthdrtghomhdp rhgtphhtthhopehvihhntggvnhhtrdhguhhithhtohhtsehlihhnrghrohdrohhrghdprh gtphhtthhopeguihgvthhmrghrrdgvghhgvghmrghnnhesrghrmhdrtghomhdprhgtphht thhopehrohhsthgvughtsehgohhoughmihhsrdhorhhgpdhrtghpthhtohepsghsvghgrg hllhesghhoohhglhgvrdgtohhmpdhrtghpthhtohepmhhgohhrmhgrnhesshhushgvrdgu vg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 25 Jun 2025 01:15:25 -0400 (EDT) From: Boqun Feng To: Ingo Molnar , Peter Zijlstra Cc: Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , FUJITA Tomonori , Tamir Duberstein , Kunwu Chan , Mitchell Levy , Martin Rodriguez Reboredo , Borys Tyran , Christian Brauner , Panagiotis Foliadis , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, llvm@lists.linux.dev, Christian Schrefl , Charalampos Mitrodimas Subject: [PATCH v2 3/5] rust: task: Mark Task methods inline Date: Tue, 24 Jun 2025 22:15:16 -0700 Message-Id: <20250625051518.15255-4-boqun.feng@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250625051518.15255-1-boqun.feng@gmail.com> References: <20250625051518.15255-1-boqun.feng@gmail.com> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Panagiotis Foliadis When building the kernel using the llvm-18.1.3-rust-1.85.0-x86_64 toolchain provided by kernel.org, the following symbols are generated: $ nm vmlinux | grep ' _R'.*Task | rustfilt ... T ::get_pid_ns ... T ::tgid_nr_ns ... T ::current_pid_ns ... T ::signal_pending ... T ::uid ... T ::euid ... T ::current ... T ::wake_up ... T ::dec_ref ... T ::inc_ref These Rust symbols are trivial wrappers around the C functions. It doesn't make sense to go through a trivial wrapper for these functions, so mark them inline. [boqun: Capitalize the title, reword a bit to avoid listing all the C functions as the code already shows them and remove the addresses of the symbols in the commit log as they are different from build to build.] Link: https://github.com/Rust-for-Linux/linux/issues/1145 Reviewed-by: Benno Lossin Reviewed-by: Christian Schrefl Reviewed-by: Charalampos Mitrodimas Reviewed-by: Alice Ryhl Signed-off-by: Panagiotis Foliadis Signed-off-by: Boqun Feng Link: https://lore.kernel.org/r/20250315-inline-c-wrappers-v3-1-048e43fcef7d@posteo.net --- rust/kernel/task.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs index 927413d85484..834368313088 100644 --- a/rust/kernel/task.rs +++ b/rust/kernel/task.rs @@ -173,6 +173,7 @@ pub fn current_raw() -> *mut bindings::task_struct { /// Callers must ensure that the returned object is only used to access a [`CurrentTask`] /// within the task context that was active when this function was called. For more details, /// see the invariants section for [`CurrentTask`]. + #[inline] pub unsafe fn current() -> impl Deref { struct TaskRef { task: *const CurrentTask, @@ -222,24 +223,28 @@ pub fn pid(&self) -> Pid { } /// Returns the UID of the given task. + #[inline] pub fn uid(&self) -> Kuid { // SAFETY: It's always safe to call `task_uid` on a valid task. Kuid::from_raw(unsafe { bindings::task_uid(self.as_ptr()) }) } /// Returns the effective UID of the given task. + #[inline] pub fn euid(&self) -> Kuid { // SAFETY: It's always safe to call `task_euid` on a valid task. Kuid::from_raw(unsafe { bindings::task_euid(self.as_ptr()) }) } /// Determines whether the given task has pending signals. + #[inline] pub fn signal_pending(&self) -> bool { // SAFETY: It's always safe to call `signal_pending` on a valid task. unsafe { bindings::signal_pending(self.as_ptr()) != 0 } } /// Returns task's pid namespace with elevated reference count + #[inline] pub fn get_pid_ns(&self) -> Option> { // SAFETY: By the type invariant, we know that `self.0` is valid. let ptr = unsafe { bindings::task_get_pid_ns(self.as_ptr()) }; @@ -255,6 +260,7 @@ pub fn get_pid_ns(&self) -> Option> { /// Returns the given task's pid in the provided pid namespace. #[doc(alias = "task_tgid_nr_ns")] + #[inline] pub fn tgid_nr_ns(&self, pidns: Option<&PidNamespace>) -> Pid { let pidns = match pidns { Some(pidns) => pidns.as_ptr(), @@ -268,6 +274,7 @@ pub fn tgid_nr_ns(&self, pidns: Option<&PidNamespace>) -> Pid { } /// Wakes up the task. + #[inline] pub fn wake_up(&self) { // SAFETY: It's always safe to call `wake_up_process` on a valid task, even if the task // running. @@ -341,11 +348,13 @@ pub fn active_pid_ns(&self) -> Option<&PidNamespace> { // SAFETY: The type invariants guarantee that `Task` is always refcounted. unsafe impl crate::types::AlwaysRefCounted for Task { + #[inline] fn inc_ref(&self) { // SAFETY: The existence of a shared reference means that the refcount is nonzero. unsafe { bindings::get_task_struct(self.as_ptr()) }; } + #[inline] unsafe fn dec_ref(obj: ptr::NonNull) { // SAFETY: The safety requirements guarantee that the refcount is nonzero. unsafe { bindings::put_task_struct(obj.cast().as_ptr()) } -- 2.39.5 (Apple Git-154)