2005-04-17 06:20:36 +08: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>
|
2009-05-26 04:25:49 +08:00
|
|
|
#include <linux/workqueue.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2017-01-07 03:28:54 +08:00
|
|
|
#include <linux/topology.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-12-25 03:46:01 +08:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/rtas.h>
|
|
|
|
#include <asm/prom.h>
|
|
|
|
#include <asm/nvram.h>
|
2011-07-27 07:09:06 +08:00
|
|
|
#include <linux/atomic.h>
|
2006-03-28 20:15:54 +08:00
|
|
|
#include <asm/machdep.h>
|
2013-04-24 14:07:39 +08:00
|
|
|
#include <asm/topology.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
static DEFINE_SPINLOCK(rtasd_log_lock);
|
|
|
|
|
2008-05-08 12:27:23 +08:00
|
|
|
static DECLARE_WAIT_QUEUE_HEAD(rtas_log_wait);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static char *rtas_log_buf;
|
|
|
|
static unsigned long rtas_log_start;
|
|
|
|
static unsigned long rtas_log_size;
|
|
|
|
|
|
|
|
static int surveillance_timeout = -1;
|
2009-09-25 03:30:05 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static unsigned int rtas_error_log_max;
|
|
|
|
static unsigned int rtas_error_log_buffer_max;
|
|
|
|
|
2007-08-10 05:01:50 +08:00
|
|
|
/* RTAS service tokens */
|
|
|
|
static unsigned int event_scan;
|
|
|
|
static unsigned int rtas_event_scan_rate;
|
|
|
|
|
2016-03-18 05:23:00 +08:00
|
|
|
static bool full_rtas_msgs;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-08-09 04:06:15 +08:00
|
|
|
/* Stop logging to nvram after first fatal error */
|
2007-10-03 09:19:09 +08:00
|
|
|
static int logging_enabled; /* Until we initialize everything,
|
|
|
|
* make sure we don't try logging
|
|
|
|
* anything */
|
2007-08-10 04:56:41 +08:00
|
|
|
static int error_log_cnt;
|
2005-04-17 06:20:36 +08: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";
|
2013-04-24 13:51:33 +08:00
|
|
|
case RTAS_TYPE_PRRN:
|
|
|
|
return "Platform Resource Reassignment Event";
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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",
|
2014-04-04 15:35:13 +08:00
|
|
|
error_log_cnt, rtas_event_type(rtas_error_type(errlog)),
|
|
|
|
rtas_error_severity(errlog));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int log_rtas_len(char * buf)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
struct rtas_error_log *err;
|
2014-04-04 15:35:13 +08:00
|
|
|
uint32_t extended_log_length;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* rtas fixed header */
|
|
|
|
len = 8;
|
|
|
|
err = (struct rtas_error_log *)buf;
|
2014-04-04 15:35:13 +08:00
|
|
|
extended_log_length = rtas_error_extended_log_length(err);
|
|
|
|
if (rtas_error_extended(err) && extended_log_length) {
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* extended header */
|
2014-04-04 15:35:13 +08:00
|
|
|
len += extended_log_length;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-08-09 04:03:37 +08:00
|
|
|
if (rtas_error_log_max == 0)
|
|
|
|
rtas_error_log_max = rtas_get_error_log_max();
|
|
|
|
|
2005-04-17 06:20:36 +08: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 13:13:19 +08:00
|
|
|
pr_debug("rtasd: logging event\n");
|
2005-04-17 06:20:36 +08: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-19 04:55:32 +08:00
|
|
|
WARN_ON_ONCE(!irqs_disabled()); /* @@@ DEBUG @@@ */
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&rtasd_log_lock, s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-09-25 03:30:05 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Write error to NVRAM */
|
2007-10-03 09:19:09 +08:00
|
|
|
if (logging_enabled && !(err_type & ERR_FLAG_BOOT))
|
2007-08-10 04:56:41 +08:00
|
|
|
nvram_write_error_log(buf, len, err_type, error_log_cnt);
|
2009-09-25 03:30:05 +08:00
|
|
|
#endif /* CONFIG_PPC64 */
|
2005-04-17 06:20:36 +08: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 09:19:09 +08: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-19 04:55:32 +08:00
|
|
|
WARN_ON_ONCE(!irqs_disabled()); /* @@@ DEBUG @@@ */
|
2005-04-17 06:20:36 +08: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-19 04:55:32 +08:00
|
|
|
WARN_ON_ONCE(!irqs_disabled()); /* @@@ DEBUG @@@ */
|
2005-04-17 06:20:36 +08: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-19 04:55:32 +08:00
|
|
|
WARN_ON_ONCE(!irqs_disabled()); /* @@@ DEBUG @@@ */
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&rtasd_log_lock, s);
|
|
|
|
return;
|
|
|
|
}
|
2013-04-24 13:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPC_PSERIES
|
|
|
|
static s32 prrn_update_scope;
|
|
|
|
|
|
|
|
static void prrn_work_fn(struct work_struct *work)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* For PRRN, we must pass the negative of the scope value in
|
|
|
|
* the RTAS event.
|
|
|
|
*/
|
|
|
|
pseries_devicetree_update(-prrn_update_scope);
|
2017-06-21 06:08:30 +08:00
|
|
|
numa_update_cpu_topology(false);
|
2013-04-24 13:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static DECLARE_WORK(prrn_work, prrn_work_fn);
|
|
|
|
|
2014-08-20 06:55:18 +08:00
|
|
|
static void prrn_schedule_update(u32 scope)
|
2013-04-24 13:51:33 +08:00
|
|
|
{
|
|
|
|
flush_work(&prrn_work);
|
|
|
|
prrn_update_scope = scope;
|
|
|
|
schedule_work(&prrn_work);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void handle_rtas_event(const struct rtas_error_log *log)
|
|
|
|
{
|
2014-04-04 15:35:13 +08:00
|
|
|
if (rtas_error_type(log) != RTAS_TYPE_PRRN || !prrn_is_enabled())
|
|
|
|
return;
|
2013-04-24 13:51:33 +08:00
|
|
|
|
2014-04-04 15:35:13 +08:00
|
|
|
/* For PRRN Events the extended log length is used to denote
|
|
|
|
* the scope for calling rtas update-nodes.
|
|
|
|
*/
|
|
|
|
prrn_schedule_update(rtas_error_extended_log_length(log));
|
2013-04-24 13:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-04-24 13:51:33 +08:00
|
|
|
static void handle_rtas_event(const struct rtas_error_log *log)
|
|
|
|
{
|
|
|
|
return;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2013-04-24 13:51:33 +08:00
|
|
|
#endif
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
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);
|
2009-09-25 03:30:05 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* if it's 0, then we know we got the last one (the one in NVRAM) */
|
2008-09-29 07:24:33 +08: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 06:20:36 +08:00
|
|
|
|
2008-09-29 07:24:33 +08:00
|
|
|
if (!logging_enabled) {
|
|
|
|
spin_unlock_irqrestore(&rtasd_log_lock, s);
|
|
|
|
error = -ENODATA;
|
|
|
|
goto out;
|
|
|
|
}
|
2009-09-25 03:30:05 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
2008-09-29 07:24:33 +08:00
|
|
|
nvram_clear_error_log();
|
2009-09-25 03:30:05 +08:00
|
|
|
#endif /* CONFIG_PPC64 */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-09-29 07:24:33 +08: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 06:20:36 +08: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 12:27:23 +08:00
|
|
|
static const struct file_operations proc_rtas_log_operations = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.read = rtas_log_read,
|
|
|
|
.poll = rtas_log_poll,
|
|
|
|
.open = rtas_log_open,
|
|
|
|
.release = rtas_log_release,
|
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-16 00:52:59 +08:00
|
|
|
.llseek = noop_llseek,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
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 04:28:13 +08:00
|
|
|
printk(KERN_DEBUG "rtasd: surveillance not supported\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_ERR "rtasd: could not update surveillance\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-08-10 05:01:50 +08:00
|
|
|
static void do_event_scan(void)
|
2005-04-17 06:20:36 +08: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;
|
|
|
|
}
|
|
|
|
|
2013-04-24 13:51:33 +08:00
|
|
|
if (error == 0) {
|
2017-01-07 03:28:54 +08:00
|
|
|
if (rtas_error_type((struct rtas_error_log *)logdata) !=
|
|
|
|
RTAS_TYPE_PRRN)
|
|
|
|
pSeries_log_error(logdata, ERR_TYPE_RTAS_LOG,
|
|
|
|
0);
|
2013-04-24 13:51:33 +08:00
|
|
|
handle_rtas_event((struct rtas_error_log *)logdata);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
} while(error == 0);
|
|
|
|
}
|
|
|
|
|
2009-05-26 04:25:49 +08:00
|
|
|
static void rtas_event_scan(struct work_struct *w);
|
2016-01-06 08:45:50 +08:00
|
|
|
static DECLARE_DELAYED_WORK(event_scan_work, rtas_event_scan);
|
2009-05-26 04:25:49 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Delay should be at least one second since some machines have problems if
|
|
|
|
* we call event-scan too quickly.
|
|
|
|
*/
|
|
|
|
static unsigned long event_scan_delay = 1*HZ;
|
|
|
|
static int first_pass = 1;
|
|
|
|
|
|
|
|
static void rtas_event_scan(struct work_struct *w)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-05-26 04:25:49 +08:00
|
|
|
unsigned int cpu;
|
|
|
|
|
|
|
|
do_event_scan();
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-01-26 04:08:02 +08:00
|
|
|
get_online_cpus();
|
2009-05-26 04:25:49 +08:00
|
|
|
|
2011-02-10 19:57:27 +08:00
|
|
|
/* raw_ OK because just using CPU as starting point. */
|
|
|
|
cpu = cpumask_next(raw_smp_processor_id(), cpu_online_mask);
|
2010-04-26 23:32:33 +08:00
|
|
|
if (cpu >= nr_cpu_ids) {
|
|
|
|
cpu = cpumask_first(cpu_online_mask);
|
2009-05-26 04:25:49 +08:00
|
|
|
|
|
|
|
if (first_pass) {
|
|
|
|
first_pass = 0;
|
|
|
|
event_scan_delay = 30*HZ/rtas_event_scan_rate;
|
|
|
|
|
|
|
|
if (surveillance_timeout != -1) {
|
|
|
|
pr_debug("rtasd: enabling surveillance\n");
|
|
|
|
enable_surveillance(surveillance_timeout);
|
|
|
|
pr_debug("rtasd: surveillance enabled\n");
|
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2009-05-26 04:25:49 +08:00
|
|
|
|
|
|
|
schedule_delayed_work_on(cpu, &event_scan_work,
|
|
|
|
__round_jiffies_relative(event_scan_delay, cpu));
|
|
|
|
|
2008-01-26 04:08:02 +08:00
|
|
|
put_online_cpus();
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-09-25 03:30:05 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
2016-05-20 22:18:57 +08:00
|
|
|
static void retrieve_nvram_error_log(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-09-25 03:30:05 +08:00
|
|
|
unsigned int err_type ;
|
|
|
|
int rc ;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* See if we have any error stored in NVRAM */
|
|
|
|
memset(logdata, 0, rtas_error_log_max);
|
2007-08-10 04:56:41 +08:00
|
|
|
rc = nvram_read_error_log(logdata, rtas_error_log_max,
|
|
|
|
&err_type, &error_log_cnt);
|
2007-10-03 09:19:09 +08:00
|
|
|
/* We can use rtas_log_buf now */
|
|
|
|
logging_enabled = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!rc) {
|
|
|
|
if (err_type != ERR_FLAG_ALREADY_LOGGED) {
|
|
|
|
pSeries_log_error(logdata, err_type | ERR_FLAG_BOOT, 0);
|
|
|
|
}
|
|
|
|
}
|
2009-09-25 03:30:05 +08:00
|
|
|
}
|
|
|
|
#else /* CONFIG_PPC64 */
|
2016-05-20 22:18:57 +08:00
|
|
|
static void retrieve_nvram_error_log(void)
|
2009-09-25 03:30:05 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PPC64 */
|
|
|
|
|
|
|
|
static void start_event_scan(void)
|
|
|
|
{
|
|
|
|
printk(KERN_DEBUG "RTAS daemon started\n");
|
|
|
|
pr_debug("rtasd: will sleep for %d milliseconds\n",
|
|
|
|
(30000 / rtas_event_scan_rate));
|
|
|
|
|
2011-03-31 09:57:33 +08:00
|
|
|
/* Retrieve errors from nvram if any */
|
2016-05-20 22:18:57 +08:00
|
|
|
retrieve_nvram_error_log();
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-04-26 23:32:33 +08:00
|
|
|
schedule_delayed_work_on(cpumask_first(cpu_online_mask),
|
|
|
|
&event_scan_work, event_scan_delay);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2011-10-04 05:49:53 +08:00
|
|
|
/* Cancel the rtas event scan work */
|
|
|
|
void rtas_cancel_event_scan(void)
|
|
|
|
{
|
|
|
|
cancel_delayed_work_sync(&event_scan_work);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rtas_cancel_event_scan);
|
|
|
|
|
2016-06-16 04:26:41 +08:00
|
|
|
static int __init rtas_event_scan_init(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-09-25 03:30:05 +08:00
|
|
|
if (!machine_is(pseries) && !machine_is(chrp))
|
2005-11-10 10:37:51 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* No RTAS */
|
2007-08-10 05:01:50 +08:00
|
|
|
event_scan = rtas_token("event-scan");
|
|
|
|
if (event_scan == RTAS_UNKNOWN_SERVICE) {
|
2009-09-25 03:30:05 +08:00
|
|
|
printk(KERN_INFO "rtasd: No event-scan on system\n");
|
2006-04-02 18:18:32 +08:00
|
|
|
return -ENODEV;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-08-09 04:03:37 +08: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;
|
|
|
|
}
|
|
|
|
|
2010-05-19 10:12:32 +08:00
|
|
|
if (!rtas_event_scan_rate) {
|
|
|
|
/* Broken firmware: take a rate of zero to mean don't scan */
|
|
|
|
printk(KERN_DEBUG "rtasd: scan rate is 0, not scanning\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-09 04:03:37 +08:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2016-06-16 04:26:41 +08:00
|
|
|
start_event_scan();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
arch_initcall(rtas_event_scan_init);
|
|
|
|
|
|
|
|
static int __init rtas_init(void)
|
|
|
|
{
|
|
|
|
struct proc_dir_entry *entry;
|
|
|
|
|
|
|
|
if (!machine_is(pseries) && !machine_is(chrp))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!rtas_log_buf)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2009-09-25 03:30:05 +08:00
|
|
|
entry = proc_create("powerpc/rtas/error_log", S_IRUSR, NULL,
|
2008-04-29 16:02:26 +08:00
|
|
|
&proc_rtas_log_operations);
|
|
|
|
if (!entry)
|
2005-04-17 06:20:36 +08:00
|
|
|
printk(KERN_ERR "Failed to create error_log proc entry\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-25 03:30:05 +08:00
|
|
|
__initcall(rtas_init);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int __init surveillance_setup(char *str)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2009-09-25 03:30:05 +08:00
|
|
|
/* We only do surveillance on pseries */
|
|
|
|
if (!machine_is(pseries))
|
|
|
|
return 0;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (get_option(&str,&i)) {
|
|
|
|
if (i >= 0 && i <= 255)
|
|
|
|
surveillance_timeout = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2009-09-25 03:30:05 +08:00
|
|
|
__setup("surveillance=", surveillance_setup);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int __init rtasmsgs_setup(char *str)
|
|
|
|
{
|
2016-03-18 05:23:00 +08:00
|
|
|
return (kstrtobool(str, &full_rtas_msgs) == 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
__setup("rtasmsgs=", rtasmsgs_setup);
|