2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Communication to userspace based on kernel/printk.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/poll.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/cpu.h>
|
2005-09-04 02:56:01 +04:00
|
|
|
#include <linux/delay.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/rtas.h>
|
|
|
|
#include <asm/prom.h>
|
|
|
|
#include <asm/nvram.h>
|
|
|
|
#include <asm/atomic.h>
|
2006-03-28 16:15:54 +04:00
|
|
|
#include <asm/machdep.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
static DEFINE_SPINLOCK(rtasd_log_lock);
|
|
|
|
|
2008-05-08 08:27:23 +04:00
|
|
|
static DECLARE_WAIT_QUEUE_HEAD(rtas_log_wait);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
static char *rtas_log_buf;
|
|
|
|
static unsigned long rtas_log_start;
|
|
|
|
static unsigned long rtas_log_size;
|
|
|
|
|
|
|
|
static int surveillance_timeout = -1;
|
|
|
|
static unsigned int rtas_error_log_max;
|
|
|
|
static unsigned int rtas_error_log_buffer_max;
|
|
|
|
|
2007-08-10 01:01:50 +04:00
|
|
|
/* RTAS service tokens */
|
|
|
|
static unsigned int event_scan;
|
|
|
|
static unsigned int rtas_event_scan_rate;
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
static int full_rtas_msgs = 0;
|
|
|
|
|
2007-08-09 00:06:15 +04:00
|
|
|
/* Stop logging to nvram after first fatal error */
|
2007-10-03 05:19:09 +04:00
|
|
|
static int logging_enabled; /* Until we initialize everything,
|
|
|
|
* make sure we don't try logging
|
|
|
|
* anything */
|
2007-08-10 00:56:41 +04:00
|
|
|
static int error_log_cnt;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Since we use 32 bit RTAS, the physical address of this must be below
|
|
|
|
* 4G or else bad things happen. Allocate this in the kernel data and
|
|
|
|
* make it big enough.
|
|
|
|
*/
|
|
|
|
static unsigned char logdata[RTAS_ERROR_LOG_MAX];
|
|
|
|
|
|
|
|
static char *rtas_type[] = {
|
|
|
|
"Unknown", "Retry", "TCE Error", "Internal Device Failure",
|
|
|
|
"Timeout", "Data Parity", "Address Parity", "Cache Parity",
|
|
|
|
"Address Invalid", "ECC Uncorrected", "ECC Corrupted",
|
|
|
|
};
|
|
|
|
|
|
|
|
static char *rtas_event_type(int type)
|
|
|
|
{
|
|
|
|
if ((type > 0) && (type < 11))
|
|
|
|
return rtas_type[type];
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case RTAS_TYPE_EPOW:
|
|
|
|
return "EPOW";
|
|
|
|
case RTAS_TYPE_PLATFORM:
|
|
|
|
return "Platform Error";
|
|
|
|
case RTAS_TYPE_IO:
|
|
|
|
return "I/O Event";
|
|
|
|
case RTAS_TYPE_INFO:
|
|
|
|
return "Platform Information Event";
|
|
|
|
case RTAS_TYPE_DEALLOC:
|
|
|
|
return "Resource Deallocation Event";
|
|
|
|
case RTAS_TYPE_DUMP:
|
|
|
|
return "Dump Notification Event";
|
|
|
|
}
|
|
|
|
|
|
|
|
return rtas_type[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* To see this info, grep RTAS /var/log/messages and each entry
|
|
|
|
* will be collected together with obvious begin/end.
|
|
|
|
* There will be a unique identifier on the begin and end lines.
|
|
|
|
* This will persist across reboots.
|
|
|
|
*
|
|
|
|
* format of error logs returned from RTAS:
|
|
|
|
* bytes (size) : contents
|
|
|
|
* --------------------------------------------------------
|
|
|
|
* 0-7 (8) : rtas_error_log
|
|
|
|
* 8-47 (40) : extended info
|
|
|
|
* 48-51 (4) : vendor id
|
|
|
|
* 52-1023 (vendor specific) : location code and debug data
|
|
|
|
*/
|
|
|
|
static void printk_log_rtas(char *buf, int len)
|
|
|
|
{
|
|
|
|
|
|
|
|
int i,j,n = 0;
|
|
|
|
int perline = 16;
|
|
|
|
char buffer[64];
|
|
|
|
char * str = "RTAS event";
|
|
|
|
|
|
|
|
if (full_rtas_msgs) {
|
|
|
|
printk(RTAS_DEBUG "%d -------- %s begin --------\n",
|
|
|
|
error_log_cnt, str);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print perline bytes on each line, each line will start
|
|
|
|
* with RTAS and a changing number, so syslogd will
|
|
|
|
* print lines that are otherwise the same. Separate every
|
|
|
|
* 4 bytes with a space.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
j = i % perline;
|
|
|
|
if (j == 0) {
|
|
|
|
memset(buffer, 0, sizeof(buffer));
|
|
|
|
n = sprintf(buffer, "RTAS %d:", i/perline);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((i % 4) == 0)
|
|
|
|
n += sprintf(buffer+n, " ");
|
|
|
|
|
|
|
|
n += sprintf(buffer+n, "%02x", (unsigned char)buf[i]);
|
|
|
|
|
|
|
|
if (j == (perline-1))
|
|
|
|
printk(KERN_DEBUG "%s\n", buffer);
|
|
|
|
}
|
|
|
|
if ((i % perline) != 0)
|
|
|
|
printk(KERN_DEBUG "%s\n", buffer);
|
|
|
|
|
|
|
|
printk(RTAS_DEBUG "%d -------- %s end ----------\n",
|
|
|
|
error_log_cnt, str);
|
|
|
|
} else {
|
|
|
|
struct rtas_error_log *errlog = (struct rtas_error_log *)buf;
|
|
|
|
|
|
|
|
printk(RTAS_DEBUG "event: %d, Type: %s, Severity: %d\n",
|
|
|
|
error_log_cnt, rtas_event_type(errlog->type),
|
|
|
|
errlog->severity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int log_rtas_len(char * buf)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
struct rtas_error_log *err;
|
|
|
|
|
|
|
|
/* rtas fixed header */
|
|
|
|
len = 8;
|
|
|
|
err = (struct rtas_error_log *)buf;
|
|
|
|
if (err->extended_log_length) {
|
|
|
|
|
|
|
|
/* extended header */
|
|
|
|
len += err->extended_log_length;
|
|
|
|
}
|
|
|
|
|
2007-08-09 00:03:37 +04:00
|
|
|
if (rtas_error_log_max == 0)
|
|
|
|
rtas_error_log_max = rtas_get_error_log_max();
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (len > rtas_error_log_max)
|
|
|
|
len = rtas_error_log_max;
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First write to nvram, if fatal error, that is the only
|
|
|
|
* place we log the info. The error will be picked up
|
|
|
|
* on the next reboot by rtasd. If not fatal, run the
|
|
|
|
* method for the type of error. Currently, only RTAS
|
|
|
|
* errors have methods implemented, but in the future
|
|
|
|
* there might be a need to store data in nvram before a
|
|
|
|
* call to panic().
|
|
|
|
*
|
|
|
|
* XXX We write to nvram periodically, to indicate error has
|
|
|
|
* been written and sync'd, but there is a possibility
|
|
|
|
* that if we don't shutdown correctly, a duplicate error
|
|
|
|
* record will be created on next reboot.
|
|
|
|
*/
|
|
|
|
void pSeries_log_error(char *buf, unsigned int err_type, int fatal)
|
|
|
|
{
|
|
|
|
unsigned long offset;
|
|
|
|
unsigned long s;
|
|
|
|
int len = 0;
|
|
|
|
|
2008-04-24 09:13:19 +04:00
|
|
|
pr_debug("rtasd: logging event\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
if (buf == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&rtasd_log_lock, s);
|
|
|
|
|
|
|
|
/* get length and increase count */
|
|
|
|
switch (err_type & ERR_TYPE_MASK) {
|
|
|
|
case ERR_TYPE_RTAS_LOG:
|
|
|
|
len = log_rtas_len(buf);
|
|
|
|
if (!(err_type & ERR_FLAG_BOOT))
|
|
|
|
error_log_cnt++;
|
|
|
|
break;
|
|
|
|
case ERR_TYPE_KERNEL_PANIC:
|
|
|
|
default:
|
"Tree RCU": scalable classic RCU implementation
This patch fixes a long-standing performance bug in classic RCU that
results in massive internal-to-RCU lock contention on systems with
more than a few hundred CPUs. Although this patch creates a separate
flavor of RCU for ease of review and patch maintenance, it is intended
to replace classic RCU.
This patch still handles stress better than does mainline, so I am still
calling it ready for inclusion. This patch is against the -tip tree.
Nevertheless, experience on an actual 1000+ CPU machine would still be
most welcome.
Most of the changes noted below were found while creating an rcutiny
(which should permit ejecting the current rcuclassic) and while doing
detailed line-by-line documentation.
Updates from v9 (http://lkml.org/lkml/2008/12/2/334):
o Fixes from remainder of line-by-line code walkthrough,
including comment spelling, initialization, undesirable
narrowing due to type conversion, removing redundant memory
barriers, removing redundant local-variable initialization,
and removing redundant local variables.
I do not believe that any of these fixes address the CPU-hotplug
issues that Andi Kleen was seeing, but please do give it a whirl
in case the machine is smarter than I am.
A writeup from the walkthrough may be found at the following
URL, in case you are suffering from terminal insomnia or
masochism:
http://www.kernel.org/pub/linux/kernel/people/paulmck/tmp/rcutree-walkthrough.2008.12.16a.pdf
o Made rcutree tracing use seq_file, as suggested some time
ago by Lai Jiangshan.
o Added a .csv variant of the rcudata debugfs trace file, to allow
people having thousands of CPUs to drop the data into
a spreadsheet. Tested with oocalc and gnumeric. Updated
documentation to suit.
Updates from v8 (http://lkml.org/lkml/2008/11/15/139):
o Fix a theoretical race between grace-period initialization and
force_quiescent_state() that could occur if more than three
jiffies were required to carry out the grace-period
initialization. Which it might, if you had enough CPUs.
o Apply Ingo's printk-standardization patch.
o Substitute local variables for repeated accesses to global
variables.
o Fix comment misspellings and redundant (but harmless) increments
of ->n_rcu_pending (this latter after having explicitly added it).
o Apply checkpatch fixes.
Updates from v7 (http://lkml.org/lkml/2008/10/10/291):
o Fixed a number of problems noted by Gautham Shenoy, including
the cpu-stall-detection bug that he was having difficulty
convincing me was real. ;-)
o Changed cpu-stall detection to wait for ten seconds rather than
three in order to reduce false positive, as suggested by Ingo
Molnar.
o Produced a design document (http://lwn.net/Articles/305782/).
The act of writing this document uncovered a number of both
theoretical and "here and now" bugs as noted below.
o Fix dynticks_nesting accounting confusion, simplify WARN_ON()
condition, fix kerneldoc comments, and add memory barriers
in dynticks interface functions.
o Add more data to tracing.
o Remove unused "rcu_barrier" field from rcu_data structure.
o Count calls to rcu_pending() from scheduling-clock interrupt
to use as a surrogate timebase should jiffies stop counting.
o Fix a theoretical race between force_quiescent_state() and
grace-period initialization. Yes, initialization does have to
go on for some jiffies for this race to occur, but given enough
CPUs...
Updates from v6 (http://lkml.org/lkml/2008/9/23/448):
o Fix a number of checkpatch.pl complaints.
o Apply review comments from Ingo Molnar and Lai Jiangshan
on the stall-detection code.
o Fix several bugs in !CONFIG_SMP builds.
o Fix a misspelled config-parameter name so that RCU now announces
at boot time if stall detection is configured.
o Run tests on numerous combinations of configurations parameters,
which after the fixes above, now build and run correctly.
Updates from v5 (http://lkml.org/lkml/2008/9/15/92, bad subject line):
o Fix a compiler error in the !CONFIG_FANOUT_EXACT case (blew a
changeset some time ago, and finally got around to retesting
this option).
o Fix some tracing bugs in rcupreempt that caused incorrect
totals to be printed.
o I now test with a more brutal random-selection online/offline
script (attached). Probably more brutal than it needs to be
on the people reading it as well, but so it goes.
o A number of optimizations and usability improvements:
o Make rcu_pending() ignore the grace-period timeout when
there is no grace period in progress.
o Make force_quiescent_state() avoid going for a global
lock in the case where there is no grace period in
progress.
o Rearrange struct fields to improve struct layout.
o Make call_rcu() initiate a grace period if RCU was
idle, rather than waiting for the next scheduling
clock interrupt.
o Invoke rcu_irq_enter() and rcu_irq_exit() only when
idle, as suggested by Andi Kleen. I still don't
completely trust this change, and might back it out.
o Make CONFIG_RCU_TRACE be the single config variable
manipulated for all forms of RCU, instead of the prior
confusion.
o Document tracing files and formats for both rcupreempt
and rcutree.
Updates from v4 for those missing v5 given its bad subject line:
o Separated dynticks interface so that NMIs and irqs call separate
functions, greatly simplifying it. In particular, this code
no longer requires a proof of correctness. ;-)
o Separated dynticks state out into its own per-CPU structure,
avoiding the duplicated accounting.
o The case where a dynticks-idle CPU runs an irq handler that
invokes call_rcu() is now correctly handled, forcing that CPU
out of dynticks-idle mode.
o Review comments have been applied (thank you all!!!).
For but one example, fixed the dynticks-ordering issue that
Manfred pointed out, saving me much debugging. ;-)
o Adjusted rcuclassic and rcupreempt to handle dynticks changes.
Attached is an updated patch to Classic RCU that applies a hierarchy,
greatly reducing the contention on the top-level lock for large machines.
This passes 10-hour concurrent rcutorture and online-offline testing on
128-CPU ppc64 without dynticks enabled, and exposes some timekeeping
bugs in presence of dynticks (exciting working on a system where
"sleep 1" hangs until interrupted...), which were fixed in the
2.6.27 kernel. It is getting more reliable than mainline by some
measures, so the next version will be against -tip for inclusion.
See also Manfred Spraul's recent patches (or his earlier work from
2004 at http://marc.info/?l=linux-kernel&m=108546384711797&w=2).
We will converge onto a common patch in the fullness of time, but are
currently exploring different regions of the design space. That said,
I have already gratefully stolen quite a few of Manfred's ideas.
This patch provides CONFIG_RCU_FANOUT, which controls the bushiness
of the RCU hierarchy. Defaults to 32 on 32-bit machines and 64 on
64-bit machines. If CONFIG_NR_CPUS is less than CONFIG_RCU_FANOUT,
there is no hierarchy. By default, the RCU initialization code will
adjust CONFIG_RCU_FANOUT to balance the hierarchy, so strongly NUMA
architectures may choose to set CONFIG_RCU_FANOUT_EXACT to disable
this balancing, allowing the hierarchy to be exactly aligned to the
underlying hardware. Up to two levels of hierarchy are permitted
(in addition to the root node), allowing up to 16,384 CPUs on 32-bit
systems and up to 262,144 CPUs on 64-bit systems. I just know that I
am going to regret saying this, but this seems more than sufficient
for the foreseeable future. (Some architectures might wish to set
CONFIG_RCU_FANOUT=4, which would limit such architectures to 64 CPUs.
If this becomes a real problem, additional levels can be added, but I
doubt that it will make a significant difference on real hardware.)
In the common case, a given CPU will manipulate its private rcu_data
structure and the rcu_node structure that it shares with its immediate
neighbors. This can reduce both lock and memory contention by multiple
orders of magnitude, which should eliminate the need for the strange
manipulations that are reported to be required when running Linux on
very large systems.
Some shortcomings:
o More bugs will probably surface as a result of an ongoing
line-by-line code inspection.
Patches will be provided as required.
o There are probably hangs, rcutorture failures, &c. Seems
quite stable on a 128-CPU machine, but that is kind of small
compared to 4096 CPUs. However, seems to do better than
mainline.
Patches will be provided as required.
o The memory footprint of this version is several KB larger
than rcuclassic.
A separate UP-only rcutiny patch will be provided, which will
reduce the memory footprint significantly, even compared
to the old rcuclassic. One such patch passes light testing,
and has a memory footprint smaller even than rcuclassic.
Initial reaction from various embedded guys was "it is not
worth it", so am putting it aside.
Credits:
o Manfred Spraul for ideas, review comments, and bugs spotted,
as well as some good friendly competition. ;-)
o Josh Triplett, Ingo Molnar, Peter Zijlstra, Mathieu Desnoyers,
Lai Jiangshan, Andi Kleen, Andy Whitcroft, and Andrew Morton
for reviews and comments.
o Thomas Gleixner for much-needed help with some timer issues
(see patches below).
o Jon M. Tollefson, Tim Pepper, Andrew Theurer, Jose R. Santos,
Andy Whitcroft, Darrick Wong, Nishanth Aravamudan, Anton
Blanchard, Dave Kleikamp, and Nathan Lynch for keeping machines
alive despite my heavy abuse^Wtesting.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-12-18 23:55:32 +03:00
|
|
|
WARN_ON_ONCE(!irqs_disabled()); /* @@@ DEBUG @@@ */
|
2005-04-17 02:20:36 +04:00
|
|
|
spin_unlock_irqrestore(&rtasd_log_lock, s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write error to NVRAM */
|
2007-10-03 05:19:09 +04:00
|
|
|
if (logging_enabled && !(err_type & ERR_FLAG_BOOT))
|
2007-08-10 00:56:41 +04:00
|
|
|
nvram_write_error_log(buf, len, err_type, error_log_cnt);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* rtas errors can occur during boot, and we do want to capture
|
|
|
|
* those somewhere, even if nvram isn't ready (why not?), and even
|
|
|
|
* if rtasd isn't ready. Put them into the boot log, at least.
|
|
|
|
*/
|
|
|
|
if ((err_type & ERR_TYPE_MASK) == ERR_TYPE_RTAS_LOG)
|
|
|
|
printk_log_rtas(buf, len);
|
|
|
|
|
|
|
|
/* Check to see if we need to or have stopped logging */
|
2007-10-03 05:19:09 +04:00
|
|
|
if (fatal || !logging_enabled) {
|
|
|
|
logging_enabled = 0;
|
"Tree RCU": scalable classic RCU implementation
This patch fixes a long-standing performance bug in classic RCU that
results in massive internal-to-RCU lock contention on systems with
more than a few hundred CPUs. Although this patch creates a separate
flavor of RCU for ease of review and patch maintenance, it is intended
to replace classic RCU.
This patch still handles stress better than does mainline, so I am still
calling it ready for inclusion. This patch is against the -tip tree.
Nevertheless, experience on an actual 1000+ CPU machine would still be
most welcome.
Most of the changes noted below were found while creating an rcutiny
(which should permit ejecting the current rcuclassic) and while doing
detailed line-by-line documentation.
Updates from v9 (http://lkml.org/lkml/2008/12/2/334):
o Fixes from remainder of line-by-line code walkthrough,
including comment spelling, initialization, undesirable
narrowing due to type conversion, removing redundant memory
barriers, removing redundant local-variable initialization,
and removing redundant local variables.
I do not believe that any of these fixes address the CPU-hotplug
issues that Andi Kleen was seeing, but please do give it a whirl
in case the machine is smarter than I am.
A writeup from the walkthrough may be found at the following
URL, in case you are suffering from terminal insomnia or
masochism:
http://www.kernel.org/pub/linux/kernel/people/paulmck/tmp/rcutree-walkthrough.2008.12.16a.pdf
o Made rcutree tracing use seq_file, as suggested some time
ago by Lai Jiangshan.
o Added a .csv variant of the rcudata debugfs trace file, to allow
people having thousands of CPUs to drop the data into
a spreadsheet. Tested with oocalc and gnumeric. Updated
documentation to suit.
Updates from v8 (http://lkml.org/lkml/2008/11/15/139):
o Fix a theoretical race between grace-period initialization and
force_quiescent_state() that could occur if more than three
jiffies were required to carry out the grace-period
initialization. Which it might, if you had enough CPUs.
o Apply Ingo's printk-standardization patch.
o Substitute local variables for repeated accesses to global
variables.
o Fix comment misspellings and redundant (but harmless) increments
of ->n_rcu_pending (this latter after having explicitly added it).
o Apply checkpatch fixes.
Updates from v7 (http://lkml.org/lkml/2008/10/10/291):
o Fixed a number of problems noted by Gautham Shenoy, including
the cpu-stall-detection bug that he was having difficulty
convincing me was real. ;-)
o Changed cpu-stall detection to wait for ten seconds rather than
three in order to reduce false positive, as suggested by Ingo
Molnar.
o Produced a design document (http://lwn.net/Articles/305782/).
The act of writing this document uncovered a number of both
theoretical and "here and now" bugs as noted below.
o Fix dynticks_nesting accounting confusion, simplify WARN_ON()
condition, fix kerneldoc comments, and add memory barriers
in dynticks interface functions.
o Add more data to tracing.
o Remove unused "rcu_barrier" field from rcu_data structure.
o Count calls to rcu_pending() from scheduling-clock interrupt
to use as a surrogate timebase should jiffies stop counting.
o Fix a theoretical race between force_quiescent_state() and
grace-period initialization. Yes, initialization does have to
go on for some jiffies for this race to occur, but given enough
CPUs...
Updates from v6 (http://lkml.org/lkml/2008/9/23/448):
o Fix a number of checkpatch.pl complaints.
o Apply review comments from Ingo Molnar and Lai Jiangshan
on the stall-detection code.
o Fix several bugs in !CONFIG_SMP builds.
o Fix a misspelled config-parameter name so that RCU now announces
at boot time if stall detection is configured.
o Run tests on numerous combinations of configurations parameters,
which after the fixes above, now build and run correctly.
Updates from v5 (http://lkml.org/lkml/2008/9/15/92, bad subject line):
o Fix a compiler error in the !CONFIG_FANOUT_EXACT case (blew a
changeset some time ago, and finally got around to retesting
this option).
o Fix some tracing bugs in rcupreempt that caused incorrect
totals to be printed.
o I now test with a more brutal random-selection online/offline
script (attached). Probably more brutal than it needs to be
on the people reading it as well, but so it goes.
o A number of optimizations and usability improvements:
o Make rcu_pending() ignore the grace-period timeout when
there is no grace period in progress.
o Make force_quiescent_state() avoid going for a global
lock in the case where there is no grace period in
progress.
o Rearrange struct fields to improve struct layout.
o Make call_rcu() initiate a grace period if RCU was
idle, rather than waiting for the next scheduling
clock interrupt.
o Invoke rcu_irq_enter() and rcu_irq_exit() only when
idle, as suggested by Andi Kleen. I still don't
completely trust this change, and might back it out.
o Make CONFIG_RCU_TRACE be the single config variable
manipulated for all forms of RCU, instead of the prior
confusion.
o Document tracing files and formats for both rcupreempt
and rcutree.
Updates from v4 for those missing v5 given its bad subject line:
o Separated dynticks interface so that NMIs and irqs call separate
functions, greatly simplifying it. In particular, this code
no longer requires a proof of correctness. ;-)
o Separated dynticks state out into its own per-CPU structure,
avoiding the duplicated accounting.
o The case where a dynticks-idle CPU runs an irq handler that
invokes call_rcu() is now correctly handled, forcing that CPU
out of dynticks-idle mode.
o Review comments have been applied (thank you all!!!).
For but one example, fixed the dynticks-ordering issue that
Manfred pointed out, saving me much debugging. ;-)
o Adjusted rcuclassic and rcupreempt to handle dynticks changes.
Attached is an updated patch to Classic RCU that applies a hierarchy,
greatly reducing the contention on the top-level lock for large machines.
This passes 10-hour concurrent rcutorture and online-offline testing on
128-CPU ppc64 without dynticks enabled, and exposes some timekeeping
bugs in presence of dynticks (exciting working on a system where
"sleep 1" hangs until interrupted...), which were fixed in the
2.6.27 kernel. It is getting more reliable than mainline by some
measures, so the next version will be against -tip for inclusion.
See also Manfred Spraul's recent patches (or his earlier work from
2004 at http://marc.info/?l=linux-kernel&m=108546384711797&w=2).
We will converge onto a common patch in the fullness of time, but are
currently exploring different regions of the design space. That said,
I have already gratefully stolen quite a few of Manfred's ideas.
This patch provides CONFIG_RCU_FANOUT, which controls the bushiness
of the RCU hierarchy. Defaults to 32 on 32-bit machines and 64 on
64-bit machines. If CONFIG_NR_CPUS is less than CONFIG_RCU_FANOUT,
there is no hierarchy. By default, the RCU initialization code will
adjust CONFIG_RCU_FANOUT to balance the hierarchy, so strongly NUMA
architectures may choose to set CONFIG_RCU_FANOUT_EXACT to disable
this balancing, allowing the hierarchy to be exactly aligned to the
underlying hardware. Up to two levels of hierarchy are permitted
(in addition to the root node), allowing up to 16,384 CPUs on 32-bit
systems and up to 262,144 CPUs on 64-bit systems. I just know that I
am going to regret saying this, but this seems more than sufficient
for the foreseeable future. (Some architectures might wish to set
CONFIG_RCU_FANOUT=4, which would limit such architectures to 64 CPUs.
If this becomes a real problem, additional levels can be added, but I
doubt that it will make a significant difference on real hardware.)
In the common case, a given CPU will manipulate its private rcu_data
structure and the rcu_node structure that it shares with its immediate
neighbors. This can reduce both lock and memory contention by multiple
orders of magnitude, which should eliminate the need for the strange
manipulations that are reported to be required when running Linux on
very large systems.
Some shortcomings:
o More bugs will probably surface as a result of an ongoing
line-by-line code inspection.
Patches will be provided as required.
o There are probably hangs, rcutorture failures, &c. Seems
quite stable on a 128-CPU machine, but that is kind of small
compared to 4096 CPUs. However, seems to do better than
mainline.
Patches will be provided as required.
o The memory footprint of this version is several KB larger
than rcuclassic.
A separate UP-only rcutiny patch will be provided, which will
reduce the memory footprint significantly, even compared
to the old rcuclassic. One such patch passes light testing,
and has a memory footprint smaller even than rcuclassic.
Initial reaction from various embedded guys was "it is not
worth it", so am putting it aside.
Credits:
o Manfred Spraul for ideas, review comments, and bugs spotted,
as well as some good friendly competition. ;-)
o Josh Triplett, Ingo Molnar, Peter Zijlstra, Mathieu Desnoyers,
Lai Jiangshan, Andi Kleen, Andy Whitcroft, and Andrew Morton
for reviews and comments.
o Thomas Gleixner for much-needed help with some timer issues
(see patches below).
o Jon M. Tollefson, Tim Pepper, Andrew Theurer, Jose R. Santos,
Andy Whitcroft, Darrick Wong, Nishanth Aravamudan, Anton
Blanchard, Dave Kleikamp, and Nathan Lynch for keeping machines
alive despite my heavy abuse^Wtesting.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-12-18 23:55:32 +03:00
|
|
|
WARN_ON_ONCE(!irqs_disabled()); /* @@@ DEBUG @@@ */
|
2005-04-17 02:20:36 +04:00
|
|
|
spin_unlock_irqrestore(&rtasd_log_lock, s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* call type specific method for error */
|
|
|
|
switch (err_type & ERR_TYPE_MASK) {
|
|
|
|
case ERR_TYPE_RTAS_LOG:
|
|
|
|
offset = rtas_error_log_buffer_max *
|
|
|
|
((rtas_log_start+rtas_log_size) & LOG_NUMBER_MASK);
|
|
|
|
|
|
|
|
/* First copy over sequence number */
|
|
|
|
memcpy(&rtas_log_buf[offset], (void *) &error_log_cnt, sizeof(int));
|
|
|
|
|
|
|
|
/* Second copy over error log data */
|
|
|
|
offset += sizeof(int);
|
|
|
|
memcpy(&rtas_log_buf[offset], buf, len);
|
|
|
|
|
|
|
|
if (rtas_log_size < LOG_NUMBER)
|
|
|
|
rtas_log_size += 1;
|
|
|
|
else
|
|
|
|
rtas_log_start += 1;
|
|
|
|
|
"Tree RCU": scalable classic RCU implementation
This patch fixes a long-standing performance bug in classic RCU that
results in massive internal-to-RCU lock contention on systems with
more than a few hundred CPUs. Although this patch creates a separate
flavor of RCU for ease of review and patch maintenance, it is intended
to replace classic RCU.
This patch still handles stress better than does mainline, so I am still
calling it ready for inclusion. This patch is against the -tip tree.
Nevertheless, experience on an actual 1000+ CPU machine would still be
most welcome.
Most of the changes noted below were found while creating an rcutiny
(which should permit ejecting the current rcuclassic) and while doing
detailed line-by-line documentation.
Updates from v9 (http://lkml.org/lkml/2008/12/2/334):
o Fixes from remainder of line-by-line code walkthrough,
including comment spelling, initialization, undesirable
narrowing due to type conversion, removing redundant memory
barriers, removing redundant local-variable initialization,
and removing redundant local variables.
I do not believe that any of these fixes address the CPU-hotplug
issues that Andi Kleen was seeing, but please do give it a whirl
in case the machine is smarter than I am.
A writeup from the walkthrough may be found at the following
URL, in case you are suffering from terminal insomnia or
masochism:
http://www.kernel.org/pub/linux/kernel/people/paulmck/tmp/rcutree-walkthrough.2008.12.16a.pdf
o Made rcutree tracing use seq_file, as suggested some time
ago by Lai Jiangshan.
o Added a .csv variant of the rcudata debugfs trace file, to allow
people having thousands of CPUs to drop the data into
a spreadsheet. Tested with oocalc and gnumeric. Updated
documentation to suit.
Updates from v8 (http://lkml.org/lkml/2008/11/15/139):
o Fix a theoretical race between grace-period initialization and
force_quiescent_state() that could occur if more than three
jiffies were required to carry out the grace-period
initialization. Which it might, if you had enough CPUs.
o Apply Ingo's printk-standardization patch.
o Substitute local variables for repeated accesses to global
variables.
o Fix comment misspellings and redundant (but harmless) increments
of ->n_rcu_pending (this latter after having explicitly added it).
o Apply checkpatch fixes.
Updates from v7 (http://lkml.org/lkml/2008/10/10/291):
o Fixed a number of problems noted by Gautham Shenoy, including
the cpu-stall-detection bug that he was having difficulty
convincing me was real. ;-)
o Changed cpu-stall detection to wait for ten seconds rather than
three in order to reduce false positive, as suggested by Ingo
Molnar.
o Produced a design document (http://lwn.net/Articles/305782/).
The act of writing this document uncovered a number of both
theoretical and "here and now" bugs as noted below.
o Fix dynticks_nesting accounting confusion, simplify WARN_ON()
condition, fix kerneldoc comments, and add memory barriers
in dynticks interface functions.
o Add more data to tracing.
o Remove unused "rcu_barrier" field from rcu_data structure.
o Count calls to rcu_pending() from scheduling-clock interrupt
to use as a surrogate timebase should jiffies stop counting.
o Fix a theoretical race between force_quiescent_state() and
grace-period initialization. Yes, initialization does have to
go on for some jiffies for this race to occur, but given enough
CPUs...
Updates from v6 (http://lkml.org/lkml/2008/9/23/448):
o Fix a number of checkpatch.pl complaints.
o Apply review comments from Ingo Molnar and Lai Jiangshan
on the stall-detection code.
o Fix several bugs in !CONFIG_SMP builds.
o Fix a misspelled config-parameter name so that RCU now announces
at boot time if stall detection is configured.
o Run tests on numerous combinations of configurations parameters,
which after the fixes above, now build and run correctly.
Updates from v5 (http://lkml.org/lkml/2008/9/15/92, bad subject line):
o Fix a compiler error in the !CONFIG_FANOUT_EXACT case (blew a
changeset some time ago, and finally got around to retesting
this option).
o Fix some tracing bugs in rcupreempt that caused incorrect
totals to be printed.
o I now test with a more brutal random-selection online/offline
script (attached). Probably more brutal than it needs to be
on the people reading it as well, but so it goes.
o A number of optimizations and usability improvements:
o Make rcu_pending() ignore the grace-period timeout when
there is no grace period in progress.
o Make force_quiescent_state() avoid going for a global
lock in the case where there is no grace period in
progress.
o Rearrange struct fields to improve struct layout.
o Make call_rcu() initiate a grace period if RCU was
idle, rather than waiting for the next scheduling
clock interrupt.
o Invoke rcu_irq_enter() and rcu_irq_exit() only when
idle, as suggested by Andi Kleen. I still don't
completely trust this change, and might back it out.
o Make CONFIG_RCU_TRACE be the single config variable
manipulated for all forms of RCU, instead of the prior
confusion.
o Document tracing files and formats for both rcupreempt
and rcutree.
Updates from v4 for those missing v5 given its bad subject line:
o Separated dynticks interface so that NMIs and irqs call separate
functions, greatly simplifying it. In particular, this code
no longer requires a proof of correctness. ;-)
o Separated dynticks state out into its own per-CPU structure,
avoiding the duplicated accounting.
o The case where a dynticks-idle CPU runs an irq handler that
invokes call_rcu() is now correctly handled, forcing that CPU
out of dynticks-idle mode.
o Review comments have been applied (thank you all!!!).
For but one example, fixed the dynticks-ordering issue that
Manfred pointed out, saving me much debugging. ;-)
o Adjusted rcuclassic and rcupreempt to handle dynticks changes.
Attached is an updated patch to Classic RCU that applies a hierarchy,
greatly reducing the contention on the top-level lock for large machines.
This passes 10-hour concurrent rcutorture and online-offline testing on
128-CPU ppc64 without dynticks enabled, and exposes some timekeeping
bugs in presence of dynticks (exciting working on a system where
"sleep 1" hangs until interrupted...), which were fixed in the
2.6.27 kernel. It is getting more reliable than mainline by some
measures, so the next version will be against -tip for inclusion.
See also Manfred Spraul's recent patches (or his earlier work from
2004 at http://marc.info/?l=linux-kernel&m=108546384711797&w=2).
We will converge onto a common patch in the fullness of time, but are
currently exploring different regions of the design space. That said,
I have already gratefully stolen quite a few of Manfred's ideas.
This patch provides CONFIG_RCU_FANOUT, which controls the bushiness
of the RCU hierarchy. Defaults to 32 on 32-bit machines and 64 on
64-bit machines. If CONFIG_NR_CPUS is less than CONFIG_RCU_FANOUT,
there is no hierarchy. By default, the RCU initialization code will
adjust CONFIG_RCU_FANOUT to balance the hierarchy, so strongly NUMA
architectures may choose to set CONFIG_RCU_FANOUT_EXACT to disable
this balancing, allowing the hierarchy to be exactly aligned to the
underlying hardware. Up to two levels of hierarchy are permitted
(in addition to the root node), allowing up to 16,384 CPUs on 32-bit
systems and up to 262,144 CPUs on 64-bit systems. I just know that I
am going to regret saying this, but this seems more than sufficient
for the foreseeable future. (Some architectures might wish to set
CONFIG_RCU_FANOUT=4, which would limit such architectures to 64 CPUs.
If this becomes a real problem, additional levels can be added, but I
doubt that it will make a significant difference on real hardware.)
In the common case, a given CPU will manipulate its private rcu_data
structure and the rcu_node structure that it shares with its immediate
neighbors. This can reduce both lock and memory contention by multiple
orders of magnitude, which should eliminate the need for the strange
manipulations that are reported to be required when running Linux on
very large systems.
Some shortcomings:
o More bugs will probably surface as a result of an ongoing
line-by-line code inspection.
Patches will be provided as required.
o There are probably hangs, rcutorture failures, &c. Seems
quite stable on a 128-CPU machine, but that is kind of small
compared to 4096 CPUs. However, seems to do better than
mainline.
Patches will be provided as required.
o The memory footprint of this version is several KB larger
than rcuclassic.
A separate UP-only rcutiny patch will be provided, which will
reduce the memory footprint significantly, even compared
to the old rcuclassic. One such patch passes light testing,
and has a memory footprint smaller even than rcuclassic.
Initial reaction from various embedded guys was "it is not
worth it", so am putting it aside.
Credits:
o Manfred Spraul for ideas, review comments, and bugs spotted,
as well as some good friendly competition. ;-)
o Josh Triplett, Ingo Molnar, Peter Zijlstra, Mathieu Desnoyers,
Lai Jiangshan, Andi Kleen, Andy Whitcroft, and Andrew Morton
for reviews and comments.
o Thomas Gleixner for much-needed help with some timer issues
(see patches below).
o Jon M. Tollefson, Tim Pepper, Andrew Theurer, Jose R. Santos,
Andy Whitcroft, Darrick Wong, Nishanth Aravamudan, Anton
Blanchard, Dave Kleikamp, and Nathan Lynch for keeping machines
alive despite my heavy abuse^Wtesting.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-12-18 23:55:32 +03:00
|
|
|
WARN_ON_ONCE(!irqs_disabled()); /* @@@ DEBUG @@@ */
|
2005-04-17 02:20:36 +04:00
|
|
|
spin_unlock_irqrestore(&rtasd_log_lock, s);
|
|
|
|
wake_up_interruptible(&rtas_log_wait);
|
|
|
|
break;
|
|
|
|
case ERR_TYPE_KERNEL_PANIC:
|
|
|
|
default:
|
"Tree RCU": scalable classic RCU implementation
This patch fixes a long-standing performance bug in classic RCU that
results in massive internal-to-RCU lock contention on systems with
more than a few hundred CPUs. Although this patch creates a separate
flavor of RCU for ease of review and patch maintenance, it is intended
to replace classic RCU.
This patch still handles stress better than does mainline, so I am still
calling it ready for inclusion. This patch is against the -tip tree.
Nevertheless, experience on an actual 1000+ CPU machine would still be
most welcome.
Most of the changes noted below were found while creating an rcutiny
(which should permit ejecting the current rcuclassic) and while doing
detailed line-by-line documentation.
Updates from v9 (http://lkml.org/lkml/2008/12/2/334):
o Fixes from remainder of line-by-line code walkthrough,
including comment spelling, initialization, undesirable
narrowing due to type conversion, removing redundant memory
barriers, removing redundant local-variable initialization,
and removing redundant local variables.
I do not believe that any of these fixes address the CPU-hotplug
issues that Andi Kleen was seeing, but please do give it a whirl
in case the machine is smarter than I am.
A writeup from the walkthrough may be found at the following
URL, in case you are suffering from terminal insomnia or
masochism:
http://www.kernel.org/pub/linux/kernel/people/paulmck/tmp/rcutree-walkthrough.2008.12.16a.pdf
o Made rcutree tracing use seq_file, as suggested some time
ago by Lai Jiangshan.
o Added a .csv variant of the rcudata debugfs trace file, to allow
people having thousands of CPUs to drop the data into
a spreadsheet. Tested with oocalc and gnumeric. Updated
documentation to suit.
Updates from v8 (http://lkml.org/lkml/2008/11/15/139):
o Fix a theoretical race between grace-period initialization and
force_quiescent_state() that could occur if more than three
jiffies were required to carry out the grace-period
initialization. Which it might, if you had enough CPUs.
o Apply Ingo's printk-standardization patch.
o Substitute local variables for repeated accesses to global
variables.
o Fix comment misspellings and redundant (but harmless) increments
of ->n_rcu_pending (this latter after having explicitly added it).
o Apply checkpatch fixes.
Updates from v7 (http://lkml.org/lkml/2008/10/10/291):
o Fixed a number of problems noted by Gautham Shenoy, including
the cpu-stall-detection bug that he was having difficulty
convincing me was real. ;-)
o Changed cpu-stall detection to wait for ten seconds rather than
three in order to reduce false positive, as suggested by Ingo
Molnar.
o Produced a design document (http://lwn.net/Articles/305782/).
The act of writing this document uncovered a number of both
theoretical and "here and now" bugs as noted below.
o Fix dynticks_nesting accounting confusion, simplify WARN_ON()
condition, fix kerneldoc comments, and add memory barriers
in dynticks interface functions.
o Add more data to tracing.
o Remove unused "rcu_barrier" field from rcu_data structure.
o Count calls to rcu_pending() from scheduling-clock interrupt
to use as a surrogate timebase should jiffies stop counting.
o Fix a theoretical race between force_quiescent_state() and
grace-period initialization. Yes, initialization does have to
go on for some jiffies for this race to occur, but given enough
CPUs...
Updates from v6 (http://lkml.org/lkml/2008/9/23/448):
o Fix a number of checkpatch.pl complaints.
o Apply review comments from Ingo Molnar and Lai Jiangshan
on the stall-detection code.
o Fix several bugs in !CONFIG_SMP builds.
o Fix a misspelled config-parameter name so that RCU now announces
at boot time if stall detection is configured.
o Run tests on numerous combinations of configurations parameters,
which after the fixes above, now build and run correctly.
Updates from v5 (http://lkml.org/lkml/2008/9/15/92, bad subject line):
o Fix a compiler error in the !CONFIG_FANOUT_EXACT case (blew a
changeset some time ago, and finally got around to retesting
this option).
o Fix some tracing bugs in rcupreempt that caused incorrect
totals to be printed.
o I now test with a more brutal random-selection online/offline
script (attached). Probably more brutal than it needs to be
on the people reading it as well, but so it goes.
o A number of optimizations and usability improvements:
o Make rcu_pending() ignore the grace-period timeout when
there is no grace period in progress.
o Make force_quiescent_state() avoid going for a global
lock in the case where there is no grace period in
progress.
o Rearrange struct fields to improve struct layout.
o Make call_rcu() initiate a grace period if RCU was
idle, rather than waiting for the next scheduling
clock interrupt.
o Invoke rcu_irq_enter() and rcu_irq_exit() only when
idle, as suggested by Andi Kleen. I still don't
completely trust this change, and might back it out.
o Make CONFIG_RCU_TRACE be the single config variable
manipulated for all forms of RCU, instead of the prior
confusion.
o Document tracing files and formats for both rcupreempt
and rcutree.
Updates from v4 for those missing v5 given its bad subject line:
o Separated dynticks interface so that NMIs and irqs call separate
functions, greatly simplifying it. In particular, this code
no longer requires a proof of correctness. ;-)
o Separated dynticks state out into its own per-CPU structure,
avoiding the duplicated accounting.
o The case where a dynticks-idle CPU runs an irq handler that
invokes call_rcu() is now correctly handled, forcing that CPU
out of dynticks-idle mode.
o Review comments have been applied (thank you all!!!).
For but one example, fixed the dynticks-ordering issue that
Manfred pointed out, saving me much debugging. ;-)
o Adjusted rcuclassic and rcupreempt to handle dynticks changes.
Attached is an updated patch to Classic RCU that applies a hierarchy,
greatly reducing the contention on the top-level lock for large machines.
This passes 10-hour concurrent rcutorture and online-offline testing on
128-CPU ppc64 without dynticks enabled, and exposes some timekeeping
bugs in presence of dynticks (exciting working on a system where
"sleep 1" hangs until interrupted...), which were fixed in the
2.6.27 kernel. It is getting more reliable than mainline by some
measures, so the next version will be against -tip for inclusion.
See also Manfred Spraul's recent patches (or his earlier work from
2004 at http://marc.info/?l=linux-kernel&m=108546384711797&w=2).
We will converge onto a common patch in the fullness of time, but are
currently exploring different regions of the design space. That said,
I have already gratefully stolen quite a few of Manfred's ideas.
This patch provides CONFIG_RCU_FANOUT, which controls the bushiness
of the RCU hierarchy. Defaults to 32 on 32-bit machines and 64 on
64-bit machines. If CONFIG_NR_CPUS is less than CONFIG_RCU_FANOUT,
there is no hierarchy. By default, the RCU initialization code will
adjust CONFIG_RCU_FANOUT to balance the hierarchy, so strongly NUMA
architectures may choose to set CONFIG_RCU_FANOUT_EXACT to disable
this balancing, allowing the hierarchy to be exactly aligned to the
underlying hardware. Up to two levels of hierarchy are permitted
(in addition to the root node), allowing up to 16,384 CPUs on 32-bit
systems and up to 262,144 CPUs on 64-bit systems. I just know that I
am going to regret saying this, but this seems more than sufficient
for the foreseeable future. (Some architectures might wish to set
CONFIG_RCU_FANOUT=4, which would limit such architectures to 64 CPUs.
If this becomes a real problem, additional levels can be added, but I
doubt that it will make a significant difference on real hardware.)
In the common case, a given CPU will manipulate its private rcu_data
structure and the rcu_node structure that it shares with its immediate
neighbors. This can reduce both lock and memory contention by multiple
orders of magnitude, which should eliminate the need for the strange
manipulations that are reported to be required when running Linux on
very large systems.
Some shortcomings:
o More bugs will probably surface as a result of an ongoing
line-by-line code inspection.
Patches will be provided as required.
o There are probably hangs, rcutorture failures, &c. Seems
quite stable on a 128-CPU machine, but that is kind of small
compared to 4096 CPUs. However, seems to do better than
mainline.
Patches will be provided as required.
o The memory footprint of this version is several KB larger
than rcuclassic.
A separate UP-only rcutiny patch will be provided, which will
reduce the memory footprint significantly, even compared
to the old rcuclassic. One such patch passes light testing,
and has a memory footprint smaller even than rcuclassic.
Initial reaction from various embedded guys was "it is not
worth it", so am putting it aside.
Credits:
o Manfred Spraul for ideas, review comments, and bugs spotted,
as well as some good friendly competition. ;-)
o Josh Triplett, Ingo Molnar, Peter Zijlstra, Mathieu Desnoyers,
Lai Jiangshan, Andi Kleen, Andy Whitcroft, and Andrew Morton
for reviews and comments.
o Thomas Gleixner for much-needed help with some timer issues
(see patches below).
o Jon M. Tollefson, Tim Pepper, Andrew Theurer, Jose R. Santos,
Andy Whitcroft, Darrick Wong, Nishanth Aravamudan, Anton
Blanchard, Dave Kleikamp, and Nathan Lynch for keeping machines
alive despite my heavy abuse^Wtesting.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-12-18 23:55:32 +03:00
|
|
|
WARN_ON_ONCE(!irqs_disabled()); /* @@@ DEBUG @@@ */
|
2005-04-17 02:20:36 +04:00
|
|
|
spin_unlock_irqrestore(&rtasd_log_lock, s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rtas_log_open(struct inode * inode, struct file * file)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtas_log_release(struct inode * inode, struct file * file)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This will check if all events are logged, if they are then, we
|
|
|
|
* know that we can safely clear the events in NVRAM.
|
|
|
|
* Next we'll sit and wait for something else to log.
|
|
|
|
*/
|
|
|
|
static ssize_t rtas_log_read(struct file * file, char __user * buf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
char *tmp;
|
|
|
|
unsigned long s;
|
|
|
|
unsigned long offset;
|
|
|
|
|
|
|
|
if (!buf || count < rtas_error_log_buffer_max)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
count = rtas_error_log_buffer_max;
|
|
|
|
|
|
|
|
if (!access_ok(VERIFY_WRITE, buf, count))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
tmp = kmalloc(count, GFP_KERNEL);
|
|
|
|
if (!tmp)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&rtasd_log_lock, s);
|
|
|
|
/* if it's 0, then we know we got the last one (the one in NVRAM) */
|
2008-09-29 03:24:33 +04:00
|
|
|
while (rtas_log_size == 0) {
|
|
|
|
if (file->f_flags & O_NONBLOCK) {
|
|
|
|
spin_unlock_irqrestore(&rtasd_log_lock, s);
|
|
|
|
error = -EAGAIN;
|
|
|
|
goto out;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-09-29 03:24:33 +04:00
|
|
|
if (!logging_enabled) {
|
|
|
|
spin_unlock_irqrestore(&rtasd_log_lock, s);
|
|
|
|
error = -ENODATA;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
nvram_clear_error_log();
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-09-29 03:24:33 +04:00
|
|
|
spin_unlock_irqrestore(&rtasd_log_lock, s);
|
|
|
|
error = wait_event_interruptible(rtas_log_wait, rtas_log_size);
|
|
|
|
if (error)
|
|
|
|
goto out;
|
|
|
|
spin_lock_irqsave(&rtasd_log_lock, s);
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
offset = rtas_error_log_buffer_max * (rtas_log_start & LOG_NUMBER_MASK);
|
|
|
|
memcpy(tmp, &rtas_log_buf[offset], count);
|
|
|
|
|
|
|
|
rtas_log_start += 1;
|
|
|
|
rtas_log_size -= 1;
|
|
|
|
spin_unlock_irqrestore(&rtasd_log_lock, s);
|
|
|
|
|
|
|
|
error = copy_to_user(buf, tmp, count) ? -EFAULT : count;
|
|
|
|
out:
|
|
|
|
kfree(tmp);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int rtas_log_poll(struct file *file, poll_table * wait)
|
|
|
|
{
|
|
|
|
poll_wait(file, &rtas_log_wait, wait);
|
|
|
|
if (rtas_log_size)
|
|
|
|
return POLLIN | POLLRDNORM;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-05-08 08:27:23 +04:00
|
|
|
static const struct file_operations proc_rtas_log_operations = {
|
2005-04-17 02:20:36 +04:00
|
|
|
.read = rtas_log_read,
|
|
|
|
.poll = rtas_log_poll,
|
|
|
|
.open = rtas_log_open,
|
|
|
|
.release = rtas_log_release,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int enable_surveillance(int timeout)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = rtas_set_indicator(SURVEILLANCE_TOKEN, 0, timeout);
|
|
|
|
|
|
|
|
if (error == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (error == -EINVAL) {
|
2006-04-13 00:28:13 +04:00
|
|
|
printk(KERN_DEBUG "rtasd: surveillance not supported\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_ERR "rtasd: could not update surveillance\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-08-10 01:01:50 +04:00
|
|
|
static void do_event_scan(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
do {
|
|
|
|
memset(logdata, 0, rtas_error_log_max);
|
|
|
|
error = rtas_call(event_scan, 4, 1, NULL,
|
|
|
|
RTAS_EVENT_SCAN_ALL_EVENTS, 0,
|
|
|
|
__pa(logdata), rtas_error_log_max);
|
|
|
|
if (error == -1) {
|
|
|
|
printk(KERN_ERR "event-scan failed\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error == 0)
|
|
|
|
pSeries_log_error(logdata, ERR_TYPE_RTAS_LOG, 0);
|
|
|
|
|
|
|
|
} while(error == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_event_scan_all_cpus(long delay)
|
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
|
2008-01-25 23:08:02 +03:00
|
|
|
get_online_cpus();
|
2005-04-17 02:20:36 +04:00
|
|
|
cpu = first_cpu(cpu_online_map);
|
|
|
|
for (;;) {
|
|
|
|
set_cpus_allowed(current, cpumask_of_cpu(cpu));
|
2007-08-10 01:01:50 +04:00
|
|
|
do_event_scan();
|
2005-04-17 02:20:36 +04:00
|
|
|
set_cpus_allowed(current, CPU_MASK_ALL);
|
|
|
|
|
|
|
|
/* Drop hotplug lock, and sleep for the specified delay */
|
2008-01-25 23:08:02 +03:00
|
|
|
put_online_cpus();
|
2005-09-04 02:56:01 +04:00
|
|
|
msleep_interruptible(delay);
|
2008-01-25 23:08:02 +03:00
|
|
|
get_online_cpus();
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
cpu = next_cpu(cpu, cpu_online_map);
|
|
|
|
if (cpu == NR_CPUS)
|
|
|
|
break;
|
|
|
|
}
|
2008-01-25 23:08:02 +03:00
|
|
|
put_online_cpus();
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtasd(void *unused)
|
|
|
|
{
|
|
|
|
unsigned int err_type;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
daemonize("rtasd");
|
|
|
|
|
2006-04-13 00:28:13 +04:00
|
|
|
printk(KERN_DEBUG "RTAS daemon started\n");
|
2008-04-24 09:13:19 +04:00
|
|
|
pr_debug("rtasd: will sleep for %d milliseconds\n",
|
|
|
|
(30000 / rtas_event_scan_rate));
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* See if we have any error stored in NVRAM */
|
|
|
|
memset(logdata, 0, rtas_error_log_max);
|
2007-08-10 00:56:41 +04:00
|
|
|
rc = nvram_read_error_log(logdata, rtas_error_log_max,
|
|
|
|
&err_type, &error_log_cnt);
|
2007-10-03 05:19:09 +04:00
|
|
|
/* We can use rtas_log_buf now */
|
|
|
|
logging_enabled = 1;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
if (!rc) {
|
|
|
|
if (err_type != ERR_FLAG_ALREADY_LOGGED) {
|
|
|
|
pSeries_log_error(logdata, err_type | ERR_FLAG_BOOT, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First pass. */
|
2005-09-04 02:56:01 +04:00
|
|
|
do_event_scan_all_cpus(1000);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
if (surveillance_timeout != -1) {
|
2008-04-24 09:13:19 +04:00
|
|
|
pr_debug("rtasd: enabling surveillance\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
enable_surveillance(surveillance_timeout);
|
2008-04-24 09:13:19 +04:00
|
|
|
pr_debug("rtasd: surveillance enabled\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Delay should be at least one second since some
|
|
|
|
* machines have problems if we call event-scan too
|
|
|
|
* quickly. */
|
|
|
|
for (;;)
|
2005-09-04 02:56:01 +04:00
|
|
|
do_event_scan_all_cpus(30000/rtas_event_scan_rate);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init rtas_init(void)
|
|
|
|
{
|
|
|
|
struct proc_dir_entry *entry;
|
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
if (!machine_is(pseries))
|
2005-11-10 05:37:51 +03:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* No RTAS */
|
2007-08-10 01:01:50 +04:00
|
|
|
event_scan = rtas_token("event-scan");
|
|
|
|
if (event_scan == RTAS_UNKNOWN_SERVICE) {
|
2006-04-13 00:28:13 +04:00
|
|
|
printk(KERN_DEBUG "rtasd: no event-scan on system\n");
|
2006-04-02 14:18:32 +04:00
|
|
|
return -ENODEV;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2007-08-09 00:03:37 +04:00
|
|
|
rtas_event_scan_rate = rtas_token("rtas-event-scan-rate");
|
|
|
|
if (rtas_event_scan_rate == RTAS_UNKNOWN_SERVICE) {
|
|
|
|
printk(KERN_ERR "rtasd: no rtas-event-scan-rate on system\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make room for the sequence number */
|
|
|
|
rtas_error_log_max = rtas_get_error_log_max();
|
|
|
|
rtas_error_log_buffer_max = rtas_error_log_max + sizeof(int);
|
|
|
|
|
|
|
|
rtas_log_buf = vmalloc(rtas_error_log_buffer_max*LOG_NUMBER);
|
|
|
|
if (!rtas_log_buf) {
|
|
|
|
printk(KERN_ERR "rtasd: no memory\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2008-04-29 12:02:26 +04:00
|
|
|
entry = proc_create("ppc64/rtas/error_log", S_IRUSR, NULL,
|
|
|
|
&proc_rtas_log_operations);
|
|
|
|
if (!entry)
|
2005-04-17 02:20:36 +04:00
|
|
|
printk(KERN_ERR "Failed to create error_log proc entry\n");
|
|
|
|
|
|
|
|
if (kernel_thread(rtasd, NULL, CLONE_FS) < 0)
|
|
|
|
printk(KERN_ERR "Failed to start RTAS daemon\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init surveillance_setup(char *str)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (get_option(&str,&i)) {
|
|
|
|
if (i >= 0 && i <= 255)
|
|
|
|
surveillance_timeout = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init rtasmsgs_setup(char *str)
|
|
|
|
{
|
|
|
|
if (strcmp(str, "on") == 0)
|
|
|
|
full_rtas_msgs = 1;
|
|
|
|
else if (strcmp(str, "off") == 0)
|
|
|
|
full_rtas_msgs = 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__initcall(rtas_init);
|
|
|
|
__setup("surveillance=", surveillance_setup);
|
|
|
|
__setup("rtasmsgs=", rtasmsgs_setup);
|