profile.h (1560B)
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _LINUX_PROFILE_H 3#define _LINUX_PROFILE_H 4 5#include <linux/kernel.h> 6#include <linux/init.h> 7#include <linux/cpumask.h> 8#include <linux/cache.h> 9 10#include <asm/errno.h> 11 12#define CPU_PROFILING 1 13#define SCHED_PROFILING 2 14#define SLEEP_PROFILING 3 15#define KVM_PROFILING 4 16 17struct proc_dir_entry; 18struct notifier_block; 19 20#if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS) 21void create_prof_cpu_mask(void); 22int create_proc_profile(void); 23#else 24static inline void create_prof_cpu_mask(void) 25{ 26} 27 28static inline int create_proc_profile(void) 29{ 30 return 0; 31} 32#endif 33 34#ifdef CONFIG_PROFILING 35 36extern int prof_on __read_mostly; 37 38/* init basic kernel profiler */ 39int profile_init(void); 40int profile_setup(char *str); 41void profile_tick(int type); 42int setup_profiling_timer(unsigned int multiplier); 43 44/* 45 * Add multiple profiler hits to a given address: 46 */ 47void profile_hits(int type, void *ip, unsigned int nr_hits); 48 49/* 50 * Single profiler hit: 51 */ 52static inline void profile_hit(int type, void *ip) 53{ 54 /* 55 * Speedup for the common (no profiling enabled) case: 56 */ 57 if (unlikely(prof_on == type)) 58 profile_hits(type, ip, 1); 59} 60 61struct task_struct; 62struct mm_struct; 63 64#else 65 66#define prof_on 0 67 68static inline int profile_init(void) 69{ 70 return 0; 71} 72 73static inline void profile_tick(int type) 74{ 75 return; 76} 77 78static inline void profile_hits(int type, void *ip, unsigned int nr_hits) 79{ 80 return; 81} 82 83static inline void profile_hit(int type, void *ip) 84{ 85 return; 86} 87 88 89#endif /* CONFIG_PROFILING */ 90 91#endif /* _LINUX_PROFILE_H */