Skip to content
Snippets Groups Projects
Select Git revision
  • 1b6cced6ec9677fa65471e890dfdcb4bf5387643
  • linus-master default
  • kunit_is_love
  • kunit_drm
  • tonyk/futex_waitv
  • hidraw_rwlock
  • futex_waitv
  • futex2-dev
  • idle_sleep
  • futex2-proton
  • futex-tests
  • futex2
  • futex2-numa
  • fwm-5.11
  • cf-fix
  • tmpfs-ic
  • futex2-stable-5.11
  • futex2-stable
  • futex2-lpc
  • gaming
  • futex-fixes
21 results

trace_stack.c

Blame
  • trace_stack.c 6.40 KiB
    /*
     * Copyright (C) 2008 Steven Rostedt <srostedt@redhat.com>
     *
     */
    #include <linux/stacktrace.h>
    #include <linux/kallsyms.h>
    #include <linux/seq_file.h>
    #include <linux/spinlock.h>
    #include <linux/uaccess.h>
    #include <linux/debugfs.h>
    #include <linux/ftrace.h>
    #include <linux/module.h>
    #include <linux/init.h>
    #include <linux/fs.h>
    #include "trace.h"
    
    #define STACK_TRACE_ENTRIES 500
    
    static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES+1] =
    	 { [0 ... (STACK_TRACE_ENTRIES)] = ULONG_MAX };
    static unsigned stack_dump_index[STACK_TRACE_ENTRIES];
    
    static struct stack_trace max_stack_trace = {
    	.max_entries		= STACK_TRACE_ENTRIES,
    	.entries		= stack_dump_trace,
    };
    
    static unsigned long max_stack_size;
    static raw_spinlock_t max_stack_lock =
    	(raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
    
    static int stack_trace_disabled __read_mostly;
    static DEFINE_PER_CPU(int, trace_active);
    
    static inline void check_stack(void)
    {
    	unsigned long this_size, flags;
    	unsigned long *p, *top, *start;
    	int i;
    
    	this_size = ((unsigned long)&this_size) & (THREAD_SIZE-1);
    	this_size = THREAD_SIZE - this_size;
    
    	if (this_size <= max_stack_size)
    		return;
    
    	raw_local_irq_save(flags);
    	__raw_spin_lock(&max_stack_lock);
    
    	/* a race could have already updated it */
    	if (this_size <= max_stack_size)
    		goto out;
    
    	max_stack_size = this_size;
    
    	max_stack_trace.nr_entries	= 0;
    	max_stack_trace.skip		= 3;
    
    	save_stack_trace(&max_stack_trace);
    
    	/*
    	 * Now find where in the stack these are.
    	 */
    	i = 0;
    	start = &this_size;
    	top = (unsigned long *)
    		(((unsigned long)start & ~(THREAD_SIZE-1)) + THREAD_SIZE);
    
    	/*
    	 * Loop through all the entries. One of the entries may