From patchwork Fri Nov 11 00:17:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 81765 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1023489qge; Thu, 10 Nov 2016 16:53:03 -0800 (PST) X-Received: by 10.98.88.5 with SMTP id m5mr1145625pfb.9.1478825583077; Thu, 10 Nov 2016 16:53:03 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a187si7384514pge.103.2016.11.10.16.53.02; Thu, 10 Nov 2016 16:53:03 -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; dkim=pass header.i=@linaro.org; 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; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755663AbcKKAw7 (ORCPT + 27 others); Thu, 10 Nov 2016 19:52:59 -0500 Received: from mail-pf0-f172.google.com ([209.85.192.172]:35284 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753716AbcKKAw5 (ORCPT ); Thu, 10 Nov 2016 19:52:57 -0500 Received: by mail-pf0-f172.google.com with SMTP id i88so1454931pfk.2 for ; Thu, 10 Nov 2016 16:52:56 -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=DyHQGICvT9FOF9tyu8Tw9xbLy6IhvxySOj9Nuccdvpg=; b=P9pyuttOXAAur2BrSa1ujIozwp98/E3OsXzJ7uJgTesjX1gMNkDHjmb5NuBLi0rz2I J72KBSWWwZ9+oIGr0zDAmapXD0bfkVdE+ol/91g6e7nSU6cvZ7aKbpBn6oroawMzqoEZ 0GPYcHbImZoctPAilGyWNhc9SYc09zOkqAuWM= 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=DyHQGICvT9FOF9tyu8Tw9xbLy6IhvxySOj9Nuccdvpg=; b=PNrZ+INpvLcgJ/AwxxS/E7KfPqRuBc5EPsm/FRyMN34VBmj6k09NnHyfUpDMRjG8oW zUd41Vu+zflTpis65M9plp9MjTyuDfJcVje586gjjxsT9OrbNM11cS/yWJrJ56+SE52C hMma7b06XDE+E+IMbxc1P2V8nuuUe6b414aYWDp4gtZ91pkB3phR2ZQY6DSOUP9bYklc IoJdsccTeg2GXYtHrPRkNJDPtLs1OXMw1pSwB4sMuXV5L7ZhWOiht3k/g5rPTDlaXM8M chmyUEDOhgWKi/AZy05mLQd8aNp61JLqt3976b9t7TopM98jYRnnqKfOpKkCMWdyJJoY vu4A== X-Gm-Message-State: ABUngvd+xRIRArqy05pOjy+6JO6ejeL+2W9vKR7XhGCGmZmG4rq37POKG9iC4/dddzpqYici X-Received: by 10.98.95.193 with SMTP id t184mr1090842pfb.85.1478825576381; Thu, 10 Nov 2016 16:52:56 -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 z3sm9935840paw.48.2016.11.10.16.52.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Nov 2016 16:52:55 -0800 (PST) From: Yang Shi To: linux@armlinux.org.uk, rostedt@goodmis.org, tglx@linutronix.de, bigeasy@linutronix.de Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rt-users@vger.kernel.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org Subject: [PATCH] arm: kprobe: replace patch_lock to raw lock Date: Thu, 10 Nov 2016 16:17:55 -0800 Message-Id: <1478823475-15087-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 When running kprobe on -rt kernel, the below bug is caught: BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:931 in_atomic(): 1, irqs_disabled(): 128, pid: 14, name: migration/0 INFO: lockdep is turned off. irq event stamp: 238 hardirqs last enabled at (237): [<80b5aecc>] _raw_spin_unlock_irqrestore+0x88/0x90 hardirqs last disabled at (238): [<80b56d88>] __schedule+0xec/0x94c softirqs last enabled at (0): [<80225584>] copy_process.part.5+0x30c/0x1994 softirqs last disabled at (0): [< (null)>] (null) Preemption disabled at:[<802f2b98>] cpu_stopper_thread+0xc0/0x140 CPU: 0 PID: 14 Comm: migration/0 Tainted: G O 4.8.3-rt2 #1 Hardware name: Freescale LS1021A [<80212e7c>] (unwind_backtrace) from [<8020cd2c>] (show_stack+0x20/0x24) [<8020cd2c>] (show_stack) from [<80689e14>] (dump_stack+0xa0/0xcc) [<80689e14>] (dump_stack) from [<8025a43c>] (___might_sleep+0x1b8/0x2a4) [<8025a43c>] (___might_sleep) from [<80b5b324>] (rt_spin_lock+0x34/0x74) [<80b5b324>] (rt_spin_lock) from [<80b5c31c>] (__patch_text_real+0x70/0xe8) [<80b5c31c>] (__patch_text_real) from [<80b5c3ac>] (patch_text_stop_machine+0x18/0x20) [<80b5c3ac>] (patch_text_stop_machine) from [<802f2920>] (multi_cpu_stop+0xfc/0x134) [<802f2920>] (multi_cpu_stop) from [<802f2ba0>] (cpu_stopper_thread+0xc8/0x140) [<802f2ba0>] (cpu_stopper_thread) from [<802563a4>] (smpboot_thread_fn+0x1a4/0x354) [<802563a4>] (smpboot_thread_fn) from [<80251d38>] (kthread+0x104/0x11c) [<80251d38>] (kthread) from [<80207f70>] (ret_from_fork+0x14/0x24) Since patch_text_stop_machine() is called in stop_machine() which disables IRQ, sleepable lock should be not used in this atomic context, so replace patch_lock to raw lock. Signed-off-by: Yang Shi --- arch/arm/kernel/patch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.0.2 Acked-by: Sebastian Andrzej Siewior diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c index 69bda1a..1f665ac 100644 --- a/arch/arm/kernel/patch.c +++ b/arch/arm/kernel/patch.c @@ -15,7 +15,7 @@ struct patch { unsigned int insn; }; -static DEFINE_SPINLOCK(patch_lock); +static DEFINE_RAW_SPINLOCK(patch_lock); static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags) __acquires(&patch_lock) @@ -32,7 +32,7 @@ static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags) return addr; if (flags) - spin_lock_irqsave(&patch_lock, *flags); + raw_spin_lock_irqsave(&patch_lock, *flags); else __acquire(&patch_lock); @@ -47,7 +47,7 @@ static void __kprobes patch_unmap(int fixmap, unsigned long *flags) clear_fixmap(fixmap); if (flags) - spin_unlock_irqrestore(&patch_lock, *flags); + raw_spin_unlock_irqrestore(&patch_lock, *flags); else __release(&patch_lock); }