From nobody Wed Dec 17 15:33:06 2025 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 610D817E01B for ; Mon, 24 Mar 2025 06:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742797162; cv=none; b=ccLRC3rx2uw3Hh7rpAcH4w2yzR54k8yLvrxoOpynMC+N+ZuenI5/XncD83eq4uHG4gfQJHyhq957rUj4N8tD65flVjLHbG70ZU8YXWCCfmTgMnH3n98+0xh+OduC4m8ZAQUVHfyvzYB1kHLVOvY4IzAVBX0QRb32SaFPfLgez2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742797162; c=relaxed/simple; bh=EmIz2lLWZAsWPVRdqglI5WF3ic5iH2SgqlIBROEY68o=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=WHLBnDmbcz3ZchZJSySsP+B17aHhaHdxFUIBukT7wcbJ9SWUuf78bm3FAkPOzTipTQBNKYwg6BlHzLvg9sm13aAF54mf/re+qE751HIBk0cC/UHplIsG/0cOanOkdFd8MqsnHQV6oP/rl+fira/8KuRDCdNCpSz0YNHABauAFKU= 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=wdSu9NA2; arc=none smtp.client-ip=91.218.175.177 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="wdSu9NA2" 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=1742797158; 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=TvhJEaWvDoaTAezZAcDpCCpB9iCGHWPgiSVGgqYu6Jw=; b=wdSu9NA2wq9kblJR8pfDVQKz92XQlXP6gCDG2m2E9Tp/aF6Mt81S11Rdsa3vEkaxu/E18b qSQBerdoesC6V1NVZ+A199MCDebZaqphngOYA6/uUtxKyPqy2VHgFbNYVb9ExakOonKMb/ K//b+D2JBF2kziIGsisiO5RjgCyHZto= 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 v2] rust: sync: optimize rust symbol generation for CondVar Date: Mon, 24 Mar 2025 14:18:34 +0800 Message-ID: <20250324061835.1693125-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: Benno Lossin Reviewed-by: Alice Ryhl --- Changes in v2: - Remove '#[inline]' for notify() - Reword commit msg - v1 link: https://lore.kernel.org/rust-for-linux/01c67d96-6477-4851-81ae-0= cbee3b9e893@linux.dev --- rust/kernel/sync/condvar.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rust/kernel/sync/condvar.rs b/rust/kernel/sync/condvar.rs index caebf03f553b..c6ec64295c9f 100644 --- a/rust/kernel/sync/condvar.rs +++ b/rust/kernel/sync/condvar.rs @@ -216,6 +216,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) }; @@ -225,6 +226,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); } @@ -233,6 +235,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