2005-04-16 22:20:36 +00: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-25 20:25:49 +00: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 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2005-04-16 22:20:36 +00: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 12:15:54 +00:00
|
|
|
#include <asm/machdep.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
static DEFINE_SPINLOCK(rtasd_log_lock);
|
|
|
|
|
2008-05-08 04:27:23 +00:00
|
|
|
static DECLARE_WAIT_QUEUE_HEAD(rtas_log_wait);
|
2005-04-16 22:20:36 +00: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-24 19:30:05 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static unsigned int rtas_error_log_max;
|
|
|
|
static unsigned int rtas_error_log_buffer_max;
|
|
|
|
|
2007-08-09 21:01:50 +00:00
|
|
|
/* RTAS service tokens */
|
|
|
|
static unsigned int event_scan;
|
|
|
|
static unsigned int rtas_event_scan_rate;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int full_rtas_msgs = 0;
|
|
|
|
|
2007-08-08 20:06:15 +00:00
|
|
|
/* Stop logging to nvram after first fatal error */
|
2007-10-03 01:19:09 +00:00
|
|
|
static int logging_enabled; /* Until we initialize everything,
|
|
|
|
* make sure we don't try logging
|
|
|
|
* anything */
|
2007-08-09 20:56:41 +00:00
|
|
|
static int error_log_cnt;
|
2005-04-16 22:20:36 +00: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-08 20:03:37 +00:00
|
|
|
if (rtas_error_log_max == 0)
|
|
|
|
rtas_error_log_max = rtas_get_error_log_max();
|
|
|
|
|
2005-04-16 22:20:36 +00: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 05:13:19 +00:00
|
|
|
pr_debug("rtasd: logging event\n");
|
2005-04-16 22:20:36 +00: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 20:55:32 +00:00
|
|
|
WARN_ON_ONCE(!irqs_disabled()); /* @@@ DEBUG @@@ */
|
2005-04-16 22:20:36 +00:00
|
|
|
spin_unlock_irqrestore(&rtasd_log_lock, s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-09-24 19:30:05 +00:00
|
|
|
#ifdef CONFIG_PPC64
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Write error to NVRAM */
|
2007-10-03 01:19:09 +00:00
|
|
|
if (logging_enabled && !(err_type & ERR_FLAG_BOOT))
|
2007-08-09 20:56:41 +00:00
|
|
|
nvram_write_error_log(buf, len, err_type, error_log_cnt);
|
2009-09-24 19:30:05 +00:00
|
|
|
#endif /* CONFIG_PPC64 */
|
2005-04-16 22:20:36 +00: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 01:19:09 +00: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 20:55:32 +00:00
|
|
|
WARN_ON_ONCE(!irqs_disabled()); /* @@@ DEBUG @@@ */
|
2005-04-16 22:20:36 +00: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 20:55:32 +00:00
|
|
|
WARN_ON_ONCE(!irqs_disabled()); /* @@@ DEBUG @@@ */
|
2005-04-16 22:20:36 +00: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 20:55:32 +00:00
|
|
|
WARN_ON_ONCE(!irqs_disabled()); /* @@@ DEBUG @@@ */
|
2005-04-16 22:20:36 +00: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);
|
2009-09-24 19:30:05 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* if it's 0, then we know we got the last one (the one in NVRAM) */
|
2008-09-28 23:24:33 +00: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-16 22:20:36 +00:00
|
|
|
|
2008-09-28 23:24:33 +00:00
|
|
|
if (!logging_enabled) {
|
|
|
|
spin_unlock_irqrestore(&rtasd_log_lock, s);
|
|
|
|
error = -ENODATA;
|
|
|
|
goto out;
|
|
|
|
}
|
2009-09-24 19:30:05 +00:00
|
|
|
#ifdef CONFIG_PPC64
|
2008-09-28 23:24:33 +00:00
|
|
|
nvram_clear_error_log();
|
2009-09-24 19:30:05 +00:00
|
|
|
#endif /* CONFIG_PPC64 */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-09-28 23:24:33 +00: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-16 22:20:36 +00: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 04:27:23 +00:00
|
|
|
static const struct file_operations proc_rtas_log_operations = {
|
2005-04-16 22:20:36 +00: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-12 20:28:13 +00:00
|
|
|
printk(KERN_DEBUG "rtasd: surveillance not supported\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_ERR "rtasd: could not update surveillance\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-08-09 21:01:50 +00:00
|
|
|
static void do_event_scan(void)
|
2005-04-16 22:20:36 +00: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);
|
|
|
|
}
|
|
|
|
|
2009-05-25 20:25:49 +00:00
|
|
|
static void rtas_event_scan(struct work_struct *w);
|
|
|
|
DECLARE_DELAYED_WORK(event_scan_work, rtas_event_scan);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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-16 22:20:36 +00:00
|
|
|
{
|
2009-05-25 20:25:49 +00:00
|
|
|
unsigned int cpu;
|
|
|
|
|
|
|
|
do_event_scan();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-01-25 20:08:02 +00:00
|
|
|
get_online_cpus();
|
2009-05-25 20:25:49 +00:00
|
|
|
|
2010-04-26 15:32:33 +00:00
|
|
|
cpu = cpumask_next(smp_processor_id(), cpu_online_mask);
|
|
|
|
if (cpu >= nr_cpu_ids) {
|
|
|
|
cpu = cpumask_first(cpu_online_mask);
|
2009-05-25 20:25:49 +00: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-16 22:20:36 +00:00
|
|
|
}
|
2009-05-25 20:25:49 +00:00
|
|
|
|
|
|
|
schedule_delayed_work_on(cpu, &event_scan_work,
|
|
|
|
__round_jiffies_relative(event_scan_delay, cpu));
|
|
|
|
|
2008-01-25 20:08:02 +00:00
|
|
|
put_online_cpus();
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-09-24 19:30:05 +00:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
static void retreive_nvram_error_log(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-09-24 19:30:05 +00:00
|
|
|
unsigned int err_type ;
|
|
|
|
int rc ;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* See if we have any error stored in NVRAM */
|
|
|
|
memset(logdata, 0, rtas_error_log_max);
|
2007-08-09 20:56:41 +00:00
|
|
|
rc = nvram_read_error_log(logdata, rtas_error_log_max,
|
|
|
|
&err_type, &error_log_cnt);
|
2007-10-03 01:19:09 +00:00
|
|
|
/* We can use rtas_log_buf now */
|
|
|
|
logging_enabled = 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!rc) {
|
|
|
|
if (err_type != ERR_FLAG_ALREADY_LOGGED) {
|
|
|
|
pSeries_log_error(logdata, err_type | ERR_FLAG_BOOT, 0);
|
|
|
|
}
|
|
|
|
}
|
2009-09-24 19:30:05 +00:00
|
|
|
}
|
|
|
|
#else /* CONFIG_PPC64 */
|
|
|
|
static void retreive_nvram_error_log(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#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));
|
|
|
|
|
|
|
|
/* Retreive errors from nvram if any */
|
|
|
|
retreive_nvram_error_log();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-04-26 15:32:33 +00:00
|
|
|
schedule_delayed_work_on(cpumask_first(cpu_online_mask),
|
|
|
|
&event_scan_work, event_scan_delay);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init rtas_init(void)
|
|
|
|
{
|
|
|
|
struct proc_dir_entry *entry;
|
|
|
|
|
2009-09-24 19:30:05 +00:00
|
|
|
if (!machine_is(pseries) && !machine_is(chrp))
|
2005-11-10 02:37:51 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* No RTAS */
|
2007-08-09 21:01:50 +00:00
|
|
|
event_scan = rtas_token("event-scan");
|
|
|
|
if (event_scan == RTAS_UNKNOWN_SERVICE) {
|
2009-09-24 19:30:05 +00:00
|
|
|
printk(KERN_INFO "rtasd: No event-scan on system\n");
|
2006-04-02 10:18:32 +00:00
|
|
|
return -ENODEV;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:03:37 +00: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 02:12:32 +00: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-08 20:03:37 +00: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;
|
|
|
|
}
|
|
|
|
|
2009-09-24 19:30:05 +00:00
|
|
|
entry = proc_create("powerpc/rtas/error_log", S_IRUSR, NULL,
|
2008-04-29 08:02:26 +00:00
|
|
|
&proc_rtas_log_operations);
|
|
|
|
if (!entry)
|
2005-04-16 22:20:36 +00:00
|
|
|
printk(KERN_ERR "Failed to create error_log proc entry\n");
|
|
|
|
|
2009-05-25 20:25:49 +00:00
|
|
|
start_event_scan();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-24 19:30:05 +00:00
|
|
|
__initcall(rtas_init);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static int __init surveillance_setup(char *str)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2009-09-24 19:30:05 +00:00
|
|
|
/* We only do surveillance on pseries */
|
|
|
|
if (!machine_is(pseries))
|
|
|
|
return 0;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (get_option(&str,&i)) {
|
|
|
|
if (i >= 0 && i <= 255)
|
|
|
|
surveillance_timeout = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2009-09-24 19:30:05 +00:00
|
|
|
__setup("surveillance=", surveillance_setup);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
__setup("rtasmsgs=", rtasmsgs_setup);
|