diff options
| author | Miguel Ojeda <ojeda@kernel.org> | 2026-08-16 15:32:33 +0200 |
|---|---|---|
| committer | Miguel Ojeda <ojeda@kernel.org> | 2026-08-23 21:27:17 +0200 |
| commit | 5febf432df1cfa5b25d99b54c32103fafbdd0eb9 (patch) | |
| tree | 93a1ed1d337bc53adf1e572c2586d347703b286e /fs/dlm/main.c | |
| download | linux-stable-5febf432df1cfa5b25d99b54c32103fafbdd0eb9.tar.gz linux-stable-5febf432df1cfa5b25d99b54c32103fafbdd0eb9.zip | |
kbuild: rust: keep Rust objects out of Clang LTO with inline helpersgrafted
Under `CONFIG_LTO_CLANG` + `CONFIG_RUST_INLINE_HELPERS`, one may hit
`objtool` errors such as:
vmlinux.o: error: objtool: _R..._3Gsp4boot+0xd6a:
can't find jump dest instruction at .text._R..._3Gsp4boot+0x1dfd
The reason is that in such builds, the Clang invocation that compiles
the combined Rust plus helpers bitcode emits LLVM bitcode (again) --
the final code generation happens in the linker's LTO step, which the
`-mllvm` trap options passed to Clang do not reach.
This, in turn, means that unreachable traps are missing, and the
impossible paths do not merely fallthrough to the next symbol, but past
the end of their own section, since LTO builds place each function in
its own section.
Thus filter `CC_FLAGS_LTO` out of the Clang invocation, so that it always
emits machine code directly, with the traps in place.
Assisted-by: LLM
Cc: Gary Guo <gary@garyguo.net>
Cc: Boqun Feng <boqun@kernel.org>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Matthew Maurer <mmaurer@google.com>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: stable@vger.kernel.org
Fixes: 3a2486cc1da5 ("kbuild: rust: provide an option to inline C helpers into Rust")
Acked-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260816133233.197500-2-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'fs/dlm/main.c')
| -rw-r--r-- | fs/dlm/main.c | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/fs/dlm/main.c b/fs/dlm/main.c new file mode 100644 index 000000000..a44d16da7 --- /dev/null +++ b/fs/dlm/main.c @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0-only +/****************************************************************************** +******************************************************************************* +** +** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. +** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. +** +** +******************************************************************************* +******************************************************************************/ + +#include <linux/module.h> + +#include "dlm_internal.h" +#include "lockspace.h" +#include "lock.h" +#include "user.h" +#include "memory.h" +#include "config.h" +#include "midcomms.h" + +#define CREATE_TRACE_POINTS +#include <trace/events/dlm.h> + +struct workqueue_struct *dlm_wq; + +static int __init init_dlm(void) +{ + int error; + + error = dlm_memory_init(); + if (error) + goto out; + + dlm_midcomms_init(); + + error = dlm_lockspace_init(); + if (error) + goto out_mem; + + error = dlm_config_init(); + if (error) + goto out_lockspace; + + dlm_register_debugfs(); + + error = dlm_user_init(); + if (error) + goto out_debug; + + error = dlm_plock_init(); + if (error) + goto out_user; + + dlm_wq = alloc_workqueue("dlm_wq", WQ_PERCPU, 0); + if (!dlm_wq) { + error = -ENOMEM; + goto out_plock; + } + + printk("DLM installed\n"); + + return 0; + + out_plock: + dlm_plock_exit(); + out_user: + dlm_user_exit(); + out_debug: + dlm_unregister_debugfs(); + dlm_config_exit(); + out_lockspace: + dlm_lockspace_exit(); + out_mem: + dlm_midcomms_exit(); + dlm_memory_exit(); + out: + return error; +} + +static void __exit exit_dlm(void) +{ + /* be sure every pending work e.g. freeing is done */ + destroy_workqueue(dlm_wq); + dlm_plock_exit(); + dlm_user_exit(); + dlm_config_exit(); + dlm_lockspace_exit(); + dlm_midcomms_exit(); + dlm_unregister_debugfs(); + dlm_memory_exit(); +} + +module_init(init_dlm); +module_exit(exit_dlm); + +MODULE_DESCRIPTION("Distributed Lock Manager"); +MODULE_AUTHOR("Red Hat, Inc."); +MODULE_LICENSE("GPL"); + +EXPORT_SYMBOL_GPL(dlm_new_lockspace); +EXPORT_SYMBOL_GPL(dlm_release_lockspace); +EXPORT_SYMBOL_GPL(dlm_lock); +EXPORT_SYMBOL_GPL(dlm_unlock); + |
