From patchwork Thu Oct 1 16:37:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 7310201 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B8D01BEEA4 for ; Thu, 1 Oct 2015 16:57:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD1EA20689 for ; Thu, 1 Oct 2015 16:57:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E3FD52065F for ; Thu, 1 Oct 2015 16:57:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zhh7z-0005L2-RD; Thu, 01 Oct 2015 16:54:43 +0000 Received: from mail-pa0-f49.google.com ([209.85.220.49]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zhh7x-0005HZ-Uq for linux-arm-kernel@lists.infradead.org; Thu, 01 Oct 2015 16:54:42 +0000 Received: by pacex6 with SMTP id ex6so79746463pac.0 for ; Thu, 01 Oct 2015 09:54:21 -0700 (PDT) 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=2a1QEJPaMlW2YaTsw7SWlV1SpH/b+Fni8Ty7onZhi3M=; b=ZGhwqbCOmT3aQzZ7Xt5ASVCQXfsW42URGTCxgEzdkJ6beRsJp+7OHldRAFPT6mXOnQ wL/HZZh8k6+jLKbmfG5HV8NjGTrlgMJrBlTLrytz6M/cFxVP7B4kbABDNEouYMERIheH 12XSA1hwgF4oybgDfjtjcmeYDBsngQ5yuJr1Co7u6m99FAR8JSd9xw/HK/LMpCYiV0YU u5EUvCi4S7BvX7pG2o2c0k+72YQwdFpa0tYhZeBVs2CSRCsJzUpTxZGwExY2LwpSTij2 bSUH+/yKaOUisbYanRMpSHPJmL+XoFH0pw+uPEvF3OlvqoQuNSYrJEbqFVd2dGcCg3Qj M9Tg== X-Gm-Message-State: ALoCoQlp+8HKHNFlSBXViWOsMnyBeI/XRi6SvonGO/g/T/4fuWp3AdNXRQcXTmdFj/fHj+60fMfJ X-Received: by 10.68.98.99 with SMTP id eh3mr13426888pbb.126.1443718460878; Thu, 01 Oct 2015 09:54:20 -0700 (PDT) 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 zn9sm7671749pac.48.2015.10.01.09.54.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Oct 2015 09:54:19 -0700 (PDT) From: Yang Shi To: rostedt@goodmis.org, catalin.marinas@arm.com, will.deacon@arm.com, dave.long@linaro.org, panand@redhat.com Subject: [v2 PATCH] arm64: replace read_lock to rcu lock in call_break_hook Date: Thu, 1 Oct 2015 09:37:37 -0700 Message-Id: <1443717457-31461-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151001_095442_038753_2D8EDA3E X-CRM114-Status: GOOD ( 12.35 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.shi@linaro.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rt-users@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:917 in_atomic(): 0, irqs_disabled(): 128, pid: 342, name: perf 1 lock held by perf/342: #0: (break_hook_lock){+.+...}, at: [] call_break_hook+0x34/0xd0 irq event stamp: 62224 hardirqs last enabled at (62223): [] __call_rcu.constprop.59+0x104/0x270 hardirqs last disabled at (62224): [] vprintk_emit+0x68/0x640 softirqs last enabled at (0): [] copy_process.part.8+0x428/0x17f8 softirqs last disabled at (0): [< (null)>] (null) CPU: 0 PID: 342 Comm: perf Not tainted 4.1.6-rt5 #4 Hardware name: linux,dummy-virt (DT) Call trace: [] dump_backtrace+0x0/0x128 [] show_stack+0x20/0x30 [] dump_stack+0x7c/0xa0 [] ___might_sleep+0x174/0x260 [] __rt_spin_lock+0x28/0x40 [] rt_read_lock+0x60/0x80 [] call_break_hook+0x30/0xd0 [] brk_handler+0x30/0x98 [] do_debug_exception+0x50/0xb8 Exception stack(0xffffffc00514fe30 to 0xffffffc00514ff50) fe20: 00000000 00000000 c1594680 0000007f fe40: ffffffff ffffffff 92063940 0000007f 0550dcd8 ffffffc0 00000000 00000000 fe60: 0514fe70 ffffffc0 000be1f8 ffffffc0 0514feb0 ffffffc0 0008948c ffffffc0 fe80: 00000004 00000000 0514fed0 ffffffc0 ffffffff ffffffff 9282a948 0000007f fea0: 00000000 00000000 9282b708 0000007f c1592820 0000007f 00083914 ffffffc0 fec0: 00000000 00000000 00000010 00000000 00000064 00000000 00000001 00000000 fee0: 005101e0 00000000 c1594680 0000007f c1594740 0000007f ffffffd8 ffffff80 ff00: 00000000 00000000 00000000 00000000 c1594770 0000007f c1594770 0000007f ff20: 00665e10 00000000 7f7f7f7f 7f7f7f7f 01010101 01010101 00000000 00000000 ff40: 928e4cc0 0000007f 91ff11e8 0000007f call_break_hook is called in atomic context (hard irq disabled), so replace the sleepable lock to rcu lock and replace relevant list operations to rcu version. Signed-off-by: Yang Shi --- v1-> v2 Replace list operations to rcu version. arch/arm64/kernel/debug-monitors.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c index cebf786..cf0e4fc 100644 --- a/arch/arm64/kernel/debug-monitors.c +++ b/arch/arm64/kernel/debug-monitors.c @@ -276,14 +276,14 @@ static DEFINE_RWLOCK(break_hook_lock); void register_break_hook(struct break_hook *hook) { write_lock(&break_hook_lock); - list_add(&hook->node, &break_hook); + list_add_rcu(&hook->node, &break_hook); write_unlock(&break_hook_lock); } void unregister_break_hook(struct break_hook *hook) { write_lock(&break_hook_lock); - list_del(&hook->node); + list_del_rcu(&hook->node); write_unlock(&break_hook_lock); } @@ -292,11 +292,11 @@ static int call_break_hook(struct pt_regs *regs, unsigned int esr) struct break_hook *hook; int (*fn)(struct pt_regs *regs, unsigned int esr) = NULL; - read_lock(&break_hook_lock); - list_for_each_entry(hook, &break_hook, node) + rcu_read_lock(); + list_for_each_entry_rcu(hook, &break_hook, node) if ((esr & hook->esr_mask) == hook->esr_val) fn = hook->fn; - read_unlock(&break_hook_lock); + rcu_read_unlock(); return fn ? fn(regs, esr) : DBG_HOOK_ERROR; }