static int __init oprofile_init(void) { int err; /* always init architecture to setup backtrace support */ err = oprofile_arch_init(&oprofile_ops); timer_mode = err || timer; /* fall back to timer mode on errors */ if (timer_mode) { if (!err) oprofile_arch_exit(); err = oprofile_timer_init(&oprofile_ops); if (err) return err; } err = oprofilefs_register(); if (!err) return 0; /* failed */ if (timer_mode) oprofile_timer_exit(); else oprofile_arch_exit(); return err; }
static int oprofile_hwsampler_init(struct oprofile_operations *ops) { if (hwsampler_setup()) return -ENODEV; /* * create hwsampler files only if hwsampler_setup() succeeds. */ oprofile_min_interval = hwsampler_query_min_interval(); if (oprofile_min_interval == 0) return -ENODEV; oprofile_max_interval = hwsampler_query_max_interval(); if (oprofile_max_interval == 0) return -ENODEV; if (oprofile_timer_init(ops)) return -ENODEV; printk(KERN_INFO "oprofile: using hardware sampling\n"); memcpy(&timer_ops, ops, sizeof(timer_ops)); ops->start = oprofile_hwsampler_start; ops->stop = oprofile_hwsampler_stop; ops->create_files = oprofile_create_hwsampling_files; return 0; }
static int oprofile_hwsampler_init(struct oprofile_operations *ops) { /* * Initialize the timer mode infrastructure as well in order * to be able to switch back dynamically. oprofile_timer_init * is not supposed to fail. */ if (oprofile_timer_init(ops)) BUG(); memcpy(&timer_ops, ops, sizeof(timer_ops)); ops->create_files = oprofile_create_hwsampling_files; /* * If the user space tools do not support newer cpu types, * the force_cpu_type module parameter * can be used to always return \"timer\" as cpu type. */ if (force_cpu_type != timer) { struct cpuid id; get_cpu_id (&id); switch (id.machine) { case 0x2097: case 0x2098: ops->cpu_type = "s390/z10"; break; case 0x2817: case 0x2818: ops->cpu_type = "s390/z196"; break; case 0x2827: case 0x2828: ops->cpu_type = "s390/zEC12"; break; default: return -ENODEV; } } if (hwsampler_setup()) return -ENODEV; /* * Query the range for the sampling interval from the * hardware. */ oprofile_min_interval = hwsampler_query_min_interval(); if (oprofile_min_interval == 0) return -ENODEV; oprofile_max_interval = hwsampler_query_max_interval(); if (oprofile_max_interval == 0) return -ENODEV; /* The initial value should be sane */ if (oprofile_hw_interval < oprofile_min_interval) oprofile_hw_interval = oprofile_min_interval; if (oprofile_hw_interval > oprofile_max_interval) oprofile_hw_interval = oprofile_max_interval; printk(KERN_INFO "oprofile: System z hardware sampling " "facility found.\n"); ops->start = oprofile_hwsampler_start; ops->stop = oprofile_hwsampler_stop; return 0; }
static int __init oprofile_init(void) { int err; err = oprofile_arch_init(&oprofile_ops); if (err < 0 || timer) { printk(KERN_INFO "oprofile: using timer interrupt.\n"); err = oprofile_timer_init(&oprofile_ops); if (err) return err; } return oprofilefs_register(); }