From patchwork Mon Apr 23 16:16:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 8060 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0C23F23E4C for ; Mon, 23 Apr 2012 19:01:42 +0000 (UTC) Received: from mail-gy0-f180.google.com (mail-gy0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 8F361A1842A for ; Mon, 23 Apr 2012 19:01:41 +0000 (UTC) Received: by ghbz12 with SMTP id z12so7918939ghb.11 for ; Mon, 23 Apr 2012 12:01:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-content-scanned:x-cbid:x-gm-message-state; bh=v4bkaZaFtg9du3oIgTW5xis5UUzvjPN68evotoq6NEQ=; b=ZCvJn9l131WXF3+fm5ZfQ7EMxhhdT9VfCF9vQDvBeX01KaQulGkSfEIXoxzOLsLkFL 3roQWJ3lZXF3PrwxrAViYh4E2od5/08SMtWzSDmZ0zyEbrKHTsVCuuJSBPrwPqu9Q0/W pQIWaIe7o/JL7qmnI1SmvXjEpKTyuu3t5S/PcBmphSX0MEJAKhgAuFqkoSqP2m7bPxE6 mIaRQqAKRozgZOmTh2odEWflpBUdCrgRskSkIVw9qaJg0XuQUfwC9zZKApAACZJMULfl gwhwf11+2SbMSeXrKopI7NFXaqRsmzasmfdwOX4Mmntt0kir+3r4Guzg26eu2x7EQIu7 tEsg== Received: by 10.50.185.233 with SMTP id ff9mr7491371igc.55.1335207700799; Mon, 23 Apr 2012 12:01:40 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.137.198 with SMTP id x6csp133201ibt; Mon, 23 Apr 2012 12:01:40 -0700 (PDT) Received: by 10.60.14.4 with SMTP id l4mr587995oec.39.1335207699903; Mon, 23 Apr 2012 12:01:39 -0700 (PDT) Received: from e37.co.us.ibm.com (e37.co.us.ibm.com. [32.97.110.158]) by mx.google.com with ESMTPS id p9si8963474obv.94.2012.04.23.12.01.39 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Apr 2012 12:01:39 -0700 (PDT) Received-SPF: pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.110.158 as permitted sender) client-ip=32.97.110.158; Authentication-Results: mx.google.com; spf=pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.110.158 as permitted sender) smtp.mail=paulmck@linux.vnet.ibm.com Received: from /spool/local by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Apr 2012 13:01:39 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 23 Apr 2012 13:01:12 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id BD89AC40004; Mon, 23 Apr 2012 13:01:08 -0600 (MDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q3NIgZfP212030; Mon, 23 Apr 2012 13:01:04 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q3NGG6Oa011489; Mon, 23 Apr 2012 10:16:09 -0600 Received: from paulmck-ThinkPad-W500 ([9.47.24.152]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q3NGG3V4011185; Mon, 23 Apr 2012 10:16:04 -0600 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id 632FFE5278; Mon, 23 Apr 2012 09:16:03 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: mingo@elte.hu, laijs@cn.fujitsu.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca, josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, Valdis.Kletnieks@vt.edu, dhowells@redhat.com, eric.dumazet@gmail.com, darren@dvhart.com, fweisbec@gmail.com, patches@linaro.org, "Paul E. McKenney" , "Paul E. McKenney" Subject: [PATCH RFC tip/core/rcu 4/4] rcu: Ensure that RCU_FAST_NO_HZ timers expire on correct CPU Date: Mon, 23 Apr 2012 09:16:01 -0700 Message-Id: <1335197761-6577-4-git-send-email-paulmck@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1335197761-6577-1-git-send-email-paulmck@linux.vnet.ibm.com> References: <20120423161539.GA6467@linux.vnet.ibm.com> <1335197761-6577-1-git-send-email-paulmck@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12042319-7408-0000-0000-0000046F8335 X-Gm-Message-State: ALoCoQltbqycm6asVcsGqfaSaTYaU6YkmWmCsuzBP7aybWo/7fOdeu0kdAwDTTjUM2cPwEAyZh4+ From: "Paul E. McKenney" Timers are subject to migration, which can lead to the following system-hang scenario when CONFIG_RCU_FAST_NO_HZ=y: 1. CPU 0 executes synchronize_rcu(), which posts an RCU callback. 2. CPU 0 then goes idle. It cannot immediately invoke the callback, but there is nothing RCU needs from ti, so it enters dyntick-idle mode after posting a timer. 3. The timer gets migrated to CPU 1. 4. CPU 0 never wakes up, so the synchronize_rcu() never returns, so the system hangs. This commit fixes this problem by using add_timer_on() to ensure that the timer remains on the CPU that posted it. Reported-by: Dipankar Sarma Signed-off-by: Paul E. McKenney Signed-off-by: Paul E. McKenney --- kernel/rcutree_plugin.h | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h index 50c1797..90b3de5 100644 --- a/kernel/rcutree_plugin.h +++ b/kernel/rcutree_plugin.h @@ -2109,6 +2109,8 @@ static void rcu_cleanup_after_idle(int cpu) */ static void rcu_prepare_for_idle(int cpu) { + struct timer_list *tp; + /* * If this is an idle re-entry, for example, due to use of * RCU_NONIDLE() or the new idle-loop tracing API within the idle @@ -2120,9 +2122,11 @@ static void rcu_prepare_for_idle(int cpu) if (!per_cpu(rcu_idle_first_pass, cpu) && (per_cpu(rcu_nonlazy_posted, cpu) == per_cpu(rcu_nonlazy_posted_snap, cpu))) { - if (rcu_cpu_has_callbacks(cpu)) - mod_timer(&per_cpu(rcu_idle_gp_timer, cpu), - per_cpu(rcu_idle_gp_timer_expires, cpu)); + if (rcu_cpu_has_callbacks(cpu)) { + tp = &per_cpu(rcu_idle_gp_timer, cpu); + tp->expires = per_cpu(rcu_idle_gp_timer_expires, cpu); + add_timer_on(tp, cpu); + } return; } per_cpu(rcu_idle_first_pass, cpu) = 0; @@ -2166,8 +2170,9 @@ static void rcu_prepare_for_idle(int cpu) else per_cpu(rcu_idle_gp_timer_expires, cpu) = jiffies + RCU_IDLE_LAZY_GP_DELAY; - mod_timer(&per_cpu(rcu_idle_gp_timer, cpu), - per_cpu(rcu_idle_gp_timer_expires, cpu)); + tp = &per_cpu(rcu_idle_gp_timer, cpu); + tp->expires = per_cpu(rcu_idle_gp_timer_expires, cpu); + add_timer_on(tp, cpu); per_cpu(rcu_nonlazy_posted_snap, cpu) = per_cpu(rcu_nonlazy_posted, cpu); return; /* Nothing more to do immediately. */