|
22 | 22 | #include <linux/cpu.h> |
23 | 23 | #include <linux/highmem.h> |
24 | 24 | #include <linux/mutex.h> |
| 25 | +#include <linux/slab.h> |
| 26 | +#include <linux/vmalloc.h> |
25 | 27 | #include <asm/sections.h> |
26 | 28 | #include <asm/irq_regs.h> |
27 | 29 | #include <asm/ptrace.h> |
@@ -50,11 +52,11 @@ static DEFINE_PER_CPU(int, cpu_profile_flip); |
50 | 52 | static DEFINE_MUTEX(profile_flip_mutex); |
51 | 53 | #endif /* CONFIG_SMP */ |
52 | 54 |
|
53 | | -static int __init profile_setup(char *str) |
| 55 | +int profile_setup(char *str) |
54 | 56 | { |
55 | | - static char __initdata schedstr[] = "schedule"; |
56 | | - static char __initdata sleepstr[] = "sleep"; |
57 | | - static char __initdata kvmstr[] = "kvm"; |
| 57 | + static char schedstr[] = "schedule"; |
| 58 | + static char sleepstr[] = "sleep"; |
| 59 | + static char kvmstr[] = "kvm"; |
58 | 60 | int par; |
59 | 61 |
|
60 | 62 | if (!strncmp(str, sleepstr, strlen(sleepstr))) { |
@@ -100,14 +102,33 @@ static int __init profile_setup(char *str) |
100 | 102 | __setup("profile=", profile_setup); |
101 | 103 |
|
102 | 104 |
|
103 | | -void __init profile_init(void) |
| 105 | +int profile_init(void) |
104 | 106 | { |
| 107 | + int buffer_bytes; |
105 | 108 | if (!prof_on) |
106 | | - return; |
| 109 | + return 0; |
107 | 110 |
|
108 | 111 | /* only text is profiled */ |
109 | 112 | prof_len = (_etext - _stext) >> prof_shift; |
110 | | - prof_buffer = alloc_bootmem(prof_len*sizeof(atomic_t)); |
| 113 | + buffer_bytes = prof_len*sizeof(atomic_t); |
| 114 | + if (!slab_is_available()) { |
| 115 | + prof_buffer = alloc_bootmem(buffer_bytes); |
| 116 | + return 0; |
| 117 | + } |
| 118 | + |
| 119 | + prof_buffer = kzalloc(buffer_bytes, GFP_KERNEL); |
| 120 | + if (prof_buffer) |
| 121 | + return 0; |
| 122 | + |
| 123 | + prof_buffer = alloc_pages_exact(buffer_bytes, GFP_KERNEL|__GFP_ZERO); |
| 124 | + if (prof_buffer) |
| 125 | + return 0; |
| 126 | + |
| 127 | + prof_buffer = vmalloc(buffer_bytes); |
| 128 | + if (prof_buffer) |
| 129 | + return 0; |
| 130 | + |
| 131 | + return -ENOMEM; |
111 | 132 | } |
112 | 133 |
|
113 | 134 | /* Profile event notifications */ |
@@ -527,7 +548,7 @@ static void __init profile_nop(void *unused) |
527 | 548 | { |
528 | 549 | } |
529 | 550 |
|
530 | | -static int __init create_hash_tables(void) |
| 551 | +static int create_hash_tables(void) |
531 | 552 | { |
532 | 553 | int cpu; |
533 | 554 |
|
@@ -575,14 +596,14 @@ static int __init create_hash_tables(void) |
575 | 596 | #define create_hash_tables() ({ 0; }) |
576 | 597 | #endif |
577 | 598 |
|
578 | | -static int __init create_proc_profile(void) |
| 599 | +int create_proc_profile(void) |
579 | 600 | { |
580 | 601 | struct proc_dir_entry *entry; |
581 | 602 |
|
582 | 603 | if (!prof_on) |
583 | 604 | return 0; |
584 | 605 | if (create_hash_tables()) |
585 | | - return -1; |
| 606 | + return -ENOMEM; |
586 | 607 | entry = proc_create("profile", S_IWUSR | S_IRUGO, |
587 | 608 | NULL, &proc_profile_operations); |
588 | 609 | if (!entry) |
|
0 commit comments