Re: [GIT PULL] orphaned patches for 6.11
From: Linus Torvalds
Date: Thu Jul 25 2024 - 12:55:44 EST
On Thu, 25 Jul 2024 at 04:06, Tetsuo Handa
<penguin-kernel@xxxxxxxxxxxxxxxxxxx> wrote:
>
>
> Do you mean
>
> void profile_tick(int type)
> {
> struct pt_regs *regs = get_irq_regs();
>
> - if (!user_mode(regs) && cpumask_available(prof_cpu_mask) &&
> + if (!user_mode(regs) && prof_buffer &&
> cpumask_test_cpu(smp_processor_id(), prof_cpu_mask))
> profile_hit(type, (void *)profile_pc(regs));
> }
>
> because prof_cpu_mask != NULL is guaranteed if prof_buffer != NULL
> because prof_cpu_mask is assigned before prof_buffer is assigned and
> prof_buffer is never reassigned?
Yeah, I think that would be much clearer.
What would make things even clearer is to not have that horrible
complex conditional there in the first place.
The code could do something like
struct pt_regs *regs;
/* Are we supposed to profile at all? */
if (!prof_buffer)
return;
/* Are we profiling this CPU? */
if (cpumask_test_cpu(smp_processor_id(), prof_cpu_mask))
return;
/* This is the old kernel-only legacy profiling */
regs = get_irq_regs();
if (user_mode(regs))
return;
profile_hit(type, (void *)profile_pc(regs));
and each line would be much simpler.
I think this code has grown all these historical barnacles, because
this really is the really old kernel-only profiling that nobody should
even use any more, but is the only thing we have for the early boot
situation.
Linus