LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Miller <davem@davemloft.net>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Steven Rostedt <srostedt@redhat.com>
Subject: Re: [PATCH 2/2] ftrace: release functions from hash
Date: Tue, 21 Oct 2008 14:27:55 -0400 (EDT)	[thread overview]
Message-ID: <alpine.DEB.1.10.0810211427150.7143@gandalf.stny.rr.com> (raw)
In-Reply-To: <20081021164302.575069241@goodmis.org>



Ingo,

I found a bug with this patch. Do not incorporate it. I'll come up
with a new patch to replace this one.

Thanks,

-- Steve

On Tue, 21 Oct 2008, Steven Rostedt wrote:

> The x86 architecture uses a static recording of mcount caller locations
> and is not affected by this patch.
> 
> For architectures still using the dynamic ftrace daemon, this patch is
> critical. It removes the race between the recording of a function that
> calls mcount, the unloading of a module, and the ftrace daemon updating
> the call sites.
> 
> This patch adds the releasing of the hash functions that the daemon uses
> to update the mcount call sites. When a module is unloaded, not only
> are the replaced call site table update, but now so is the hash recorded
> functions that the ftrace daemon will use.
> 
> Again, architectures that implement MCOUNT_RECORD are not affected by
> this (which currently only x86 has).
> 
> Signed-off-by: Steven Rostedt <srostedt@redhat.com>
> ---
>  kernel/trace/ftrace.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> Index: linux-compile.git/kernel/trace/ftrace.c
> ===================================================================
> --- linux-compile.git.orig/kernel/trace/ftrace.c	2008-10-21 09:34:51.000000000 -0400
> +++ linux-compile.git/kernel/trace/ftrace.c	2008-10-21 10:31:24.000000000 -0400
> @@ -164,10 +164,14 @@ static DEFINE_SPINLOCK(ftrace_hash_lock)
>  #define ftrace_hash_lock(flags)	  spin_lock_irqsave(&ftrace_hash_lock, flags)
>  #define ftrace_hash_unlock(flags) \
>  			spin_unlock_irqrestore(&ftrace_hash_lock, flags)
> +static void ftrace_release_hash(unsigned long start, unsigned long end);
>  #else
>  /* This is protected via the ftrace_lock with MCOUNT_RECORD. */
>  #define ftrace_hash_lock(flags)   do { (void)(flags); } while (0)
>  #define ftrace_hash_unlock(flags) do { } while(0)
> +static inline void ftrace_release_hash(unsigned long start, unsigned long end)
> +{
> +}
>  #endif
>  
>  /*
> @@ -354,6 +358,8 @@ void ftrace_release(void *start, unsigne
>  		}
>  	}
>  	spin_unlock(&ftrace_lock);
> +
> +	ftrace_release_hash(s, e);
>  }
>  
>  static struct dyn_ftrace *ftrace_alloc_dyn_node(unsigned long ip)
> @@ -1686,6 +1692,44 @@ void __init ftrace_init(void)
>  	ftrace_disabled = 1;
>  }
>  #else /* CONFIG_FTRACE_MCOUNT_RECORD */
> +
> +static void ftrace_release_hash(unsigned long start, unsigned long end)
> +{
> +	struct dyn_ftrace *rec;
> +	struct hlist_node *t, *n;
> +	struct hlist_head *head, temp_list;
> +	unsigned long flags;
> +	int i, cpu;
> +
> +	preempt_disable_notrace();
> +
> +	/* disable incase we call something that calls mcount */
> +	cpu = raw_smp_processor_id();
> +	per_cpu(ftrace_shutdown_disable_cpu, cpu)++;
> +
> +	ftrace_hash_lock(flags);
> +
> +	for (i = 0; i < FTRACE_HASHSIZE; i++) {
> +		INIT_HLIST_HEAD(&temp_list);
> +		head = &ftrace_hash[i];
> +
> +		/* all CPUS are stopped, we are safe to modify code */
> +		hlist_for_each_entry_safe(rec, t, n, head, node) {
> +			if (rec->flags & FTRACE_FL_FREE)
> +				continue;
> +
> +			if ((rec->ip >= start) && (rec->ip < end))
> +				ftrace_free_rec(rec);
> +		}
> +	}
> +
> +	ftrace_hash_unlock(flags);
> +
> +	per_cpu(ftrace_shutdown_disable_cpu, cpu)--;
> +	preempt_enable_notrace();
> +
> +}
> +
>  static int ftraced(void *ignore)
>  {
>  	unsigned long usecs;
> 
> -- 
> 
> 

      reply	other threads:[~2008-10-21 18:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-21 16:40 [PATCH 0/2] ftrace: clean ups and sanity checks Steven Rostedt
2008-10-21 16:40 ` [PATCH 1/2] ftrace: make dynamic ftrace more robust Steven Rostedt
2008-10-22  6:53   ` Ingo Molnar
2008-10-22 11:07     ` Steven Rostedt
2008-10-22 11:28       ` Steven Rostedt
2008-10-22 11:47       ` Ingo Molnar
2008-10-22 12:07         ` Steven Rostedt
2008-10-21 16:40 ` [PATCH 2/2] ftrace: release functions from hash Steven Rostedt
2008-10-21 18:27   ` Steven Rostedt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.1.10.0810211427150.7143@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=srostedt@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --subject='Re: [PATCH 2/2] ftrace: release functions from hash' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).