tracing/mm: Use raw_smp_processor_id() instead of smp_processor_id()
PATCH 1/1 tracing/mm: Use raw_smp_processor_id() instead of smp_processor_id()
trace_mm_page_pcpu_drain, trace_kmem_cache_free, trace_mm_page_free can be potentially called from an offlined cpu. Since trace points use RCU and RCU should not be used from offlined cpus, we have checks to filter out such calls.
But these checks use smp_processor_id() and since these trace calls can happen from preemptable sections, this throws a warning when running with CONFIG_DEBUG_PREEMPT set.
Now consider task gets migrated after calling smp_processor_id()
- From an online cpu to another online cpu - No impact
- From an online cpu to an offline cpu - Should never happen
- From an offline cpu to an online cpu - Once a cpu has been offlined it returns to cpu_idle_loop, discovers its offline and calls arch_cpu_idle_dead. All this happens with preemption disabled. So this scenario too should never happen.
Thus running with PREEMPT set has no impact on the condition. So use raw_smp_processor_id() so that the warnings are suppressed.
--- include/trace/events/kmem.h | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-)
include/trace/events/kmem.h +31 -3
@@ -146,7 +146,16 @@ DEFINE_EVENT_CONDITION(kmem_free, kmem_cache_free,TP_ARGS (call_site, ptr), -TP_CONDITION (cpu_online (smp_processor_id ())) +/* +* This trace can be potentially called from an offlined cpu. +* Since trace points use RCU and RCU should not be used from +* offline cpus, filter such calls out. +* While this trace can be called from a preemptable section, +* it has no impact on the condition since tasks can migrate +* only from online cpus to other online cpus. Thus its safe +* to use raw_smp_processor_id. +*/ +TP_CONDITION (cpu_online (raw_smp_processor_id ())) ); TRACE_EVENT_CONDITION(mm_page_free,
@@ -155,7 +164,17 @@ TRACE_EVENT_CONDITION(mm_page_free,TP_ARGS (page, order), -TP_CONDITION (cpu_online (smp_processor_id ())), + +/* +* This trace can be potentially called from an offlined cpu. +* Since trace points use RCU and RCU should not be used from +* offline cpus, filter such calls out. +* While this trace can be called from a preemptable section, +* it has no impact on the condition since tasks can migrate +* only from online cpus to other online cpus. Thus its safe +* to use raw_smp_processor_id. +*/ +TP_CONDITION (cpu_online (raw_smp_processor_id ())),TP_STRUCT__entry ( __field( unsigned long, pfn )
@@ -263,7 +282,16 @@ TRACE_EVENT_CONDITION(mm_page_pcpu_drain,TP_ARGS (page, order, migratetype), -TP_CONDITION (cpu_online (smp_processor_id ())), +/* +* This trace can be potentially called from an offlined cpu. +* Since trace points use RCU and RCU should not be used from +* offline cpus, filter such calls out. +* While this trace can be called from a preemptable section, +* it has no impact on the condition since tasks can migrate +* only from online cpus to other online cpus. Thus its safe +* to use raw_smp_processor_id. +*/ +TP_CONDITION (cpu_online (raw_smp_processor_id ())),TP_STRUCT__entry ( __field( unsigned long, pfn )
Signature · 1 line
1.9.3
Quoted 74 lines · Shreyas B. Prabhu
trace_mm_page_pcpu_drain,trace_kmem_cache_free,trace_mm_page_freecan be potentially called from an offlined cpu. Since trace points use RCU and RCU should not be used from offlined cpus, we have checks to filter out such calls.But these checks use
smp_processor_id()and since these trace calls can happen from preemptable sections, this throws a warning when running withCONFIG_DEBUG_PREEMPTset.Now consider task gets migrated after calling
smp_processor_id()
- From an online cpu to another online cpu - No impact
- From an online cpu to an offline cpu - Should never happen
- From an offline cpu to an online cpu - Once a cpu has been offlined it returns tocpu_idle_loop, discovers its offline and callsarch_cpu_idle_dead. All this happens with preemption disabled. So this scenario too should never happen.Thus running with PREEMPT set has no impact on the condition. So use
raw_smp_processor_id()so that the warnings are suppressed.Signed-off-by Shreyas B. Prabhu <[email protected]>--- include/trace/events/kmem.h | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-)include/trace/events/kmem.h +24
-3@@ -146,7 +146,16 @@ DEFINE_EVENT_CONDITION(kmem_free, kmem_cache_free,TP_ARGS (call_site, ptr), -TP_CONDITION (cpu_online (smp_processor_id ())) +/* +* This trace can be potentially called from an offlined cpu. +* Since trace points use RCU and RCU should not be used from +* offline cpus, filter such calls out. +* While this trace can be called from a preemptable section, +* it has no impact on the condition since tasks can migrate +* only from online cpus to other online cpus. Thus its safe +* to use raw_smp_processor_id. +*/ +TP_CONDITION (cpu_online (raw_smp_processor_id ())) ); TRACE_EVENT_CONDITION(mm_page_free,@@ -155,7 +164,17 @@ TRACE_EVENT_CONDITION(mm_page_free,TP_ARGS (page, order), -TP_CONDITION (cpu_online (smp_processor_id ())), + +/* +* This trace can be potentially called from an offlined cpu. +* Since trace points use RCU and RCU should not be used from +* offline cpus, filter such calls out. +* While this trace can be called from a preemptable section, +* it has no impact on the condition since tasks can migrate +* only from online cpus to other online cpus. Thus its safe +* to use raw_smp_processor_id. +*/ +TP_CONDITION (cpu_online (raw_smp_processor_id ())),TP_STRUCT__entry ( __field( unsigned long, pfn )@@ -263,7 +282,16 @@ TRACE_EVENT_CONDITION(mm_page_pcpu_drain, TP_ARGS(page, order, migratetype), - TP_CONDITION(cpu_online(smp_processor_id())), +/* +* This trace can be potentially called from an offlined cpu. +* Since trace points use RCU and RCU should not be used from
include/trace/events/kmem.h TRACE_EVENT_CONDITION(mm_page_pcpu_drain, · line 297
Quoted 10 lines
include/trace/events/kmem.h +7
-0+* offline cpus, filter such calls out. +* While this trace can be called from a preemptable section, +* it has no impact on the condition since tasks can migrate +* only from online cpus to other online cpus. Thus its safe +* to use raw_smp_processor_id. +*/ +TP_CONDITION (cpu_online (raw_smp_processor_id ())),TP_STRUCT__entry ( __field( unsigned long, pfn )