[PATCH 3/3] sched/preempt: Check preempt counts in notrace helpers

Karl Mehltretter kmehltretter at gmail.com
Wed Nov 25 11:23:30 PST 2026


On Wed, Nov 25, 2026 at 01:26:28PM +0100, Hongyan Xia wrote:
> > CONFIG_DEBUG_PREEMPT enabled. They therefore skip the bounds checks
> > which ordinary preemption operations provide.
> 
> Nit: Somehow my brain cannot parse 'bounds checks' before reading the 
> whole patch. Hopefully it's just me.

I'll reword that to 'underflow and near-overflow checks'.

> >   #define preempt_check_resched() do { } while (0)
> 
> No need for this hunk as you are in !CONFIG_PREEMPTION without any 
> checks anyway, but for symmetry I guess it doesn't hurt.
> 
> But if you decide to keep this change, then we can always use your new 
> macros and remove __preempt_count_{inc/dec}(). They no longer have any 
> users anyway?

Agreed, I'll remove those two macros.

> > +CFLAGS_core.o += -DDISABLE_BRANCH_PROFILING
> > +endif
> >   CFLAGS_build_policy.o += -DDISABLE_BRANCH_PROFILING
> >   CFLAGS_build_utility.o += -DDISABLE_BRANCH_PROFILING
> >   endif
> 
> This exclusion looks massive for a whole core.c file. When someone 
> profiles branches, does he or she really care about branch statistics in 
> DEBUG_LOCKS_WARN_ON()? Can we just switch to unlikely_notrace() in that 
> macro globally?

unlikely_notrace() does not solve the PROFILE_ALL_BRANCHES case, which
instruments if statements directly, including those in the notrace
helpers.

I will follow Steven's suggestion and make the Branch Profiling choice
depend on !DEBUG_PREEMPT instead.

Thanks,
Karl



More information about the linux-arm-kernel mailing list