Re: [PATCH v10 08/14] unwind deferred: Use bitmask to determine which callbacks to call
From: Peter Zijlstra
Date: Fri Jun 20 2025 - 04:16:14 EST
On Tue, Jun 10, 2025 at 08:54:29PM -0400, Steven Rostedt wrote:
> void unwind_deferred_cancel(struct unwind_work *work)
> {
> + struct task_struct *g, *t;
> +
> if (!work)
> return;
>
> guard(mutex)(&callback_mutex);
> list_del(&work->list);
> +
> + clear_bit(work->bit, &unwind_mask);
atomic bitop
> +
> + guard(rcu)();
> + /* Clear this bit from all threads */
> + for_each_process_thread(g, t) {
> + clear_bit(work->bit, &t->unwind_info.unwind_mask);
> + }
> }
>
> int unwind_deferred_init(struct unwind_work *work, unwind_callback_t func)
> @@ -256,6 +278,14 @@ int unwind_deferred_init(struct unwind_work *work, unwind_callback_t func)
> memset(work, 0, sizeof(*work));
>
> guard(mutex)(&callback_mutex);
> +
> + /* See if there's a bit in the mask available */
> + if (unwind_mask == ~0UL)
> + return -EBUSY;
> +
> + work->bit = ffz(unwind_mask);
> + unwind_mask |= BIT(work->bit);
regular or
> +
> list_add(&work->list, &callbacks);
> work->func = func;
> return 0;
> @@ -267,6 +297,7 @@ void unwind_task_init(struct task_struct *task)
>
> memset(info, 0, sizeof(*info));
> init_task_work(&info->work, unwind_deferred_task_work);
> + info->unwind_mask = 0;
> }
Which is somewhat inconsistent;
__clear_bit()/__set_bit()
or:
unwind_mask &= ~BIT() / unwind_mask |= BIT()