2019-05-27 14:55:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
|
|
|
|
*
|
|
|
|
* 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";
|
2018-10-15 07:18:27 +08:00
|
|
|
case RTAS_TYPE_HOTPLUG:
|
|
|
|
return "Hotplug 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;
|
|
|
|
|
2018-10-10 13:23:02 +08:00
|
|
|
printk(RTAS_DEBUG "event: %d, Type: %s (%d), Severity: %d\n",
|
|
|
|
error_log_cnt,
|
|
|
|
rtas_event_type(rtas_error_type(errlog)),
|
|
|
|
rtas_error_type(errlog),
|
2014-04-04 15:35:13 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static void handle_rtas_event(const struct rtas_error_log *log)
|
|
|
|
{
|
2020-06-12 13:12:32 +08:00
|
|
|
if (!machine_is(pseries))
|
2014-04-04 15:35:13 +08:00
|
|
|
return;
|
2013-04-24 13:51:33 +08:00
|
|
|
|
2020-06-12 13:12:32 +08:00
|
|
|
if (rtas_error_type(log) == RTAS_TYPE_PRRN)
|
|
|
|
pr_info_ratelimited("Platform resource reassignment ignored.\n");
|
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;
|
|
|
|
|
Remove 'type' argument from access_ok() function
Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument
of the user address range verification function since we got rid of the
old racy i386-only code to walk page tables by hand.
It existed because the original 80386 would not honor the write protect
bit when in kernel mode, so you had to do COW by hand before doing any
user access. But we haven't supported that in a long time, and these
days the 'type' argument is a purely historical artifact.
A discussion about extending 'user_access_begin()' to do the range
checking resulted this patch, because there is no way we're going to
move the old VERIFY_xyz interface to that model. And it's best done at
the end of the merge window when I've done most of my merges, so let's
just get this done once and for all.
This patch was mostly done with a sed-script, with manual fix-ups for
the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form.
There were a couple of notable cases:
- csky still had the old "verify_area()" name as an alias.
- the iter_iov code had magical hardcoded knowledge of the actual
values of VERIFY_{READ,WRITE} (not that they mattered, since nothing
really used it)
- microblaze used the type argument for a debug printout
but other than those oddities this should be a total no-op patch.
I tried to fix up all architectures, did fairly extensive grepping for
access_ok() uses, and the changes are trivial, but I may have missed
something. Any missed conversion should be trivially fixable, though.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-01-04 10:57:57 +08:00
|
|
|
if (!access_ok(buf, count))
|
2005-04-17 06:20:36 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-07-03 10:33:19 +08:00
|
|
|
static __poll_t rtas_log_poll(struct file *file, poll_table * wait)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
poll_wait(file, &rtas_log_wait, wait);
|
|
|
|
if (rtas_log_size)
|
2018-02-12 06:34:03 +08:00
|
|
|
return EPOLLIN | EPOLLRDNORM;
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-02-04 09:37:17 +08:00
|
|
|
static const struct proc_ops rtas_log_proc_ops = {
|
|
|
|
.proc_read = rtas_log_read,
|
|
|
|
.proc_poll = rtas_log_poll,
|
|
|
|
.proc_open = rtas_log_open,
|
|
|
|
.proc_release = rtas_log_release,
|
|
|
|
.proc_lseek = 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);
|
|
|
|
|
treewide: Use array_size() in vmalloc()
The vmalloc() function has no 2-factor argument form, so multiplication
factors need to be wrapped in array_size(). This patch replaces cases of:
vmalloc(a * b)
with:
vmalloc(array_size(a, b))
as well as handling cases of:
vmalloc(a * b * c)
with:
vmalloc(array3_size(a, b, c))
This does, however, attempt to ignore constant size factors like:
vmalloc(4 * 1024)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
vmalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
vmalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
vmalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
vmalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
vmalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
vmalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
vmalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
vmalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
vmalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
vmalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
vmalloc(
- sizeof(TYPE) * (COUNT_ID)
+ array_size(COUNT_ID, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(TYPE) * COUNT_ID
+ array_size(COUNT_ID, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(TYPE) * (COUNT_CONST)
+ array_size(COUNT_CONST, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(TYPE) * COUNT_CONST
+ array_size(COUNT_CONST, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(THING) * (COUNT_ID)
+ array_size(COUNT_ID, sizeof(THING))
, ...)
|
vmalloc(
- sizeof(THING) * COUNT_ID
+ array_size(COUNT_ID, sizeof(THING))
, ...)
|
vmalloc(
- sizeof(THING) * (COUNT_CONST)
+ array_size(COUNT_CONST, sizeof(THING))
, ...)
|
vmalloc(
- sizeof(THING) * COUNT_CONST
+ array_size(COUNT_CONST, sizeof(THING))
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
vmalloc(
- SIZE * COUNT
+ array_size(COUNT, SIZE)
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
vmalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
vmalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
vmalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
vmalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
vmalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
vmalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
vmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
vmalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
vmalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
vmalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
vmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
vmalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
vmalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
vmalloc(C1 * C2 * C3, ...)
|
vmalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants.
@@
expression E1, E2;
constant C1, C2;
@@
(
vmalloc(C1 * C2, ...)
|
vmalloc(
- E1 * E2
+ array_size(E1, E2)
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-13 05:27:11 +08:00
|
|
|
rtas_log_buf = vmalloc(array_size(LOG_NUMBER,
|
|
|
|
rtas_error_log_buffer_max));
|
2007-08-09 04:03:37 +08:00
|
|
|
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;
|
|
|
|
|
2017-01-12 11:54:13 +08:00
|
|
|
entry = proc_create("powerpc/rtas/error_log", 0400, NULL,
|
2020-02-04 09:37:17 +08:00
|
|
|
&rtas_log_proc_ops);
|
2008-04-29 16:02:26 +08:00
|
|
|
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);
|