From nobody Wed Dec 17 15:36:27 2025 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81F7A1B042F for ; Mon, 17 Mar 2025 08:14:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742199294; cv=none; b=Y7pyK2oDHu6QQxnvbpCPK8vxJJj9034K+Am4exxTFVBjx5TIPJQ+Iuq6X6/ncCL48rccfyl3bo6q8xWFRUefhI4jDOLKeuV+M1WV2K600UCfQvm5ZLe6iXpPf3vcbNfaPw9IPILsfa6wIPT/V+2JpjmgwEPZIos+DdWK8Ah2LBI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742199294; c=relaxed/simple; bh=Ik+juuv3vZG7o9rKpUv3FPBSdYaXCPaTs5wTp0dE0ro=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=a/ZeV2GVqXrZ/yq/wxcNwc0xl8Cbsp32zJVD3cn07VcJe6F5lv5nlaIc+dT6FDRukHZeFbtD1K0yLDnQ8/+gSHN0MYAEt6i3aoJ4F5Mc1d5vpCqZNm5c4BgizPI3pp56n1tJ+C2o8JTY6vzFLoLq0IGPQgntdMbRphNdC7+8/nw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=PdNGLK8I; arc=none smtp.client-ip=91.218.175.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="PdNGLK8I" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1742199289; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=LRqxEhaGGRBnjpe2vKuBwbtSeIwWfJeTVgBc1Z0wJ/4=; b=PdNGLK8ITK14OXWrnSamvqcfkiWYMqi544OKblg8sMlGEo3ZtchjFR/F/EKJ3TZ3RWv7AC Krrd+ft4xu9hbW6/5nNMQStRe3SWE94f1qo8JSlp0Cgsd5nNtC0yo6+22VYcbzroI0vKGs 07/uzWV71v1QcjBWFiYjl3pfYDbA7V4= From: Kunwu Chan To: ojeda@kernel.org, alex.gaynor@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu, dakr@kernel.org, nathan@kernel.org, nick.desaulniers+lkml@gmail.com, morbo@google.com, justinstitt@google.com Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Kunwu Chan , Grace Deng Subject: [PATCH] rust: sync: optimize rust symbol generation for CondVar Date: Mon, 17 Mar 2025 16:13:50 +0800 Message-ID: <20250317081351.2503049-1-kunwu.chan@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Kunwu Chan When build the kernel using the llvm-18.1.3-rust-1.85.0-x86_64 with ARCH=3Darm64, the following symbols are generated: $nm vmlinux | grep ' _R'.*CondVar | rustfilt ... T ::notify_all ... T ::notify_one ... T ::notify_sync ... T ::new::{closure#0}::{closure#0}::pani= c_cold_explicit ... T ::new::{closure#0}::{closure#0}::pani= c_cold_explicit ... T ::new::{closure#0}::{closure#0}::pan= ic_cold_explicit ... T ::drop These notify* symbols are trivial wrappers around the C functions __wake_up and __wake_up_sync. It doesn't make sense to go through a trivial wrapper for these functions, so mark them inline. Link: https://github.com/Rust-for-Linux/linux/issues/1145 Suggested-by: Alice Ryhl Co-developed-by: Grace Deng Signed-off-by: Grace Deng Signed-off-by: Kunwu Chan Reviewed-by: Alice Ryhl Reviewed-by: Benno Lossin --- rust/kernel/sync/condvar.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rust/kernel/sync/condvar.rs b/rust/kernel/sync/condvar.rs index 7df565038d7d..a826896ba3f0 100644 --- a/rust/kernel/sync/condvar.rs +++ b/rust/kernel/sync/condvar.rs @@ -181,6 +181,7 @@ pub fn wait_interruptible_timeout( } =20 /// Calls the kernel function to notify the appropriate number of thre= ads. + #[inline] fn notify(&self, count: c_int) { // SAFETY: `wait_queue_head` points to valid memory. unsafe { @@ -198,6 +199,7 @@ fn notify(&self, count: c_int) { /// This method behaves like `notify_one`, except that it hints to the= scheduler that the /// current thread is about to go to sleep, so it should schedule the = target thread on the same /// CPU. + #[inline] pub fn notify_sync(&self) { // SAFETY: `wait_queue_head` points to valid memory. unsafe { bindings::__wake_up_sync(self.wait_queue_head.get(), TASK= _NORMAL) }; @@ -207,6 +209,7 @@ pub fn notify_sync(&self) { /// /// This is not 'sticky' in the sense that if no thread is waiting, th= e notification is lost /// completely (as opposed to automatically waking up the next waiter). + #[inline] pub fn notify_one(&self) { self.notify(1); } @@ -215,6 +218,7 @@ pub fn notify_one(&self) { /// /// This is not 'sticky' in the sense that if no thread is waiting, th= e notification is lost /// completely (as opposed to automatically waking up the next waiter). + #[inline] pub fn notify_all(&self) { self.notify(0); } --=20 2.43.0