Re: [PATCH v2] tracing/hwlat: Bind the sampler kthread instead of setting its affinity

From: Steven Rostedt

Date: Wed Nov 25 2026 - 10:38:31 EST


On Wed, 25 Nov 2026 14:37:24 +0100
Frederic Weisbecker <frederic@xxxxxxxxxx> wrote:

> > static int kthread_fn(void *data)
> > {
> > + unsigned long flags;
> > u64 interval;
> >
> > + /*
> > + * kthread_bind_mask() sets PF_NO_SETAFFINITY to keep the initial
> > + * affinity from being overridden by kthread_affine_node(). Clear it
> > + * now to allow userspace affinity changes and cgroup migration, but
> > + * keep per-CPU threads bound to their CPUs.
> > + */
> > + if (hwlat_data.thread_mode != MODE_PER_CPU) {
> > + raw_spin_lock_irqsave(&current->pi_lock, flags);
> > + current->flags &= ~PF_NO_SETAFFINITY;
> > + raw_spin_unlock_irqrestore(&current->pi_lock, flags);
>
> This is not pretty but moreover, is it a good idea to let the user override
> that affinity?

No, but we used to. Perhaps we should make that not possible instead? :-/

-- Steve