linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	Michael Wang <yun.wang@linux.alibaba.com>
Subject: linux-next: manual merge of the ftrace tree with Linus' tree
Date: Thu, 28 Oct 2021 16:31:11 +1100	[thread overview]
Message-ID: <20211028163111.7f09f7eb@canb.auug.org.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 3288 bytes --]

Hi all,

Today's linux-next merge of the ftrace tree got conflicts in:

  include/linux/trace_recursion.h
  kernel/trace/ftrace.c

between commit:

  ed65df63a39a ("tracing: Have all levels of checks prevent recursion")

from Linus' tree and commit:

  ce5e48036c9e ("ftrace: disable preemption when recursion locked")

from the ftrace tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc include/linux/trace_recursion.h
index fe95f0922526,a13f23b04d73..000000000000
--- a/include/linux/trace_recursion.h
+++ b/include/linux/trace_recursion.h
@@@ -139,8 -155,11 +135,11 @@@ extern void ftrace_record_recursion(uns
  # define do_ftrace_record_recursion(ip, pip)	do { } while (0)
  #endif
  
+ /*
+  * Preemption is promised to be disabled when return bit >= 0.
+  */
  static __always_inline int trace_test_and_set_recursion(unsigned long ip, unsigned long pip,
 -							int start, int max)
 +							int start)
  {
  	unsigned int val = READ_ONCE(current->trace_recursion);
  	int bit;
@@@ -148,10 -167,18 +147,14 @@@
  	bit = trace_get_context_bit() + start;
  	if (unlikely(val & (1 << bit))) {
  		/*
- 		 * It could be that preempt_count has not been updated during
- 		 * a switch between contexts. Allow for a single recursion.
+ 		 * If an interrupt occurs during a trace, and another trace
+ 		 * happens in that interrupt but before the preempt_count is
+ 		 * updated to reflect the new interrupt context, then this
+ 		 * will think a recursion occurred, and the event will be dropped.
+ 		 * Let a single instance happen via the TRANSITION_BIT to
+ 		 * not drop those events.
  		 */
 -		bit = TRACE_TRANSITION_BIT;
 +		bit = TRACE_CTX_TRANSITION + start;
  		if (val & (1 << bit)) {
  			do_ftrace_record_recursion(ip, pip);
  			return -1;
@@@ -162,12 -192,22 +165,18 @@@
  	current->trace_recursion = val;
  	barrier();
  
+ 	preempt_disable_notrace();
+ 
 -	return bit + 1;
 +	return bit;
  }
  
+ /*
+  * Preemption will be enabled (if it was previously enabled).
+  */
  static __always_inline void trace_clear_recursion(int bit)
  {
 -	if (!bit)
 -		return;
 -
+ 	preempt_enable_notrace();
  	barrier();
 -	bit--;
  	trace_recursion_clear(bit);
  }
  
diff --cc kernel/trace/ftrace.c
index 635fbdc9d589,b4ed1a301232..000000000000
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@@ -6977,7 -7198,12 +7198,12 @@@ __ftrace_ops_list_func(unsigned long ip
  	struct ftrace_ops *op;
  	int bit;
  
+ 	/*
+ 	 * The ftrace_test_and_set_recursion() will disable preemption,
+ 	 * which is required since some of the ops may be dynamically
+ 	 * allocated, they must be freed after a synchronize_rcu().
+ 	 */
 -	bit = trace_test_and_set_recursion(ip, parent_ip, TRACE_LIST_START, TRACE_LIST_MAX);
 +	bit = trace_test_and_set_recursion(ip, parent_ip, TRACE_LIST_START);
  	if (bit < 0)
  		return;
  

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2021-10-28  5:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28  5:31 Stephen Rothwell [this message]
2021-10-28 13:14 ` linux-next: manual merge of the ftrace tree with Linus' tree Steven Rostedt
  -- strict thread matches above, loose matches on Subject: below --
2023-08-28  1:59 Stephen Rothwell
2023-04-11  2:46 Stephen Rothwell
2023-04-11  3:01 ` Steven Rostedt
2021-09-15  0:44 Stephen Rothwell
2021-09-15  0:47 ` Steven Rostedt
2021-02-15  4:03 Stephen Rothwell
2020-12-08  5:02 Stephen Rothwell
2020-12-14 20:37 ` Stephen Rothwell
2020-12-14 21:33   ` Steven Rostedt
2019-05-16  1:05 Stephen Rothwell
2019-05-16  1:53 ` Steven Rostedt
2019-05-16  3:32   ` Stephen Rothwell
2019-05-16  1:00 Stephen Rothwell
2018-08-15  4:04 Stephen Rothwell
2015-11-05  2:51 Stephen Rothwell
2015-11-05  3:20 ` Steven Rostedt
2013-07-10  3:51 Stephen Rothwell
2013-04-22  5:55 Stephen Rothwell
2013-04-09  6:30 Stephen Rothwell
2013-03-18  2:00 Stephen Rothwell
2013-03-18 13:26 ` Steven Rostedt

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=20211028163111.7f09f7eb@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=yun.wang@linux.alibaba.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).