<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/include/linux/pstore.h, branch v3.10.44</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.10.44</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.10.44'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2013-01-11T18:20:50Z</updated>
<entry>
<title>pstore: Avoid deadlock in panic and emergency-restart path</title>
<updated>2013-01-11T18:20:50Z</updated>
<author>
<name>Seiji Aguchi</name>
<email>seiji.aguchi@hds.com</email>
</author>
<published>2013-01-11T18:09:41Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9f244e9cfd70c7c0f82d3c92ce772ab2a92d9f64'/>
<id>urn:sha1:9f244e9cfd70c7c0f82d3c92ce772ab2a92d9f64</id>
<content type='text'>
[Issue]

When pstore is in panic and emergency-restart paths, it may be blocked
in those paths because it simply takes spin_lock.

This is an example scenario which pstore may hang up in a panic path:

 - cpuA grabs psinfo-&gt;buf_lock
 - cpuB panics and calls smp_send_stop
 - smp_send_stop sends IRQ to cpuA
 - after 1 second, cpuB gives up on cpuA and sends an NMI instead
 - cpuA is now in an NMI handler while still holding buf_lock
 - cpuB is deadlocked

This case may happen if a firmware has a bug and
cpuA is stuck talking with it more than one second.

Also, this is a similar scenario in an emergency-restart path:

 - cpuA grabs psinfo-&gt;buf_lock and stucks in a firmware
 - cpuB kicks emergency-restart via either sysrq-b or hangcheck timer.
   And then, cpuB is deadlocked by taking psinfo-&gt;buf_lock again.

[Solution]

This patch avoids the deadlocking issues in both panic and emergency_restart
paths by introducing a function, is_non_blocking_path(), to check if a cpu
can be blocked in current path.

With this patch, pstore is not blocked even if another cpu has
taken a spin_lock, in those paths by changing from spin_lock_irqsave
to spin_trylock_irqsave.

In addition, according to a comment of emergency_restart() in kernel/sys.c,
spin_lock shouldn't be taken in an emergency_restart path to avoid
deadlock. This patch fits the comment below.

&lt;snip&gt;
/**
 *      emergency_restart - reboot the system
 *
 *      Without shutting down any hardware or taking any locks
 *      reboot the system.  This is called when we know we are in
 *      trouble so this is our best effort to reboot.  This is
 *      safe to call in interrupt context.
 */
void emergency_restart(void)
&lt;snip&gt;

Signed-off-by: Seiji Aguchi &lt;seiji.aguchi@hds.com&gt;
Acked-by: Don Zickus &lt;dzickus@redhat.com&gt;
Signed-off-by: Tony Luck &lt;tony.luck@intel.com&gt;
</content>
</entry>
<entry>
<title>efi_pstore: Add a sequence counter to a variable name</title>
<updated>2012-11-27T00:07:44Z</updated>
<author>
<name>Seiji Aguchi</name>
<email>seiji.aguchi@hds.com</email>
</author>
<published>2012-11-27T00:07:44Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=755d4fe46529018ae45bc7c86df682de45ace764'/>
<id>urn:sha1:755d4fe46529018ae45bc7c86df682de45ace764</id>
<content type='text'>
[Issue]

Currently, a variable name, which identifies each entry, consists of type, id and ctime.
But if multiple events happens in a short time, a second/third event may fail to log because
efi_pstore can't distinguish each event with current variable name.

[Solution]

A reasonable way to identify all events precisely is introducing a sequence counter to
the variable name.

The sequence counter has already supported in a pstore layer with "oopscount".
So, this patch adds it to a variable name.
Also, it is passed to read/erase callbacks of platform drivers in accordance with
the modification of the variable name.

  &lt;before applying this patch&gt;
 a variable name of first event: dump-type0-1-12345678
 a variable name of second event: dump-type0-1-12345678

  type:0
  id:1
  ctime:12345678

 If multiple events happen in a short time, efi_pstore can't distinguish them because
 variable names are same among them.

  &lt;after applying this patch&gt;

 it can be distinguishable by adding a sequence counter as follows.

 a variable name of first event: dump-type0-1-1-12345678
 a variable name of Second event: dump-type0-1-2-12345678

  type:0
  id:1
  sequence counter: 1(first event), 2(second event)
  ctime:12345678

In case of a write callback executed in pstore_console_write(), "0" is added to
an argument of the write callback because it just logs all kernel messages and
doesn't need to care about multiple events.

Signed-off-by: Seiji Aguchi &lt;seiji.aguchi@hds.com&gt;
Acked-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Acked-by: Mike Waychison &lt;mikew@google.com&gt;
Signed-off-by: Tony Luck &lt;tony.luck@intel.com&gt;
</content>
</entry>
<entry>
<title>efi_pstore: Add ctime to argument of erase callback</title>
<updated>2012-11-27T00:02:12Z</updated>
<author>
<name>Seiji Aguchi</name>
<email>seiji.aguchi@hds.com</email>
</author>
<published>2012-11-14T20:27:28Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a9efd39cd547223597cfe7c53acec44c099b9264'/>
<id>urn:sha1:a9efd39cd547223597cfe7c53acec44c099b9264</id>
<content type='text'>
[Issue]

Currently, a variable name, which is used to identify each log entry, consists of type,
id and ctime. But an erase callback does not use ctime.

If efi_pstore supported just one log, type and id were enough.
However, in case of supporting multiple logs, it doesn't work because
it can't distinguish each entry without ctime at erasing time.

 &lt;Example&gt;

 As you can see below, efi_pstore can't differentiate first event from second one without ctime.

 a variable name of first event: dump-type0-1-12345678
 a variable name of second event: dump-type0-1-23456789

  type:0
  id:1
  ctime:12345678, 23456789

[Solution]

This patch adds ctime to an argument of an erase callback.

It works across reboots because ctime of pstore means the date that the record was originally stored.
To do this, efi_pstore saves the ctime to variable name at writing time and passes it to pstore
at reading time.

Signed-off-by: Seiji Aguchi &lt;seiji.aguchi@hds.com&gt;
Acked-by: Mike Waychison &lt;mikew@google.com&gt;
Signed-off-by: Tony Luck &lt;tony.luck@intel.com&gt;
</content>
</entry>
<entry>
<title>pstore/ftrace: Convert to its own enable/disable debugfs knob</title>
<updated>2012-09-07T05:16:58Z</updated>
<author>
<name>Anton Vorontsov</name>
<email>anton.vorontsov@linaro.org</email>
</author>
<published>2012-07-17T21:26:15Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=65f8c95e46a1827ae8bbc52a817ea308dd7d65ae'/>
<id>urn:sha1:65f8c95e46a1827ae8bbc52a817ea308dd7d65ae</id>
<content type='text'>
With this patch we no longer reuse function tracer infrastructure, now
we register our own tracer back-end via a debugfs knob.

It's a bit more code, but that is the only downside. On the bright side we
have:

- Ability to make persistent_ram module removable (when needed, we can
  move ftrace_ops struct into a module). Note that persistent_ram is still
  not removable for other reasons, but with this patch it's just one
  thing less to worry about;

- Pstore part is more isolated from the generic function tracer. We tried
  it already by registering our own tracer in available_tracers, but that
  way we're loosing ability to see the traces while we record them to
  pstore. This solution is somewhere in the middle: we only register
  "internal ftracer" back-end, but not the "front-end";

- When there is only pstore tracing enabled, the kernel will only write
  to the pstore buffer, omitting function tracer buffer (which, of course,
  still can be enabled via 'echo function &gt; current_tracer').

Suggested-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Signed-off-by: Anton Vorontsov &lt;anton.vorontsov@linaro.org&gt;
</content>
</entry>
<entry>
<title>pstore: Headers should include all stuff they use</title>
<updated>2012-07-17T19:15:30Z</updated>
<author>
<name>Anton Vorontsov</name>
<email>anton.vorontsov@linaro.org</email>
</author>
<published>2012-07-17T18:37:07Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=67a101f573b0cb1043c8c305112113450cb9fdbf'/>
<id>urn:sha1:67a101f573b0cb1043c8c305112113450cb9fdbf</id>
<content type='text'>
Headers should really include all the needed prototypes, types, defines
etc. to be self-contained. This is a long-standing issue, but apparently
the new tracing code unearthed it (SMP=n is also a prerequisite):

In file included from fs/pstore/internal.h:4:0,
                 from fs/pstore/ftrace.c:21:
include/linux/pstore.h:43:15: error: field ‘read_mutex’ has incomplete type

While at it, I also added the following:

linux/types.h -&gt; size_t, phys_addr_t, uXX and friends
linux/spinlock.h -&gt; spinlock_t
linux/errno.h -&gt; Exxxx
linux/time.h -&gt; struct timespec (struct passed by value)
struct module and rs_control forward declaration (passed via pointers).

Signed-off-by: Anton Vorontsov &lt;anton.vorontsov@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>pstore: Add persistent function tracing</title>
<updated>2012-07-17T17:05:52Z</updated>
<author>
<name>Anton Vorontsov</name>
<email>anton.vorontsov@linaro.org</email>
</author>
<published>2012-07-10T00:10:41Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=060287b8c467bf49a594d8d669e1986c6d8d76b0'/>
<id>urn:sha1:060287b8c467bf49a594d8d669e1986c6d8d76b0</id>
<content type='text'>
With this support kernel can save function call chain log into a
persistent ram buffer that can be decoded and dumped after reboot
through pstore filesystem. It can be used to determine what function
was last called before a reset or panic.

We store the log in a binary format and then decode it at read time.

p.s.
Mostly the code comes from trace_persistent.c driver found in the
Android git tree, written by Colin Cross &lt;ccross@android.com&gt;
(according to sign-off history). I reworked the driver a little bit,
and ported it to pstore.

Signed-off-by: Anton Vorontsov &lt;anton.vorontsov@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>pstore: Introduce write_buf backend callback</title>
<updated>2012-07-17T16:51:38Z</updated>
<author>
<name>Anton Vorontsov</name>
<email>anton.vorontsov@linaro.org</email>
</author>
<published>2012-07-10T00:10:40Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=897dba027445be93f40e5caf550556ca38c48c51'/>
<id>urn:sha1:897dba027445be93f40e5caf550556ca38c48c51</id>
<content type='text'>
For function tracing we need to stop using pstore.buf directly, since
in a tracing callback we can't use spinlocks, and thus we can't safely
use the global buffer.

With write_buf callback, backends no longer need to access pstore.buf
directly, and thus we can pass any buffers (e.g. allocated on stack).

Signed-off-by: Anton Vorontsov &lt;anton.vorontsov@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>pstore: Add console log messages support</title>
<updated>2012-06-13T23:59:27Z</updated>
<author>
<name>Anton Vorontsov</name>
<email>anton.vorontsov@linaro.org</email>
</author>
<published>2012-05-26T13:20:19Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f29e5956aebafe63f81e80f972c44c4a666e5c7f'/>
<id>urn:sha1:f29e5956aebafe63f81e80f972c44c4a666e5c7f</id>
<content type='text'>
Pstore doesn't support logging kernel messages in run-time, it only
dumps dmesg when kernel oopses/panics. This makes pstore useless for
debugging hangs caused by HW issues or improper use of HW (e.g.
weird device inserted -&gt; driver tried to write a reserved bits -&gt;
SoC hanged. In that case we don't get any messages in the pstore.

Therefore, let's add a runtime logging support: PSTORE_TYPE_CONSOLE.

Signed-off-by: Anton Vorontsov &lt;anton.vorontsov@linaro.org&gt;
Acked-by: Kees Cook &lt;keescook@chromium.org&gt;
Acked-by: Colin Cross &lt;ccross@android.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>pstore: pass reason to backend write callback</title>
<updated>2011-11-17T21:13:29Z</updated>
<author>
<name>Kees Cook</name>
<email>keescook@chromium.org</email>
</author>
<published>2011-11-17T21:13:29Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3d6d8d20ec4fd3b256632edb373a9c504724b8a9'/>
<id>urn:sha1:3d6d8d20ec4fd3b256632edb373a9c504724b8a9</id>
<content type='text'>
This allows a backend to filter on the dmesg reason as well as the pstore
reason. When ramoops is switched to pstore, this is needed since it has
no interest in storing non-crash dmesg details.

Drop pstore_write() as it has no users, and handling the "reason" here
has no obviously correct value.

Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: Tony Luck &lt;tony.luck@intel.com&gt;
</content>
</entry>
<entry>
<title>pstore: pass allocated memory region back to caller</title>
<updated>2011-11-17T20:58:07Z</updated>
<author>
<name>Kees Cook</name>
<email>keescook@chromium.org</email>
</author>
<published>2011-11-17T20:58:07Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f6f8285132907757ef84ef8dae0a1244b8cde6ac'/>
<id>urn:sha1:f6f8285132907757ef84ef8dae0a1244b8cde6ac</id>
<content type='text'>
The buf_lock cannot be held while populating the inodes, so make the backend
pass forward an allocated and filled buffer instead. This solves the following
backtrace. The effect is that "buf" is only ever used to notify the backends
that something was written to it, and shouldn't be used in the read path.

To replace the buf_lock during the read path, isolate the open/read/close
loop with a separate mutex to maintain serialized access to the backend.

Note that is is up to the pstore backend to cope if the (*write)() path is
called in the middle of the read path.

[   59.691019] BUG: sleeping function called from invalid context at .../mm/slub.c:847
[   59.691019] in_atomic(): 0, irqs_disabled(): 1, pid: 1819, name: mount
[   59.691019] Pid: 1819, comm: mount Not tainted 3.0.8 #1
[   59.691019] Call Trace:
[   59.691019]  [&lt;810252d5&gt;] __might_sleep+0xc3/0xca
[   59.691019]  [&lt;810a26e6&gt;] kmem_cache_alloc+0x32/0xf3
[   59.691019]  [&lt;810b53ac&gt;] ? __d_lookup_rcu+0x6f/0xf4
[   59.691019]  [&lt;810b68b1&gt;] alloc_inode+0x2a/0x64
[   59.691019]  [&lt;810b6903&gt;] new_inode+0x18/0x43
[   59.691019]  [&lt;81142447&gt;] pstore_get_inode.isra.1+0x11/0x98
[   59.691019]  [&lt;81142623&gt;] pstore_mkfile+0xae/0x26f
[   59.691019]  [&lt;810a2a66&gt;] ? kmem_cache_free+0x19/0xb1
[   59.691019]  [&lt;8116c821&gt;] ? ida_get_new_above+0x140/0x158
[   59.691019]  [&lt;811708ea&gt;] ? __init_rwsem+0x1e/0x2c
[   59.691019]  [&lt;810b67e8&gt;] ? inode_init_always+0x111/0x1b0
[   59.691019]  [&lt;8102127e&gt;] ? should_resched+0xd/0x27
[   59.691019]  [&lt;8137977f&gt;] ? _cond_resched+0xd/0x21
[   59.691019]  [&lt;81142abf&gt;] pstore_get_records+0x52/0xa7
[   59.691019]  [&lt;8114254b&gt;] pstore_fill_super+0x7d/0x91
[   59.691019]  [&lt;810a7ff5&gt;] mount_single+0x46/0x82
[   59.691019]  [&lt;8114231a&gt;] pstore_mount+0x15/0x17
[   59.691019]  [&lt;811424ce&gt;] ? pstore_get_inode.isra.1+0x98/0x98
[   59.691019]  [&lt;810a8199&gt;] mount_fs+0x5a/0x12d
[   59.691019]  [&lt;810b9174&gt;] ? alloc_vfsmnt+0xa4/0x14a
[   59.691019]  [&lt;810b9474&gt;] vfs_kern_mount+0x4f/0x7d
[   59.691019]  [&lt;810b9d7e&gt;] do_kern_mount+0x34/0xb2
[   59.691019]  [&lt;810bb15f&gt;] do_mount+0x5fc/0x64a
[   59.691019]  [&lt;810912fb&gt;] ? strndup_user+0x2e/0x3f
[   59.691019]  [&lt;810bb3cb&gt;] sys_mount+0x66/0x99
[   59.691019]  [&lt;8137b537&gt;] sysenter_do_call+0x12/0x26

Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: Tony Luck &lt;tony.luck@intel.com&gt;
</content>
</entry>
</feed>
