aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-07 04:30:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-07 04:30:50 -0400
commit7f60ba388f5b9dd8b0da463b394412dace3ab814 (patch)
treeb97b4fb5c8ad07a435e5b1b559988364764d5e8d
parente665faa424a4a782aa986274920c1fc5b76f5560 (diff)
parent80c9d03c22f13a17df67b4b99a83ed5e9acf6093 (diff)
Merge tag 'for-v3.7' of git://git.infradead.org/users/cbou/linux-pstore
Pull pstore changes from Anton Vorontsov: 1) We no longer ad-hoc to the function tracer "high level" infrastructure and no longer use its debugfs knobs. The change slightly touches kernel/trace directory, but it got the needed ack from Steven Rostedt: http://lkml.org/lkml/2012/8/21/688 2) Added maintainers entry; 3) A bunch of fixes, nothing special. * tag 'for-v3.7' of git://git.infradead.org/users/cbou/linux-pstore: pstore: Avoid recursive spinlocks in the oops_in_progress case pstore/ftrace: Convert to its own enable/disable debugfs knob pstore/ram: Add missing platform_device_unregister MAINTAINERS: Add pstore maintainers pstore/ram: Mark ramoops_pstore_write_buf() as notrace pstore/ram: Fix printk format warning pstore/ram: Fix possible NULL dereference
-rw-r--r--Documentation/ramoops.txt4
-rw-r--r--MAINTAINERS12
-rw-r--r--fs/pstore/Kconfig1
-rw-r--r--fs/pstore/ftrace.c96
-rw-r--r--fs/pstore/internal.h6
-rw-r--r--fs/pstore/platform.c9
-rw-r--r--fs/pstore/ram.c28
-rw-r--r--include/linux/pstore.h8
-rw-r--r--kernel/trace/trace_functions.c15
9 files changed, 139 insertions, 40 deletions
diff --git a/Documentation/ramoops.txt b/Documentation/ramoops.txt
index 197ad59ab9bf..69b3cac4749d 100644
--- a/Documentation/ramoops.txt
+++ b/Documentation/ramoops.txt
@@ -102,9 +102,7 @@ related hangs. The functions call chain log is stored in a "ftrace-ramoops"
102file. Here is an example of usage: 102file. Here is an example of usage:
103 103
104 # mount -t debugfs debugfs /sys/kernel/debug/ 104 # mount -t debugfs debugfs /sys/kernel/debug/
105 # cd /sys/kernel/debug/tracing 105 # echo 1 > /sys/kernel/debug/pstore/record_ftrace
106 # echo function > current_tracer
107 # echo 1 > options/func_pstore
108 # reboot -f 106 # reboot -f
109 [...] 107 [...]
110 # mount -t pstore pstore /mnt/ 108 # mount -t pstore pstore /mnt/
diff --git a/MAINTAINERS b/MAINTAINERS
index 42c2264a154c..4b58d5415929 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5550,6 +5550,18 @@ L: cbe-oss-dev@lists.ozlabs.org
5550S: Maintained 5550S: Maintained
5551F: drivers/block/ps3vram.c 5551F: drivers/block/ps3vram.c
5552 5552
5553PSTORE FILESYSTEM
5554M: Anton Vorontsov <cbouatmailru@gmail.com>
5555M: Colin Cross <ccross@android.com>
5556M: Kees Cook <keescook@chromium.org>
5557M: Tony Luck <tony.luck@intel.com>
5558S: Maintained
5559T: git git://git.infradead.org/users/cbou/linux-pstore.git
5560F: fs/pstore/
5561F: include/linux/pstore*
5562F: drivers/firmware/efivars.c
5563F: drivers/acpi/apei/erst.c
5564
5553PTP HARDWARE CLOCK SUPPORT 5565PTP HARDWARE CLOCK SUPPORT
5554M: Richard Cochran <richardcochran@gmail.com> 5566M: Richard Cochran <richardcochran@gmail.com>
5555S: Maintained 5567S: Maintained
diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig
index d39bb5cce883..ca71db69da07 100644
--- a/fs/pstore/Kconfig
+++ b/fs/pstore/Kconfig
@@ -23,6 +23,7 @@ config PSTORE_FTRACE
23 bool "Persistent function tracer" 23 bool "Persistent function tracer"
24 depends on PSTORE 24 depends on PSTORE
25 depends on FUNCTION_TRACER 25 depends on FUNCTION_TRACER
26 depends on DEBUG_FS
26 help 27 help
27 With this option kernel traces function calls into a persistent 28 With this option kernel traces function calls into a persistent
28 ram buffer that can be decoded and dumped after reboot through 29 ram buffer that can be decoded and dumped after reboot through
diff --git a/fs/pstore/ftrace.c b/fs/pstore/ftrace.c
index a130d484b7d3..2d57e1ac0115 100644
--- a/fs/pstore/ftrace.c
+++ b/fs/pstore/ftrace.c
@@ -17,19 +17,113 @@
17#include <linux/percpu.h> 17#include <linux/percpu.h>
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/atomic.h> 19#include <linux/atomic.h>
20#include <linux/types.h>
21#include <linux/mutex.h>
22#include <linux/ftrace.h>
23#include <linux/fs.h>
24#include <linux/debugfs.h>
25#include <linux/err.h>
26#include <linux/cache.h>
20#include <asm/barrier.h> 27#include <asm/barrier.h>
21#include "internal.h" 28#include "internal.h"
22 29
23void notrace pstore_ftrace_call(unsigned long ip, unsigned long parent_ip) 30static void notrace pstore_ftrace_call(unsigned long ip,
31 unsigned long parent_ip)
24{ 32{
33 unsigned long flags;
25 struct pstore_ftrace_record rec = {}; 34 struct pstore_ftrace_record rec = {};
26 35
27 if (unlikely(oops_in_progress)) 36 if (unlikely(oops_in_progress))
28 return; 37 return;
29 38
39 local_irq_save(flags);
40
30 rec.ip = ip; 41 rec.ip = ip;
31 rec.parent_ip = parent_ip; 42 rec.parent_ip = parent_ip;
32 pstore_ftrace_encode_cpu(&rec, raw_smp_processor_id()); 43 pstore_ftrace_encode_cpu(&rec, raw_smp_processor_id());
33 psinfo->write_buf(PSTORE_TYPE_FTRACE, 0, NULL, 0, (void *)&rec, 44 psinfo->write_buf(PSTORE_TYPE_FTRACE, 0, NULL, 0, (void *)&rec,
34 sizeof(rec), psinfo); 45 sizeof(rec), psinfo);
46
47 local_irq_restore(flags);
48}
49
50static struct ftrace_ops pstore_ftrace_ops __read_mostly = {
51 .func = pstore_ftrace_call,
52};
53
54static DEFINE_MUTEX(pstore_ftrace_lock);
55static bool pstore_ftrace_enabled;
56
57static ssize_t pstore_ftrace_knob_write(struct file *f, const char __user *buf,
58 size_t count, loff_t *ppos)
59{
60 u8 on;
61 ssize_t ret;
62
63 ret = kstrtou8_from_user(buf, count, 2, &on);
64 if (ret)
65 return ret;
66
67 mutex_lock(&pstore_ftrace_lock);
68
69 if (!on ^ pstore_ftrace_enabled)
70 goto out;
71
72 if (on)
73 ret = register_ftrace_function(&pstore_ftrace_ops);
74 else
75 ret = unregister_ftrace_function(&pstore_ftrace_ops);
76 if (ret) {
77 pr_err("%s: unable to %sregister ftrace ops: %zd\n",
78 __func__, on ? "" : "un", ret);
79 goto err;
80 }
81
82 pstore_ftrace_enabled = on;
83out:
84 ret = count;
85err:
86 mutex_unlock(&pstore_ftrace_lock);
87
88 return ret;
89}
90
91static ssize_t pstore_ftrace_knob_read(struct file *f, char __user *buf,
92 size_t count, loff_t *ppos)
93{
94 char val[] = { '0' + pstore_ftrace_enabled, '\n' };
95
96 return simple_read_from_buffer(buf, count, ppos, val, sizeof(val));
97}
98
99static const struct file_operations pstore_knob_fops = {
100 .open = simple_open,
101 .read = pstore_ftrace_knob_read,
102 .write = pstore_ftrace_knob_write,
103};
104
105void pstore_register_ftrace(void)
106{
107 struct dentry *dir;
108 struct dentry *file;
109
110 if (!psinfo->write_buf)
111 return;
112
113 dir = debugfs_create_dir("pstore", NULL);
114 if (!dir) {
115 pr_err("%s: unable to create pstore directory\n", __func__);
116 return;
117 }
118
119 file = debugfs_create_file("record_ftrace", 0600, dir, NULL,
120 &pstore_knob_fops);
121 if (!file) {
122 pr_err("%s: unable to create record_ftrace file\n", __func__);
123 goto err_file;
124 }
125
126 return;
127err_file:
128 debugfs_remove(dir);
35} 129}
diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h
index 0d0d3b7d5f12..4847f588b7d5 100644
--- a/fs/pstore/internal.h
+++ b/fs/pstore/internal.h
@@ -39,6 +39,12 @@ pstore_ftrace_decode_cpu(struct pstore_ftrace_record *rec)
39#endif 39#endif
40} 40}
41 41
42#ifdef CONFIG_PSTORE_FTRACE
43extern void pstore_register_ftrace(void);
44#else
45static inline void pstore_register_ftrace(void) {}
46#endif
47
42extern struct pstore_info *psinfo; 48extern struct pstore_info *psinfo;
43 49
44extern void pstore_set_kmsg_bytes(int); 50extern void pstore_set_kmsg_bytes(int);
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 29996e8793a7..a40da07e93d6 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -164,7 +164,13 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
164 164
165 if (c > psinfo->bufsize) 165 if (c > psinfo->bufsize)
166 c = psinfo->bufsize; 166 c = psinfo->bufsize;
167 spin_lock_irqsave(&psinfo->buf_lock, flags); 167
168 if (oops_in_progress) {
169 if (!spin_trylock_irqsave(&psinfo->buf_lock, flags))
170 break;
171 } else {
172 spin_lock_irqsave(&psinfo->buf_lock, flags);
173 }
168 memcpy(psinfo->buf, s, c); 174 memcpy(psinfo->buf, s, c);
169 psinfo->write(PSTORE_TYPE_CONSOLE, 0, NULL, 0, c, psinfo); 175 psinfo->write(PSTORE_TYPE_CONSOLE, 0, NULL, 0, c, psinfo);
170 spin_unlock_irqrestore(&psinfo->buf_lock, flags); 176 spin_unlock_irqrestore(&psinfo->buf_lock, flags);
@@ -236,6 +242,7 @@ int pstore_register(struct pstore_info *psi)
236 242
237 kmsg_dump_register(&pstore_dumper); 243 kmsg_dump_register(&pstore_dumper);
238 pstore_register_console(); 244 pstore_register_console();
245 pstore_register_ftrace();
239 246
240 if (pstore_update_ms >= 0) { 247 if (pstore_update_ms >= 0) {
241 pstore_timer.expires = jiffies + 248 pstore_timer.expires = jiffies +
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 0b311bc18916..1a4f6da58eab 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -32,6 +32,7 @@
32#include <linux/ioport.h> 32#include <linux/ioport.h>
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/compiler.h>
35#include <linux/pstore_ram.h> 36#include <linux/pstore_ram.h>
36 37
37#define RAMOOPS_KERNMSG_HDR "====" 38#define RAMOOPS_KERNMSG_HDR "===="
@@ -181,12 +182,11 @@ static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz)
181 return len; 182 return len;
182} 183}
183 184
184 185static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
185static int ramoops_pstore_write_buf(enum pstore_type_id type, 186 enum kmsg_dump_reason reason,
186 enum kmsg_dump_reason reason, 187 u64 *id, unsigned int part,
187 u64 *id, unsigned int part, 188 const char *buf, size_t size,
188 const char *buf, size_t size, 189 struct pstore_info *psi)
189 struct pstore_info *psi)
190{ 190{
191 struct ramoops_context *cxt = psi->data; 191 struct ramoops_context *cxt = psi->data;
192 struct persistent_ram_zone *prz = cxt->przs[cxt->dump_write_cnt]; 192 struct persistent_ram_zone *prz = cxt->przs[cxt->dump_write_cnt];
@@ -406,7 +406,7 @@ static int __devinit ramoops_probe(struct platform_device *pdev)
406 goto fail_init_fprz; 406 goto fail_init_fprz;
407 407
408 if (!cxt->przs && !cxt->cprz && !cxt->fprz) { 408 if (!cxt->przs && !cxt->cprz && !cxt->fprz) {
409 pr_err("memory size too small, minimum is %lu\n", 409 pr_err("memory size too small, minimum is %zu\n",
410 cxt->console_size + cxt->record_size + 410 cxt->console_size + cxt->record_size +
411 cxt->ftrace_size); 411 cxt->ftrace_size);
412 goto fail_cnt; 412 goto fail_cnt;
@@ -414,13 +414,14 @@ static int __devinit ramoops_probe(struct platform_device *pdev)
414 414
415 cxt->pstore.data = cxt; 415 cxt->pstore.data = cxt;
416 /* 416 /*
417 * Console can handle any buffer size, so prefer dumps buffer 417 * Console can handle any buffer size, so prefer LOG_LINE_MAX. If we
418 * size since usually it is smaller. 418 * have to handle dumps, we must have at least record_size buffer. And
419 * for ftrace, bufsize is irrelevant (if bufsize is 0, buf will be
420 * ZERO_SIZE_PTR).
419 */ 421 */
420 if (cxt->przs) 422 if (cxt->console_size)
421 cxt->pstore.bufsize = cxt->przs[0]->buffer_size; 423 cxt->pstore.bufsize = 1024; /* LOG_LINE_MAX */
422 else 424 cxt->pstore.bufsize = max(cxt->record_size, cxt->pstore.bufsize);
423 cxt->pstore.bufsize = cxt->cprz->buffer_size;
424 cxt->pstore.buf = kmalloc(cxt->pstore.bufsize, GFP_KERNEL); 425 cxt->pstore.buf = kmalloc(cxt->pstore.bufsize, GFP_KERNEL);
425 spin_lock_init(&cxt->pstore.buf_lock); 426 spin_lock_init(&cxt->pstore.buf_lock);
426 if (!cxt->pstore.buf) { 427 if (!cxt->pstore.buf) {
@@ -537,6 +538,7 @@ postcore_initcall(ramoops_init);
537static void __exit ramoops_exit(void) 538static void __exit ramoops_exit(void)
538{ 539{
539 platform_driver_unregister(&ramoops_driver); 540 platform_driver_unregister(&ramoops_driver);
541 platform_device_unregister(dummy);
540 kfree(dummy_data); 542 kfree(dummy_data);
541} 543}
542module_exit(ramoops_exit); 544module_exit(ramoops_exit);
diff --git a/include/linux/pstore.h b/include/linux/pstore.h
index c892587d9b81..ee3034a40884 100644
--- a/include/linux/pstore.h
+++ b/include/linux/pstore.h
@@ -64,14 +64,6 @@ struct pstore_info {
64 void *data; 64 void *data;
65}; 65};
66 66
67
68#ifdef CONFIG_PSTORE_FTRACE
69extern void pstore_ftrace_call(unsigned long ip, unsigned long parent_ip);
70#else
71static inline void pstore_ftrace_call(unsigned long ip, unsigned long parent_ip)
72{ }
73#endif
74
75#ifdef CONFIG_PSTORE 67#ifdef CONFIG_PSTORE
76extern int pstore_register(struct pstore_info *); 68extern int pstore_register(struct pstore_info *);
77#else 69#else
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index 483162a9f908..507a7a9630bf 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -13,7 +13,6 @@
13#include <linux/debugfs.h> 13#include <linux/debugfs.h>
14#include <linux/uaccess.h> 14#include <linux/uaccess.h>
15#include <linux/ftrace.h> 15#include <linux/ftrace.h>
16#include <linux/pstore.h>
17#include <linux/fs.h> 16#include <linux/fs.h>
18 17
19#include "trace.h" 18#include "trace.h"
@@ -76,10 +75,9 @@ function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip,
76 preempt_enable_notrace(); 75 preempt_enable_notrace();
77} 76}
78 77
79/* Our two options */ 78/* Our option */
80enum { 79enum {
81 TRACE_FUNC_OPT_STACK = 0x1, 80 TRACE_FUNC_OPT_STACK = 0x1,
82 TRACE_FUNC_OPT_PSTORE = 0x2,
83}; 81};
84 82
85static struct tracer_flags func_flags; 83static struct tracer_flags func_flags;
@@ -109,12 +107,6 @@ function_trace_call(unsigned long ip, unsigned long parent_ip,
109 disabled = atomic_inc_return(&data->disabled); 107 disabled = atomic_inc_return(&data->disabled);
110 108
111 if (likely(disabled == 1)) { 109 if (likely(disabled == 1)) {
112 /*
113 * So far tracing doesn't support multiple buffers, so
114 * we make an explicit call for now.
115 */
116 if (unlikely(func_flags.val & TRACE_FUNC_OPT_PSTORE))
117 pstore_ftrace_call(ip, parent_ip);
118 pc = preempt_count(); 110 pc = preempt_count();
119 trace_function(tr, ip, parent_ip, flags, pc); 111 trace_function(tr, ip, parent_ip, flags, pc);
120 } 112 }
@@ -181,9 +173,6 @@ static struct tracer_opt func_opts[] = {
181#ifdef CONFIG_STACKTRACE 173#ifdef CONFIG_STACKTRACE
182 { TRACER_OPT(func_stack_trace, TRACE_FUNC_OPT_STACK) }, 174 { TRACER_OPT(func_stack_trace, TRACE_FUNC_OPT_STACK) },
183#endif 175#endif
184#ifdef CONFIG_PSTORE_FTRACE
185 { TRACER_OPT(func_pstore, TRACE_FUNC_OPT_PSTORE) },
186#endif
187 { } /* Always set a last empty entry */ 176 { } /* Always set a last empty entry */
188}; 177};
189 178
@@ -236,8 +225,6 @@ static int func_set_flag(u32 old_flags, u32 bit, int set)
236 } 225 }
237 226
238 break; 227 break;
239 case TRACE_FUNC_OPT_PSTORE:
240 break;
241 default: 228 default:
242 return -EINVAL; 229 return -EINVAL;
243 } 230 }