Re: [PATCH mm-unstable] lib/Kconfig.debug: do not enable DEBUG_PREEMPT by default

From: Hyeonggon Yoo
Date: Fri Jan 27 2023 - 06:46:29 EST


On Wed, Jan 25, 2023 at 10:51:05AM +0100, Michal Hocko wrote:
> On Thu 26-01-23 00:41:15, Hyeonggon Yoo wrote:
> [...]
> > > Do you happen to have any perf data collected during those runs? I
> > > would be interested in the memcg side of things. Maybe we can do
> > > something better there.
> >
> > Yes, below is performance data I've collected.
> >
> > 6.1.8-debug-preempt-dirty
> > =========================
> > Overhead Command Shared Object Symbol
> > + 9.14% hackbench [kernel.vmlinux] [k] check_preemption_disabled
>
> Thanks! Could you just add callers that are showing in the profile for
> this call please?

- 14.56% 9.14% hackbench [kernel.vmlinux] [k] check_preemption_disabled
- 6.37% check_preemption_disabled
+ 3.48% mod_objcg_state
+ 1.10% obj_cgroup_charge
1.02% refill_obj_stock
0.67% memcg_slab_post_alloc_hook
0.58% mod_objcg_state

According to perf, many memcg functions call this function
and that's because __this_cpu_xxxx checks if preemption is disabled.

in include/linux/percpu-defs.h:

/*
* Operations for contexts that are safe from preemption/interrupts. These
* operations verify that preemption is disabled.
*/
#define __this_cpu_read(pcp) \
({ \
__this_cpu_preempt_check("read"); \
raw_cpu_read(pcp); \
})

#define __this_cpu_write(pcp, val) \
({ \
__this_cpu_preempt_check("write"); \
raw_cpu_write(pcp, val); \
})

#define __this_cpu_add(pcp, val) \
({ \
__this_cpu_preempt_check("add"); \
raw_cpu_add(pcp, val); \
})

in lib/smp_processor_id.c:

noinstr void __this_cpu_preempt_check(const char *op)
{
check_preemption_disabled("__this_cpu_", op);
}
EXPORT_SYMBOL(__this_cpu_preempt_check);


> --
> Michal Hocko
> SUSE Labs