Re: [PATCH v2] tracing/hwlat: Bind the sampler kthread instead of setting its affinity
From: Frederic Weisbecker
Date: Wed Nov 25 2026 - 11:24:42 EST
Le Wed, Nov 25, 2026 at 10:38:22AM -0500, Steven Rostedt a écrit :
> 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(¤t->pi_lock, flags);
> > > + current->flags &= ~PF_NO_SETAFFINITY;
> > > + raw_spin_unlock_irqrestore(¤t->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? :-/
Right, the affinity should only be changed by the kernel if tracing_cpumask is
written. Otherwise it doesn't seem to make sense to let the user play with the
affinity.
--
Frederic Weisbecker
SUSE Labs