From patchwork Mon Dec 14 23:06:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 58371 Delivered-To: patch@linaro.org Received: by 10.112.73.68 with SMTP id j4csp1789842lbv; Mon, 14 Dec 2015 15:27:02 -0800 (PST) X-Received: by 10.98.32.218 with SMTP id m87mr38155384pfj.60.1450135622779; Mon, 14 Dec 2015 15:27:02 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3si3103606pfi.74.2015.12.14.15.27.02; Mon, 14 Dec 2015 15:27:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-rt-users-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-rt-users-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-rt-users-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753656AbbLNX1B (ORCPT + 4 others); Mon, 14 Dec 2015 18:27:01 -0500 Received: from mail-pf0-f181.google.com ([209.85.192.181]:34106 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753607AbbLNX1A (ORCPT ); Mon, 14 Dec 2015 18:27:00 -0500 Received: by pfbo64 with SMTP id o64so34718965pfb.1 for ; Mon, 14 Dec 2015 15:27:00 -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=FCltdQE2LxMNzoUgYCPYs61CbOy+cIXDjleX1P/tqAc=; b=SBFu+7pDaDknVgyEDUO/3+7wMaatgRJ8m2OkI706RaTpmx9ph0dU5MpKkkC5YvUFf4 ASQd04f7Crr8Nw7WV+7tW9MCvueqkH7DTEuO0AVhKXyCTXRHel0vL9J9+4nisj7GK8os yJfa6xZUWFT/SoCfOXcINGTHj8C+vDn2jNxds= 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=FCltdQE2LxMNzoUgYCPYs61CbOy+cIXDjleX1P/tqAc=; b=G4Akgjw7/a7LQxu+bPgOxZvDAJNMRIXlumrQpeyk4bahoL56xeKsyKm/QmQoR38KbH BninBAefRTboGug4rcXjjKzE8niAq5Yf37NbclnWUcZb1i8hxO3OLRZjn7H58Qv4KKAo 3xyxz1l6Xtr/CygnWxMco5Ljg1AAARIPJK3aiuJYPpf2dAkBJbmoL1c8+KSwmleMWc0N Tm2TQG1+FyMTtPb49+RLWPAFtiZ9G0BLn3/DN4QLtTs8q2zQ37LlAlLyq8Z+Xv+RMDLx vProDpe6GB17emNUhRJIwd3BZceNDd4XnFM9xF7EfAuR4h5emf9+cAh1QpWP0MAtV4wr oJHQ== X-Gm-Message-State: ALoCoQllL4Mgz9dKlXnQOnY6bfoRgff+aaRkOYULC9KzfmYbde3r/Nchd1cUk7vuUiWxuTLOPu6IRo1obOdpFRBVYs0TZHssXQ== X-Received: by 10.98.14.27 with SMTP id w27mr29809903pfi.50.1450135620100; Mon, 14 Dec 2015 15:27:00 -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 79sm44556310pfb.67.2015.12.14.15.26.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Dec 2015 15:26:58 -0800 (PST) From: Yang Shi To: tglx@linutronix.de, bigeasy@linutronix.de, rostedt@goodmis.org Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org Subject: [PATCH v2] rt: x86: enable preemption in IST exception for x86-32 Date: Mon, 14 Dec 2015 15:06:44 -0800 Message-Id: <1450134404-16662-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 Sender: linux-rt-users-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org When running some ptrace single step tests on x86-32 machine, the below problem is triggered: BUG: sleeping function called from invalid context at linux-rt/kernel/locking/rtmutex.c:917 in_atomic(): 1, irqs_disabled(): 0, pid: 1041, name: dummy2 INFO: lockdep is turned off. Preemption disabled at:[] do_debug+0x1f/0x1a0 CPU: 10 PID: 1041 Comm: dummy2 Tainted: G W 4.1.13-rt13 #1 Hardware name: Intel Corporation S5520HC/S5520HC, BIOS S5500.86B.01.10.0025.030220091519 03/02/2009 00000000 00000000 e1811e80 c1aa8306 00000000 e1811ea8 c1080517 c1d8b2e8 c100326f c100326f 00000411 e5b7d5b4 e1d521c4 00000005 e1811f74 e1811ec4 c1ab0eff e1d51cc0 e5b7d180 c1081403 e5b7d180 e5b7d180 e1811ee4 c1064b5a Call Trace: [] dump_stack+0x46/0x5c [] ___might_sleep+0x137/0x220 [] ? do_debug+0x1f/0x1a0 [] ? do_debug+0x1f/0x1a0 [] rt_spin_lock+0x1f/0x80 [] ? preempt_count_sub+0xb3/0x110 [] do_force_sig_info+0x2a/0xc0 [] force_sig_info+0xd/0x10 [] send_sigtrap+0x6f/0x80 [] do_debug+0x161/0x1a0 [] debug_stack_correct+0x2e/0x35 Mainline kernel commit 959274753857efe9c5f1ba35fe727f51e9aa128d ("x86, traps: Track entry into and exit from IST context"), introduced ist_enter which disables preemption uncondiontionally for both x86-64 and x86-32. However, x86-32 does not have an IST and the stack still belongs to the current task and there is no problem in scheduling out the task. Signed-off-by: Yang Shi --- arch/x86/kernel/traps.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.0.2 -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index ebae118..7139bc0 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -90,7 +90,7 @@ static inline void conditional_sti(struct pt_regs *regs) static inline void conditional_sti_ist(struct pt_regs *regs) { -#ifdef CONFIG_X86_64 +#if !defined(CONFIG_X86_64) /* * X86_64 uses a per CPU stack on the IST for certain traps * like int3. The task can not be preempted when using one @@ -101,7 +101,7 @@ static inline void conditional_sti_ist(struct pt_regs *regs) * On x86_32 the task keeps its own stack and it is OK if the * task schedules out. */ - preempt_count_inc(); + ist_begin_non_atomic(regs); #endif if (regs->flags & X86_EFLAGS_IF) local_irq_enable(); @@ -117,8 +117,8 @@ static inline void conditional_cli_ist(struct pt_regs *regs) { if (regs->flags & X86_EFLAGS_IF) local_irq_disable(); -#ifdef CONFIG_X86_64 - preempt_count_dec(); +#if !defined(CONFIG_X86_64) + ist_end_non_atomic(); #endif }