From patchwork Mon Feb 8 22:49:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 61451 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1717633lbl; Mon, 8 Feb 2016 15:12:01 -0800 (PST) X-Received: by 10.67.14.105 with SMTP id ff9mr46138329pad.150.1454973121348; Mon, 08 Feb 2016 15:12:01 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fk7si9779483pac.50.2016.02.08.15.12.01; Mon, 08 Feb 2016 15:12:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932459AbcBHXL7 (ORCPT + 30 others); Mon, 8 Feb 2016 18:11:59 -0500 Received: from mail-pf0-f173.google.com ([209.85.192.173]:34661 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932113AbcBHXL5 (ORCPT ); Mon, 8 Feb 2016 18:11:57 -0500 Received: by mail-pf0-f173.google.com with SMTP id o185so116914157pfb.1 for ; Mon, 08 Feb 2016 15:11:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ntfA3tOf9GUrPUepdlNuyA7wW5QETSH/F24Agb4p3A0=; b=Vz6kTdl0fxL0olTQ5pzde9TzwAeQEG81n49tM/RU7kWcNjocXwLqqdOe/3IO2WRKpf nQGRcludCc9DajckJGia6wDG0AJY9SHx1Fg0TjsaYPO4KsWgnJD/Ytc2iK5fBy0LblFR 474XaHBA4Y7+Fa2rtnEfn9ToRqn9pJkHoD+fk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ntfA3tOf9GUrPUepdlNuyA7wW5QETSH/F24Agb4p3A0=; b=cAqRDA2aEYb8hm2128X1BRf1nmR6fAfSbimqnpyLY9/fMdXs/CdsVvuvikNV+CTGyH u78Frg4x95FOpnybyMEW6/rW3gILbkjFjIhzFCaQKaK3IjeRZLUvBwx3hbmnfhtFtG0x eSKH6uqUSpYUfbbmXb3HPSr+WFkQZSjliKlu3BFb1xlaFZ4HPgPUiQKA7tlfSIa5tCIR oUsbc4Q5uxv1GmJayXrf5tse1efwx1RHuzENAzH8AyP4G4mVgNxdrJEB+IopbagIMTMM B7NQvHdL7LimvwdvNrnZvjvu+UuYUjR1QnlGPP8UVCNlSjqK5wbv+4wq2dLozE7d8BQu 3nzQ== X-Gm-Message-State: AG10YOTP8PsdPtm+XI3qkkYWftjSpNF05KMsK8696IP3MlVzn4sVTNXIeYIAz7aV02UrDPJF X-Received: by 10.98.14.79 with SMTP id w76mr22777043pfi.1.1454973117183; Mon, 08 Feb 2016 15:11:57 -0800 (PST) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id g10sm45675619pfd.92.2016.02.08.15.11.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 15:11:56 -0800 (PST) From: Yang Shi To: rostedt@goodmis.org, catalin.marinas@arm.com, will.deacon@arm.com, bigeasy@linutronix.de Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org Subject: [PATCH] arm64: replace read_lock to rcu lock in call_step_hook Date: Mon, 8 Feb 2016 14:49:24 -0800 Message-Id: <1454971764-30720-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:917 in_atomic(): 1, irqs_disabled(): 128, pid: 383, name: sh Preemption disabled at:[] kgdb_cpu_enter+0x158/0x6b8 CPU: 3 PID: 383 Comm: sh Tainted: G W 4.1.13-rt13 #2 Hardware name: Freescale Layerscape 2085a RDB Board (DT) Call trace: [] dump_backtrace+0x0/0x128 [] show_stack+0x24/0x30 [] dump_stack+0x80/0xa0 [] ___might_sleep+0x18c/0x1a0 [] __rt_spin_lock+0x2c/0x40 [] rt_read_lock+0x40/0x58 [] single_step_handler+0x38/0xd8 [] do_debug_exception+0x58/0xb8 Exception stack(0xffff80834a1e7c80 to 0xffff80834a1e7da0) 7c80: ffffff9c ffffffff 92c23ba0 0000ffff 4a1e7e40 ffff8083 001bfcc4 ffff8000 7ca0: f2000400 00000000 00000000 00000000 4a1e7d80 ffff8083 0049501c ffff8000 7cc0: 00005402 00000000 00aaa210 ffff8000 4a1e7ea0 ffff8083 000833f4 ffff8000 7ce0: ffffff9c ffffffff 92c23ba0 0000ffff 4a1e7ea0 ffff8083 001bfcc0 ffff8000 7d00: 4a0fc400 ffff8083 00005402 00000000 4a1e7d40 ffff8083 00490324 ffff8000 7d20: ffffff9c 00000000 92c23ba0 0000ffff 000a0000 00000000 00000000 00000000 7d40: 00000008 00000000 00080000 00000000 92c23b8b 0000ffff 92c23b8e 0000ffff 7d60: 00000038 00000000 00001cb2 00000000 00000005 00000000 92d7b498 0000ffff 7d80: 01010101 01010101 92be9000 0000ffff 00000000 00000000 00000030 00000000 [] el1_dbg+0x18/0x6c This issue is similar with 62c6c61("arm64: replace read_lock to rcu lock in call_break_hook"), but comes to single_step_handler. This also solves kgdbts boot test silent hang issue on 4.4 -rt kernel. Signed-off-by: Yang Shi --- arch/arm64/kernel/debug-monitors.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) -- 2.0.2 Acked-by: Will Deacon diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c index 8aee3ae..c1492ba 100644 --- a/arch/arm64/kernel/debug-monitors.c +++ b/arch/arm64/kernel/debug-monitors.c @@ -186,20 +186,21 @@ static void clear_regs_spsr_ss(struct pt_regs *regs) /* EL1 Single Step Handler hooks */ static LIST_HEAD(step_hook); -static DEFINE_RWLOCK(step_hook_lock); +static DEFINE_SPINLOCK(step_hook_lock); void register_step_hook(struct step_hook *hook) { - write_lock(&step_hook_lock); - list_add(&hook->node, &step_hook); - write_unlock(&step_hook_lock); + spin_lock(&step_hook_lock); + list_add_rcu(&hook->node, &step_hook); + spin_unlock(&step_hook_lock); } void unregister_step_hook(struct step_hook *hook) { - write_lock(&step_hook_lock); - list_del(&hook->node); - write_unlock(&step_hook_lock); + spin_lock(&step_hook_lock); + list_del_rcu(&hook->node); + spin_unlock(&step_hook_lock); + synchronize_rcu(); } /* @@ -213,15 +214,15 @@ static int call_step_hook(struct pt_regs *regs, unsigned int esr) struct step_hook *hook; int retval = DBG_HOOK_ERROR; - read_lock(&step_hook_lock); + rcu_read_lock(); - list_for_each_entry(hook, &step_hook, node) { + list_for_each_entry_rcu(hook, &step_hook, node) { retval = hook->fn(regs, esr); if (retval == DBG_HOOK_HANDLED) break; } - read_unlock(&step_hook_lock); + rcu_read_unlock(); return retval; }