Re: [PATCH v4 1/5] rust: workqueue: support stack-allocated work items
From: Gary Guo
Date: Wed Nov 25 2026 - 11:57:37 EST
On Thu Nov 19, 2026 at 3:17 PM GMT, Alice Ryhl wrote:
> On Thu, Nov 19, 2026 at 02:37:17PM +0000, Gary Guo wrote:
>> On Thu Nov 19, 2026 at 2:12 PM GMT, Alice Ryhl wrote:
>> > __rust_helper void rust_helper_init_work_with_key(struct work_struct *work,
>> > work_func_t func,
>> > - bool onstack,
>> > const char *name,
>> > struct lock_class_key *key)
>> > {
>> > - __init_work(work, onstack);
>> > + __init_work(work, object_is_on_stack(work));
>>
>> Is this fully optimized out if !CONFIG_DEBUG_OBJECTS_WORK?
>
> Yes, on normal architectures (checked x86_64 and arm64 with Clang and
> GCC): `get_current()` omits `volatile` and `current->stack` is a plain
> load, so DCE removes all of `object_is_on_stack(work)` once the empty
> `__init_work()` stub is inlined.
>
> The one exception is `ARCH=um` with `CONFIG_SMP=y`, where `get_current()`
> calls an external `uml_curr_cpu()` function without `__attribute_const__`
> (and under `CONFIG_RUST_INLINE_HELPERS`, the dead `mrs`/`movq %gs:...`
> inline asm stays in `helpers.bc` until backend codegen drops it). I can
> wrap it in `if (IS_ENABLED(CONFIG_DEBUG_OBJECTS_WORK))` if I send a v5.
With or without it added (leaning on adding one):
Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
>
> Alice