linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com,
	akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
	josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org,
	rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com,
	fweisbec@gmail.com, oleg@redhat.com,
	Wanpeng Li <wanpeng.li@hotmail.com>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	Rik van Riel <riel@redhat.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH tip/core/rcu 5/5] EXP: sched/cputime: Fix using smp_processor_id() in preemptible
Date: Mon, 24 Jul 2017 14:58:17 -0700	[thread overview]
Message-ID: <1500933497-12612-5-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170724215758.GA12075@linux.vnet.ibm.com>

From: Wanpeng Li <wanpeng.li@hotmail.com>

 BUG: using smp_processor_id() in preemptible [00000000] code: 99-trinity/181
 caller is debug_smp_processor_id+0x17/0x19
 CPU: 0 PID: 181 Comm: 99-trinity Not tainted 4.12.0-01059-g2a42eb9 #1
 Call Trace:
  dump_stack+0x82/0xb8
  check_preemption_disabled+0xd1/0xe3
  debug_smp_processor_id+0x17/0x19
  vtime_delta+0xd/0x2c
  task_cputime+0x89/0xdb
  thread_group_cputime+0x11b/0x1ed
  thread_group_cputime_adjusted+0x1f/0x47
  wait_consider_task+0x2a9/0xaf9
  ? lock_acquire+0x97/0xa4
  do_wait+0xdf/0x1f4
  SYSC_wait4+0x8e/0xb5
  ? list_add+0x34/0x34
  SyS_wait4+0x9/0xb
  do_syscall_64+0x70/0x82
  entry_SYSCALL64_slow_path+0x25/0x25

As Frederic pointed out:

| Although those sched_clock_cpu() things seem to only matter when the
| sched_clock() is unstable. And that stability is a condition for nohz_full
| to work anyway. So probably sched_clock() alone would be enough.

This patch fixes it by replacing sched_clock_cpu() in vtime_delta() by
sched_clock() to avoid to call smp_processor_id() in preemptible context.

Reported-by: Xiaolong Ye <xiaolong.ye@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/sched/cputime.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 6e3ea4ac1bda..14d2dbf97c53 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -683,7 +683,7 @@ static u64 vtime_delta(struct vtime *vtime)
 {
 	unsigned long long clock;
 
-	clock = sched_clock_cpu(smp_processor_id());
+	clock = sched_clock();
 	if (clock < vtime->starttime)
 		return 0;
 
@@ -814,7 +814,7 @@ void arch_vtime_task_switch(struct task_struct *prev)
 
 	write_seqcount_begin(&vtime->seqcount);
 	vtime->state = VTIME_SYS;
-	vtime->starttime = sched_clock_cpu(smp_processor_id());
+	vtime->starttime = sched_clock();
 	write_seqcount_end(&vtime->seqcount);
 }
 
@@ -826,7 +826,7 @@ void vtime_init_idle(struct task_struct *t, int cpu)
 	local_irq_save(flags);
 	write_seqcount_begin(&vtime->seqcount);
 	vtime->state = VTIME_SYS;
-	vtime->starttime = sched_clock_cpu(cpu);
+	vtime->starttime = sched_clock();
 	write_seqcount_end(&vtime->seqcount);
 	local_irq_restore(flags);
 }
-- 
2.5.2

  parent reply	other threads:[~2017-07-24 21:58 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24 21:57 [PATCH tip/core/rcu 0/5] Related non-RCU updates Paul E. McKenney
2017-07-24 21:58 ` [PATCH tip/core/rcu 1/5] module: Fix pr_fmt() bug for header use of printk Paul E. McKenney
2017-07-24 21:58 ` [PATCH tip/core/rcu 2/5] init_task: Remove redundant INIT_TASK_RCU_TREE_PREEMPT() macro Paul E. McKenney
2017-07-24 21:58 ` [PATCH tip/core/rcu 3/5] EXPERIMENTAL sched: Allow migrating kthreads into online but inactive CPUs Paul E. McKenney
2017-07-24 21:58 ` [PATCH tip/core/rcu 4/5] sys_membarrier: Add expedited option Paul E. McKenney
2017-07-25  4:27   ` Boqun Feng
2017-07-25 16:24     ` Paul E. McKenney
2017-07-25 13:21   ` Mathieu Desnoyers
2017-07-25 16:48     ` Paul E. McKenney
2017-07-25 16:33   ` Peter Zijlstra
2017-07-25 16:49     ` Paul E. McKenney
2017-07-25 16:59       ` Peter Zijlstra
2017-07-25 17:17         ` Paul E. McKenney
2017-07-25 18:53           ` Peter Zijlstra
2017-07-25 19:36             ` Paul E. McKenney
2017-07-25 20:24               ` Peter Zijlstra
2017-07-25 21:19                 ` Paul E. McKenney
2017-07-25 21:55                   ` Peter Zijlstra
2017-07-25 22:39                     ` Mathieu Desnoyers
2017-07-25 22:50                     ` Mathieu Desnoyers
2017-07-26  0:01                       ` Paul E. McKenney
2017-07-26  7:46                       ` Peter Zijlstra
2017-07-26 15:42                         ` Paul E. McKenney
2017-07-26 18:01                           ` Mathieu Desnoyers
2017-07-26 18:30                             ` Paul E. McKenney
2017-07-26 20:37                               ` Mathieu Desnoyers
2017-07-26 21:11                                 ` Paul E. McKenney
2017-07-27  1:45                                   ` Paul E. McKenney
2017-07-27 12:39                                     ` Mathieu Desnoyers
2017-07-27 14:44                                       ` Paul E. McKenney
2017-07-27 10:24                               ` Peter Zijlstra
2017-07-27 14:52                                 ` Paul E. McKenney
2017-07-27  8:53                             ` Peter Zijlstra
2017-07-27 10:09                               ` Peter Zijlstra
2017-07-27 10:22                               ` Will Deacon
2017-07-27 13:14                               ` Paul E. McKenney
2017-07-25 23:59                     ` Paul E. McKenney
2017-07-26  7:41                       ` Peter Zijlstra
2017-07-26 15:41                         ` Paul E. McKenney
2017-07-27  8:30                           ` Peter Zijlstra
2017-07-27 13:08                             ` Paul E. McKenney
2017-07-27 13:49                               ` Peter Zijlstra
2017-07-27 14:32                                 ` Paul E. McKenney
2017-07-27 14:36                                   ` Peter Zijlstra
2017-07-27 14:46                                     ` Paul E. McKenney
2017-07-27 13:55                               ` Boqun Feng
2017-07-27 14:16                                 ` Paul E. McKenney
2017-07-27 14:29                                   ` Boqun Feng
2017-07-27 14:36                                     ` Paul E. McKenney
2017-07-27 14:41                                       ` Will Deacon
2017-07-27 14:47                                       ` Boqun Feng
2017-07-27 14:55                                         ` Paul E. McKenney
2017-07-27 13:56                               ` Peter Zijlstra
2017-07-27 15:19                                 ` Peter Zijlstra
2017-07-26  9:36                   ` Will Deacon
2017-07-26 15:46                     ` Paul E. McKenney
2017-07-27 10:14               ` Peter Zijlstra
2017-07-27 12:56                 ` Paul E. McKenney
2017-07-27 13:37                   ` Peter Zijlstra
2017-07-27 14:33                     ` Paul E. McKenney
2017-07-24 21:58 ` Paul E. McKenney [this message]
2017-07-24 22:01   ` [PATCH tip/core/rcu 5/5] EXP: sched/cputime: Fix using smp_processor_id() in preemptible Wanpeng Li
2017-07-24 22:29     ` Paul E. McKenney
2017-07-31 22:51 ` [PATCH tip/core/rcu 0/5] Related non-RCU updates Paul E. McKenney
2017-07-31 22:53   ` [PATCH v2 tip/core/rcu 1/4] module: Fix pr_fmt() bug for header use of printk Paul E. McKenney
2017-07-31 22:53   ` [PATCH v2 tip/core/rcu 2/4] init_task: Remove redundant INIT_TASK_RCU_TREE_PREEMPT() macro Paul E. McKenney
2017-07-31 22:53   ` [PATCH v2 tip/core/rcu 3/4] sched: Allow migrating kthreads into online but inactive CPUs Paul E. McKenney
2017-07-31 22:53   ` [PATCH v2 tip/core/rcu 4/4] membarrier: Expedited private command Paul E. McKenney

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=1500933497-12612-5-git-send-email-paulmck@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=edumazet@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=lcapitulino@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=wanpeng.li@hotmail.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).