License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 17:07:57 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2008-08-28 07:31:01 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 Steven Rostedt <srostedt@redhat.com>
|
|
|
|
*
|
|
|
|
*/
|
2017-02-08 20:51:37 +03:00
|
|
|
#include <linux/sched/task_stack.h>
|
2008-08-28 07:31:01 +04:00
|
|
|
#include <linux/stacktrace.h>
|
|
|
|
#include <linux/kallsyms.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/uaccess.h>
|
|
|
|
#include <linux/ftrace.h>
|
|
|
|
#include <linux/module.h>
|
2008-12-17 07:06:40 +03:00
|
|
|
#include <linux/sysctl.h>
|
2008-08-28 07:31:01 +04:00
|
|
|
#include <linux/init.h>
|
2011-12-20 07:01:00 +04:00
|
|
|
|
|
|
|
#include <asm/setup.h>
|
|
|
|
|
2008-08-28 07:31:01 +04:00
|
|
|
#include "trace.h"
|
|
|
|
|
2008-08-30 00:51:43 +04:00
|
|
|
static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES+1] =
|
|
|
|
{ [0 ... (STACK_TRACE_ENTRIES)] = ULONG_MAX };
|
2015-10-30 08:25:39 +03:00
|
|
|
unsigned stack_trace_index[STACK_TRACE_ENTRIES];
|
2008-08-30 00:51:43 +04:00
|
|
|
|
2013-03-14 07:34:22 +04:00
|
|
|
/*
|
|
|
|
* Reserve one entry for the passed in ip. This will allow
|
|
|
|
* us to remove most or all of the stack size overhead
|
|
|
|
* added by the stack tracer itself.
|
|
|
|
*/
|
2015-10-30 08:25:39 +03:00
|
|
|
struct stack_trace stack_trace_max = {
|
2013-03-14 07:34:22 +04:00
|
|
|
.max_entries = STACK_TRACE_ENTRIES - 1,
|
2015-07-16 20:24:54 +03:00
|
|
|
.entries = &stack_dump_trace[0],
|
2008-08-28 07:31:01 +04:00
|
|
|
};
|
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
unsigned long stack_trace_max_size;
|
2015-11-03 22:50:15 +03:00
|
|
|
arch_spinlock_t stack_trace_max_lock =
|
2009-12-03 14:38:57 +03:00
|
|
|
(arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2017-04-06 22:47:32 +03:00
|
|
|
DEFINE_PER_CPU(int, disable_stack_tracer);
|
2008-12-17 07:06:40 +03:00
|
|
|
static DEFINE_MUTEX(stack_sysctl_mutex);
|
|
|
|
|
|
|
|
int stack_tracer_enabled;
|
|
|
|
static int last_stack_tracer_enabled;
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
void stack_trace_print(void)
|
2014-06-02 08:33:12 +04:00
|
|
|
{
|
|
|
|
long i;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
pr_emerg(" Depth Size Location (%d entries)\n"
|
|
|
|
" ----- ---- --------\n",
|
2015-10-30 08:25:39 +03:00
|
|
|
stack_trace_max.nr_entries);
|
2014-06-02 08:33:12 +04:00
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
for (i = 0; i < stack_trace_max.nr_entries; i++) {
|
2014-06-02 08:33:12 +04:00
|
|
|
if (stack_dump_trace[i] == ULONG_MAX)
|
|
|
|
break;
|
2015-10-30 08:25:39 +03:00
|
|
|
if (i+1 == stack_trace_max.nr_entries ||
|
2014-06-02 08:33:12 +04:00
|
|
|
stack_dump_trace[i+1] == ULONG_MAX)
|
2015-10-30 08:25:39 +03:00
|
|
|
size = stack_trace_index[i];
|
2014-06-02 08:33:12 +04:00
|
|
|
else
|
2015-10-30 08:25:39 +03:00
|
|
|
size = stack_trace_index[i] - stack_trace_index[i+1];
|
2014-06-02 08:33:12 +04:00
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
pr_emerg("%3ld) %8d %5d %pS\n", i, stack_trace_index[i],
|
2014-06-02 08:33:12 +04:00
|
|
|
size, (void *)stack_dump_trace[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
/*
|
2017-03-10 03:16:33 +03:00
|
|
|
* When arch-specific code overrides this function, the following
|
2015-11-03 22:50:15 +03:00
|
|
|
* data should be filled up, assuming stack_trace_max_lock is held to
|
2015-10-30 08:25:39 +03:00
|
|
|
* prevent concurrent updates.
|
|
|
|
* stack_trace_index[]
|
|
|
|
* stack_trace_max
|
|
|
|
* stack_trace_max_size
|
|
|
|
*/
|
|
|
|
void __weak
|
2013-03-14 05:25:35 +04:00
|
|
|
check_stack(unsigned long ip, unsigned long *stack)
|
2008-08-28 07:31:01 +04:00
|
|
|
{
|
2014-06-02 08:33:12 +04:00
|
|
|
unsigned long this_size, flags; unsigned long *p, *top, *start;
|
2013-03-14 07:34:22 +04:00
|
|
|
static int tracer_frame;
|
locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE()
Please do not apply this to mainline directly, instead please re-run the
coccinelle script shown below and apply its output.
For several reasons, it is desirable to use {READ,WRITE}_ONCE() in
preference to ACCESS_ONCE(), and new code is expected to use one of the
former. So far, there's been no reason to change most existing uses of
ACCESS_ONCE(), as these aren't harmful, and changing them results in
churn.
However, for some features, the read/write distinction is critical to
correct operation. To distinguish these cases, separate read/write
accessors must be used. This patch migrates (most) remaining
ACCESS_ONCE() instances to {READ,WRITE}_ONCE(), using the following
coccinelle script:
----
// Convert trivial ACCESS_ONCE() uses to equivalent READ_ONCE() and
// WRITE_ONCE()
// $ make coccicheck COCCI=/home/mark/once.cocci SPFLAGS="--include-headers" MODE=patch
virtual patch
@ depends on patch @
expression E1, E2;
@@
- ACCESS_ONCE(E1) = E2
+ WRITE_ONCE(E1, E2)
@ depends on patch @
expression E;
@@
- ACCESS_ONCE(E)
+ READ_ONCE(E)
----
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: davem@davemloft.net
Cc: linux-arch@vger.kernel.org
Cc: mpe@ellerman.id.au
Cc: shuah@kernel.org
Cc: snitzer@redhat.com
Cc: thor.thayer@linux.intel.com
Cc: tj@kernel.org
Cc: viro@zeniv.linux.org.uk
Cc: will.deacon@arm.com
Link: http://lkml.kernel.org/r/1508792849-3115-19-git-send-email-paulmck@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-10-24 00:07:29 +03:00
|
|
|
int frame_size = READ_ONCE(tracer_frame);
|
2015-07-16 20:24:54 +03:00
|
|
|
int i, x;
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2013-03-14 04:43:57 +04:00
|
|
|
this_size = ((unsigned long)stack) & (THREAD_SIZE-1);
|
2008-08-28 07:31:01 +04:00
|
|
|
this_size = THREAD_SIZE - this_size;
|
2013-03-14 07:34:22 +04:00
|
|
|
/* Remove the frame of the tracer */
|
|
|
|
this_size -= frame_size;
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
if (this_size <= stack_trace_max_size)
|
2008-08-28 07:31:01 +04:00
|
|
|
return;
|
|
|
|
|
2008-10-07 05:24:18 +04:00
|
|
|
/* we do not handle interrupt stacks yet */
|
2013-03-14 04:43:57 +04:00
|
|
|
if (!object_is_on_stack(stack))
|
2008-10-07 05:24:18 +04:00
|
|
|
return;
|
|
|
|
|
2015-10-21 04:48:02 +03:00
|
|
|
/* Can't do this from NMI context (can cause deadlocks) */
|
|
|
|
if (in_nmi())
|
|
|
|
return;
|
|
|
|
|
2008-12-02 23:34:05 +03:00
|
|
|
local_irq_save(flags);
|
2015-11-03 22:50:15 +03:00
|
|
|
arch_spin_lock(&stack_trace_max_lock);
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2013-03-14 07:34:22 +04:00
|
|
|
/* In case another CPU set the tracer_frame on us */
|
|
|
|
if (unlikely(!frame_size))
|
|
|
|
this_size -= tracer_frame;
|
|
|
|
|
2008-08-28 07:31:01 +04:00
|
|
|
/* a race could have already updated it */
|
2015-10-30 08:25:39 +03:00
|
|
|
if (this_size <= stack_trace_max_size)
|
2008-08-28 07:31:01 +04:00
|
|
|
goto out;
|
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
stack_trace_max_size = this_size;
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
stack_trace_max.nr_entries = 0;
|
|
|
|
stack_trace_max.skip = 3;
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
save_stack_trace(&stack_trace_max);
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2015-07-16 20:24:54 +03:00
|
|
|
/* Skip over the overhead of the stack tracer itself */
|
2015-10-30 08:25:39 +03:00
|
|
|
for (i = 0; i < stack_trace_max.nr_entries; i++) {
|
2015-07-16 20:24:54 +03:00
|
|
|
if (stack_dump_trace[i] == ip)
|
|
|
|
break;
|
|
|
|
}
|
2013-03-14 05:25:35 +04:00
|
|
|
|
2016-01-29 18:22:41 +03:00
|
|
|
/*
|
|
|
|
* Some archs may not have the passed in ip in the dump.
|
|
|
|
* If that happens, we need to show everything.
|
|
|
|
*/
|
|
|
|
if (i == stack_trace_max.nr_entries)
|
|
|
|
i = 0;
|
|
|
|
|
2008-08-30 00:51:43 +04:00
|
|
|
/*
|
|
|
|
* Now find where in the stack these are.
|
|
|
|
*/
|
2015-07-16 20:24:54 +03:00
|
|
|
x = 0;
|
2013-03-14 04:43:57 +04:00
|
|
|
start = stack;
|
2008-08-30 00:51:43 +04:00
|
|
|
top = (unsigned long *)
|
|
|
|
(((unsigned long)start & ~(THREAD_SIZE-1)) + THREAD_SIZE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop through all the entries. One of the entries may
|
|
|
|
* for some reason be missed on the stack, so we may
|
|
|
|
* have to account for them. If they are all there, this
|
|
|
|
* loop will only happen once. This code only takes place
|
|
|
|
* on a new max, so it is far from a fast path.
|
|
|
|
*/
|
2015-10-30 08:25:39 +03:00
|
|
|
while (i < stack_trace_max.nr_entries) {
|
2008-12-03 19:04:50 +03:00
|
|
|
int found = 0;
|
2008-08-30 00:51:43 +04:00
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
stack_trace_index[x] = this_size;
|
2008-08-30 00:51:43 +04:00
|
|
|
p = start;
|
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
for (; p < top && i < stack_trace_max.nr_entries; p++) {
|
2015-07-16 20:24:54 +03:00
|
|
|
if (stack_dump_trace[i] == ULONG_MAX)
|
|
|
|
break;
|
2016-02-12 23:46:00 +03:00
|
|
|
/*
|
|
|
|
* The READ_ONCE_NOCHECK is used to let KASAN know that
|
|
|
|
* this is not a stack-out-of-bounds error.
|
|
|
|
*/
|
|
|
|
if ((READ_ONCE_NOCHECK(*p)) == stack_dump_trace[i]) {
|
2015-07-16 20:24:54 +03:00
|
|
|
stack_dump_trace[x] = stack_dump_trace[i++];
|
2015-10-30 08:25:39 +03:00
|
|
|
this_size = stack_trace_index[x++] =
|
2008-08-30 00:51:43 +04:00
|
|
|
(top - p) * sizeof(unsigned long);
|
2008-12-03 19:04:50 +03:00
|
|
|
found = 1;
|
2008-08-30 00:51:43 +04:00
|
|
|
/* Start the search from here */
|
|
|
|
start = p + 1;
|
2013-03-14 07:34:22 +04:00
|
|
|
/*
|
|
|
|
* We do not want to show the overhead
|
|
|
|
* of the stack tracer stack in the
|
|
|
|
* max stack. If we haven't figured
|
|
|
|
* out what that is, then figure it out
|
|
|
|
* now.
|
|
|
|
*/
|
2015-07-16 20:24:54 +03:00
|
|
|
if (unlikely(!tracer_frame)) {
|
2013-03-14 07:34:22 +04:00
|
|
|
tracer_frame = (p - stack) *
|
|
|
|
sizeof(unsigned long);
|
2015-10-30 08:25:39 +03:00
|
|
|
stack_trace_max_size -= tracer_frame;
|
2013-03-14 07:34:22 +04:00
|
|
|
}
|
2008-08-30 00:51:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-03 19:04:50 +03:00
|
|
|
if (!found)
|
|
|
|
i++;
|
2008-08-30 00:51:43 +04:00
|
|
|
}
|
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
stack_trace_max.nr_entries = x;
|
2015-07-16 20:24:54 +03:00
|
|
|
for (; x < i; x++)
|
|
|
|
stack_dump_trace[x] = ULONG_MAX;
|
|
|
|
|
2014-09-12 17:16:18 +04:00
|
|
|
if (task_stack_end_corrupted(current)) {
|
2015-10-30 08:25:39 +03:00
|
|
|
stack_trace_print();
|
2014-06-02 08:33:12 +04:00
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
2008-08-28 07:31:01 +04:00
|
|
|
out:
|
2015-11-03 22:50:15 +03:00
|
|
|
arch_spin_unlock(&stack_trace_max_lock);
|
2008-12-02 23:34:05 +03:00
|
|
|
local_irq_restore(flags);
|
2008-08-28 07:31:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-08-09 20:50:46 +04:00
|
|
|
stack_trace_call(unsigned long ip, unsigned long parent_ip,
|
|
|
|
struct ftrace_ops *op, struct pt_regs *pt_regs)
|
2008-08-28 07:31:01 +04:00
|
|
|
{
|
2013-03-14 04:43:57 +04:00
|
|
|
unsigned long stack;
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2010-06-03 17:36:50 +04:00
|
|
|
preempt_disable_notrace();
|
2008-08-28 07:31:01 +04:00
|
|
|
|
|
|
|
/* no atomic needed, we only modify this variable by this cpu */
|
2017-04-06 22:47:32 +03:00
|
|
|
__this_cpu_inc(disable_stack_tracer);
|
|
|
|
if (__this_cpu_read(disable_stack_tracer) != 1)
|
2008-08-28 07:31:01 +04:00
|
|
|
goto out;
|
|
|
|
|
2017-12-05 12:41:51 +03:00
|
|
|
/* If rcu is not watching, then save stack trace can fail */
|
|
|
|
if (!rcu_is_watching())
|
|
|
|
goto out;
|
|
|
|
|
2015-07-16 20:24:54 +03:00
|
|
|
ip += MCOUNT_INSN_SIZE;
|
2013-03-14 07:34:22 +04:00
|
|
|
|
|
|
|
check_stack(ip, &stack);
|
2008-08-28 07:31:01 +04:00
|
|
|
|
|
|
|
out:
|
2017-04-06 22:47:32 +03:00
|
|
|
__this_cpu_dec(disable_stack_tracer);
|
2008-08-28 07:31:01 +04:00
|
|
|
/* prevent recursion in schedule */
|
2010-06-03 17:36:50 +04:00
|
|
|
preempt_enable_notrace();
|
2008-08-28 07:31:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct ftrace_ops trace_ops __read_mostly =
|
|
|
|
{
|
|
|
|
.func = stack_trace_call,
|
2012-07-20 19:04:44 +04:00
|
|
|
.flags = FTRACE_OPS_FL_RECURSION_SAFE,
|
2008-08-28 07:31:01 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
stack_max_size_read(struct file *filp, char __user *ubuf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
unsigned long *ptr = filp->private_data;
|
|
|
|
char buf[64];
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = snprintf(buf, sizeof(buf), "%ld\n", *ptr);
|
|
|
|
if (r > sizeof(buf))
|
|
|
|
r = sizeof(buf);
|
|
|
|
return simple_read_from_buffer(ubuf, count, ppos, buf, r);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
stack_max_size_write(struct file *filp, const char __user *ubuf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
long *ptr = filp->private_data;
|
|
|
|
unsigned long val, flags;
|
|
|
|
int ret;
|
|
|
|
|
2011-06-07 23:58:27 +04:00
|
|
|
ret = kstrtoul_from_user(ubuf, count, 10, &val);
|
|
|
|
if (ret)
|
2008-08-28 07:31:01 +04:00
|
|
|
return ret;
|
|
|
|
|
2008-12-02 23:34:05 +03:00
|
|
|
local_irq_save(flags);
|
2010-02-02 10:32:09 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* In case we trace inside arch_spin_lock() or after (NMI),
|
|
|
|
* we will cause circular lock, so we also need to increase
|
2017-04-06 22:47:32 +03:00
|
|
|
* the percpu disable_stack_tracer here.
|
2010-02-02 10:32:09 +03:00
|
|
|
*/
|
2017-04-06 22:47:32 +03:00
|
|
|
__this_cpu_inc(disable_stack_tracer);
|
2010-02-02 10:32:09 +03:00
|
|
|
|
2015-11-03 22:50:15 +03:00
|
|
|
arch_spin_lock(&stack_trace_max_lock);
|
2008-08-28 07:31:01 +04:00
|
|
|
*ptr = val;
|
2015-11-03 22:50:15 +03:00
|
|
|
arch_spin_unlock(&stack_trace_max_lock);
|
2010-02-02 10:32:09 +03:00
|
|
|
|
2017-04-06 22:47:32 +03:00
|
|
|
__this_cpu_dec(disable_stack_tracer);
|
2008-12-02 23:34:05 +03:00
|
|
|
local_irq_restore(flags);
|
2008-08-28 07:31:01 +04:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:06:40 +03:00
|
|
|
static const struct file_operations stack_max_size_fops = {
|
2008-08-28 07:31:01 +04:00
|
|
|
.open = tracing_open_generic,
|
|
|
|
.read = stack_max_size_read,
|
|
|
|
.write = stack_max_size_write,
|
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-15 20:52:59 +04:00
|
|
|
.llseek = default_llseek,
|
2008-08-28 07:31:01 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void *
|
2009-08-17 12:53:37 +04:00
|
|
|
__next(struct seq_file *m, loff_t *pos)
|
2008-08-28 07:31:01 +04:00
|
|
|
{
|
2009-08-17 12:53:37 +04:00
|
|
|
long n = *pos - 1;
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
if (n > stack_trace_max.nr_entries || stack_dump_trace[n] == ULONG_MAX)
|
2008-08-28 07:31:01 +04:00
|
|
|
return NULL;
|
|
|
|
|
2009-08-17 12:53:37 +04:00
|
|
|
m->private = (void *)n;
|
2008-08-30 00:51:43 +04:00
|
|
|
return &m->private;
|
2008-08-28 07:31:01 +04:00
|
|
|
}
|
|
|
|
|
2009-08-17 12:53:37 +04:00
|
|
|
static void *
|
|
|
|
t_next(struct seq_file *m, void *v, loff_t *pos)
|
2008-08-28 07:31:01 +04:00
|
|
|
{
|
2009-08-17 12:53:37 +04:00
|
|
|
(*pos)++;
|
|
|
|
return __next(m, pos);
|
|
|
|
}
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2009-08-17 12:53:37 +04:00
|
|
|
static void *t_start(struct seq_file *m, loff_t *pos)
|
|
|
|
{
|
2008-08-28 07:31:01 +04:00
|
|
|
local_irq_disable();
|
2010-02-02 10:32:09 +03:00
|
|
|
|
2017-04-06 22:47:32 +03:00
|
|
|
__this_cpu_inc(disable_stack_tracer);
|
2010-02-02 10:32:09 +03:00
|
|
|
|
2015-11-03 22:50:15 +03:00
|
|
|
arch_spin_lock(&stack_trace_max_lock);
|
2008-08-28 07:31:01 +04:00
|
|
|
|
function tracing: fix wrong position computing of stack_trace
Impact: make output of stack_trace complete if buffer overruns
When read buffer overruns, the output of stack_trace isn't complete.
When printing records with seq_printf in t_show, if the read buffer
has overruned by the current record, then this record won't be
printed to user space through read buffer, it will just be dropped in
this printing.
When next printing, t_start should return the "*pos"th record, which
is the one dropped by previous printing, but it just returns
(m->private + *pos)th record.
Here we use a more sane method to implement seq_operations which can
be found in kernel code. Thus we needn't initialize m->private.
About testing, it's not easy to overrun read buffer, but we can use
seq_printf to print more padding bytes in t_show, then it's easy to
check whether or not records are lost.
This commit has been tested on both condition of overrun and non
overrun.
Signed-off-by: Liming Wang <liming.wang@windriver.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-11-21 06:00:18 +03:00
|
|
|
if (*pos == 0)
|
|
|
|
return SEQ_START_TOKEN;
|
|
|
|
|
2009-08-17 12:53:37 +04:00
|
|
|
return __next(m, pos);
|
2008-08-28 07:31:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void t_stop(struct seq_file *m, void *p)
|
|
|
|
{
|
2015-11-03 22:50:15 +03:00
|
|
|
arch_spin_unlock(&stack_trace_max_lock);
|
2010-02-02 10:32:09 +03:00
|
|
|
|
2017-04-06 22:47:32 +03:00
|
|
|
__this_cpu_dec(disable_stack_tracer);
|
2010-02-02 10:32:09 +03:00
|
|
|
|
2008-08-28 07:31:01 +04:00
|
|
|
local_irq_enable();
|
|
|
|
}
|
|
|
|
|
2015-04-16 02:18:22 +03:00
|
|
|
static void trace_lookup_stack(struct seq_file *m, long i)
|
2008-08-28 07:31:01 +04:00
|
|
|
{
|
2008-08-30 00:51:43 +04:00
|
|
|
unsigned long addr = stack_dump_trace[i];
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2015-04-16 02:18:22 +03:00
|
|
|
seq_printf(m, "%pS\n", (void *)addr);
|
2008-08-28 07:31:01 +04:00
|
|
|
}
|
|
|
|
|
2009-03-13 02:42:29 +03:00
|
|
|
static void print_disabled(struct seq_file *m)
|
|
|
|
{
|
|
|
|
seq_puts(m, "#\n"
|
|
|
|
"# Stack tracer disabled\n"
|
|
|
|
"#\n"
|
|
|
|
"# To enable the stack tracer, either add 'stacktrace' to the\n"
|
|
|
|
"# kernel command line\n"
|
|
|
|
"# or 'echo 1 > /proc/sys/kernel/stack_tracer_enabled'\n"
|
|
|
|
"#\n");
|
|
|
|
}
|
|
|
|
|
2008-08-28 07:31:01 +04:00
|
|
|
static int t_show(struct seq_file *m, void *v)
|
|
|
|
{
|
function tracing: fix wrong position computing of stack_trace
Impact: make output of stack_trace complete if buffer overruns
When read buffer overruns, the output of stack_trace isn't complete.
When printing records with seq_printf in t_show, if the read buffer
has overruned by the current record, then this record won't be
printed to user space through read buffer, it will just be dropped in
this printing.
When next printing, t_start should return the "*pos"th record, which
is the one dropped by previous printing, but it just returns
(m->private + *pos)th record.
Here we use a more sane method to implement seq_operations which can
be found in kernel code. Thus we needn't initialize m->private.
About testing, it's not easy to overrun read buffer, but we can use
seq_printf to print more padding bytes in t_show, then it's easy to
check whether or not records are lost.
This commit has been tested on both condition of overrun and non
overrun.
Signed-off-by: Liming Wang <liming.wang@windriver.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-11-21 06:00:18 +03:00
|
|
|
long i;
|
2008-08-30 00:51:43 +04:00
|
|
|
int size;
|
|
|
|
|
function tracing: fix wrong position computing of stack_trace
Impact: make output of stack_trace complete if buffer overruns
When read buffer overruns, the output of stack_trace isn't complete.
When printing records with seq_printf in t_show, if the read buffer
has overruned by the current record, then this record won't be
printed to user space through read buffer, it will just be dropped in
this printing.
When next printing, t_start should return the "*pos"th record, which
is the one dropped by previous printing, but it just returns
(m->private + *pos)th record.
Here we use a more sane method to implement seq_operations which can
be found in kernel code. Thus we needn't initialize m->private.
About testing, it's not easy to overrun read buffer, but we can use
seq_printf to print more padding bytes in t_show, then it's easy to
check whether or not records are lost.
This commit has been tested on both condition of overrun and non
overrun.
Signed-off-by: Liming Wang <liming.wang@windriver.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-11-21 06:00:18 +03:00
|
|
|
if (v == SEQ_START_TOKEN) {
|
2009-03-13 07:00:58 +03:00
|
|
|
seq_printf(m, " Depth Size Location"
|
2008-08-30 00:51:43 +04:00
|
|
|
" (%d entries)\n"
|
2009-03-13 07:00:58 +03:00
|
|
|
" ----- ---- --------\n",
|
2015-10-30 08:25:39 +03:00
|
|
|
stack_trace_max.nr_entries);
|
2009-03-13 02:42:29 +03:00
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
if (!stack_tracer_enabled && !stack_trace_max_size)
|
2009-03-13 02:42:29 +03:00
|
|
|
print_disabled(m);
|
|
|
|
|
2008-08-30 00:51:43 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2008-08-28 07:31:01 +04:00
|
|
|
|
function tracing: fix wrong position computing of stack_trace
Impact: make output of stack_trace complete if buffer overruns
When read buffer overruns, the output of stack_trace isn't complete.
When printing records with seq_printf in t_show, if the read buffer
has overruned by the current record, then this record won't be
printed to user space through read buffer, it will just be dropped in
this printing.
When next printing, t_start should return the "*pos"th record, which
is the one dropped by previous printing, but it just returns
(m->private + *pos)th record.
Here we use a more sane method to implement seq_operations which can
be found in kernel code. Thus we needn't initialize m->private.
About testing, it's not easy to overrun read buffer, but we can use
seq_printf to print more padding bytes in t_show, then it's easy to
check whether or not records are lost.
This commit has been tested on both condition of overrun and non
overrun.
Signed-off-by: Liming Wang <liming.wang@windriver.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-11-21 06:00:18 +03:00
|
|
|
i = *(long *)v;
|
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
if (i >= stack_trace_max.nr_entries ||
|
2008-08-30 00:51:43 +04:00
|
|
|
stack_dump_trace[i] == ULONG_MAX)
|
2008-08-28 07:31:01 +04:00
|
|
|
return 0;
|
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
if (i+1 == stack_trace_max.nr_entries ||
|
2008-08-30 00:51:43 +04:00
|
|
|
stack_dump_trace[i+1] == ULONG_MAX)
|
2015-10-30 08:25:39 +03:00
|
|
|
size = stack_trace_index[i];
|
2008-08-30 00:51:43 +04:00
|
|
|
else
|
2015-10-30 08:25:39 +03:00
|
|
|
size = stack_trace_index[i] - stack_trace_index[i+1];
|
2008-08-30 00:51:43 +04:00
|
|
|
|
2015-10-30 08:25:39 +03:00
|
|
|
seq_printf(m, "%3ld) %8d %5d ", i, stack_trace_index[i], size);
|
2008-08-30 00:51:43 +04:00
|
|
|
|
|
|
|
trace_lookup_stack(m, i);
|
2008-08-28 07:31:01 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:06:40 +03:00
|
|
|
static const struct seq_operations stack_trace_seq_ops = {
|
2008-08-28 07:31:01 +04:00
|
|
|
.start = t_start,
|
|
|
|
.next = t_next,
|
|
|
|
.stop = t_stop,
|
|
|
|
.show = t_show,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int stack_trace_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2009-07-23 07:28:40 +04:00
|
|
|
return seq_open(file, &stack_trace_seq_ops);
|
2008-08-28 07:31:01 +04:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:06:40 +03:00
|
|
|
static const struct file_operations stack_trace_fops = {
|
2008-08-28 07:31:01 +04:00
|
|
|
.open = stack_trace_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
2009-07-23 07:28:40 +04:00
|
|
|
.release = seq_release,
|
2008-08-28 07:31:01 +04:00
|
|
|
};
|
|
|
|
|
2017-07-12 02:21:04 +03:00
|
|
|
#ifdef CONFIG_DYNAMIC_FTRACE
|
|
|
|
|
2011-12-19 23:44:09 +04:00
|
|
|
static int
|
|
|
|
stack_trace_filter_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2017-06-29 17:05:45 +03:00
|
|
|
struct ftrace_ops *ops = inode->i_private;
|
|
|
|
|
|
|
|
return ftrace_regex_open(ops, FTRACE_ITER_FILTER,
|
2011-12-19 23:44:09 +04:00
|
|
|
inode, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct file_operations stack_trace_filter_fops = {
|
|
|
|
.open = stack_trace_filter_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.write = ftrace_filter_write,
|
2013-12-22 02:39:40 +04:00
|
|
|
.llseek = tracing_lseek,
|
2011-12-19 23:44:09 +04:00
|
|
|
.release = ftrace_regex_release,
|
|
|
|
};
|
|
|
|
|
2017-07-12 02:21:04 +03:00
|
|
|
#endif /* CONFIG_DYNAMIC_FTRACE */
|
|
|
|
|
2008-12-17 07:06:40 +03:00
|
|
|
int
|
|
|
|
stack_trace_sysctl(struct ctl_table *table, int write,
|
2009-09-24 02:57:19 +04:00
|
|
|
void __user *buffer, size_t *lenp,
|
2008-12-17 07:06:40 +03:00
|
|
|
loff_t *ppos)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
mutex_lock(&stack_sysctl_mutex);
|
|
|
|
|
2009-09-24 02:57:19 +04:00
|
|
|
ret = proc_dointvec(table, write, buffer, lenp, ppos);
|
2008-12-17 07:06:40 +03:00
|
|
|
|
|
|
|
if (ret || !write ||
|
2009-06-26 12:55:51 +04:00
|
|
|
(last_stack_tracer_enabled == !!stack_tracer_enabled))
|
2008-12-17 07:06:40 +03:00
|
|
|
goto out;
|
|
|
|
|
2009-06-26 12:55:51 +04:00
|
|
|
last_stack_tracer_enabled = !!stack_tracer_enabled;
|
2008-12-17 07:06:40 +03:00
|
|
|
|
|
|
|
if (stack_tracer_enabled)
|
|
|
|
register_ftrace_function(&trace_ops);
|
|
|
|
else
|
|
|
|
unregister_ftrace_function(&trace_ops);
|
|
|
|
|
|
|
|
out:
|
|
|
|
mutex_unlock(&stack_sysctl_mutex);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-12-20 07:01:00 +04:00
|
|
|
static char stack_trace_filter_buf[COMMAND_LINE_SIZE+1] __initdata;
|
|
|
|
|
2008-12-17 07:06:40 +03:00
|
|
|
static __init int enable_stacktrace(char *str)
|
|
|
|
{
|
2011-12-20 07:01:00 +04:00
|
|
|
if (strncmp(str, "_filter=", 8) == 0)
|
|
|
|
strncpy(stack_trace_filter_buf, str+8, COMMAND_LINE_SIZE);
|
|
|
|
|
2008-12-17 17:43:00 +03:00
|
|
|
stack_tracer_enabled = 1;
|
|
|
|
last_stack_tracer_enabled = 1;
|
2008-12-17 07:06:40 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("stacktrace", enable_stacktrace);
|
|
|
|
|
2008-08-28 07:31:01 +04:00
|
|
|
static __init int stack_trace_init(void)
|
|
|
|
{
|
|
|
|
struct dentry *d_tracer;
|
|
|
|
|
|
|
|
d_tracer = tracing_init_dentry();
|
2015-01-20 19:14:16 +03:00
|
|
|
if (IS_ERR(d_tracer))
|
2013-04-10 04:18:12 +04:00
|
|
|
return 0;
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2009-03-27 02:25:38 +03:00
|
|
|
trace_create_file("stack_max_size", 0644, d_tracer,
|
2015-10-30 08:25:39 +03:00
|
|
|
&stack_trace_max_size, &stack_max_size_fops);
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2009-03-27 02:25:38 +03:00
|
|
|
trace_create_file("stack_trace", 0444, d_tracer,
|
|
|
|
NULL, &stack_trace_fops);
|
2008-08-28 07:31:01 +04:00
|
|
|
|
2017-07-12 02:21:04 +03:00
|
|
|
#ifdef CONFIG_DYNAMIC_FTRACE
|
2018-02-08 04:41:53 +03:00
|
|
|
trace_create_file("stack_trace_filter", 0644, d_tracer,
|
2017-06-29 17:05:45 +03:00
|
|
|
&trace_ops, &stack_trace_filter_fops);
|
2017-07-12 02:21:04 +03:00
|
|
|
#endif
|
2011-12-19 23:44:09 +04:00
|
|
|
|
2011-12-20 07:01:00 +04:00
|
|
|
if (stack_trace_filter_buf[0])
|
|
|
|
ftrace_set_early_filter(&trace_ops, stack_trace_filter_buf, 1);
|
|
|
|
|
2008-12-17 17:43:00 +03:00
|
|
|
if (stack_tracer_enabled)
|
2008-12-17 07:06:40 +03:00
|
|
|
register_ftrace_function(&trace_ops);
|
2008-08-28 07:31:01 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
device_initcall(stack_trace_init);
|