at v6.9 1.5 kB view raw
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) 21int create_proc_profile(void); 22#else 23static inline int create_proc_profile(void) 24{ 25 return 0; 26} 27#endif 28 29#ifdef CONFIG_PROFILING 30 31extern int prof_on __read_mostly; 32 33/* init basic kernel profiler */ 34int profile_init(void); 35int profile_setup(char *str); 36void profile_tick(int type); 37int setup_profiling_timer(unsigned int multiplier); 38 39/* 40 * Add multiple profiler hits to a given address: 41 */ 42void profile_hits(int type, void *ip, unsigned int nr_hits); 43 44/* 45 * Single profiler hit: 46 */ 47static inline void profile_hit(int type, void *ip) 48{ 49 /* 50 * Speedup for the common (no profiling enabled) case: 51 */ 52 if (unlikely(prof_on == type)) 53 profile_hits(type, ip, 1); 54} 55 56struct task_struct; 57struct mm_struct; 58 59#else 60 61#define prof_on 0 62 63static inline int profile_init(void) 64{ 65 return 0; 66} 67 68static inline void profile_tick(int type) 69{ 70 return; 71} 72 73static inline void profile_hits(int type, void *ip, unsigned int nr_hits) 74{ 75 return; 76} 77 78static inline void profile_hit(int type, void *ip) 79{ 80 return; 81} 82 83 84#endif /* CONFIG_PROFILING */ 85 86#endif /* _LINUX_PROFILE_H */