Subject: arm-preempt-lazy-support.patch From: Thomas Gleixner Date: Wed, 31 Oct 2012 12:04:11 +0100 Signed-off-by: Thomas Gleixner --- arch/arm/Kconfig | 1 + arch/arm/include/asm/thread_info.h | 3 +++ arch/arm/kernel/asm-offsets.c | 1 + arch/arm/kernel/entry-armv.S | 8 ++++++++ arch/arm/kernel/signal.c | 3 ++- 5 files changed, 15 insertions(+), 1 deletion(-) Index: linux-stable/arch/arm/Kconfig =================================================================== --- linux-stable.orig/arch/arm/Kconfig +++ linux-stable/arch/arm/Kconfig @@ -50,6 +50,7 @@ config ARM select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER select DCACHE_WORD_ACCESS if (CPU_V6 || CPU_V6K || CPU_V7) && !CPU_BIG_ENDIAN + select HAVE_PREEMPT_LAZY help The ARM series is a line of low-power-consumption RISC chip designs licensed by ARM Ltd and targeted at embedded applications and Index: linux-stable/arch/arm/include/asm/thread_info.h =================================================================== --- linux-stable.orig/arch/arm/include/asm/thread_info.h +++ linux-stable/arch/arm/include/asm/thread_info.h @@ -50,6 +50,7 @@ struct cpu_context_save { struct thread_info { unsigned long flags; /* low level flags */ int preempt_count; /* 0 => preemptable, <0 => bug */ + int preempt_lazy_count; /* 0 => preemptable, <0 => bug */ mm_segment_t addr_limit; /* address limit */ struct task_struct *task; /* main task structure */ struct exec_domain *exec_domain; /* execution domain */ @@ -146,6 +147,7 @@ extern int vfp_restore_user_hwstate(stru #define TIF_SIGPENDING 0 #define TIF_NEED_RESCHED 1 #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */ +#define TIF_NEED_RESCHED_LAZY 3 #define TIF_SYSCALL_TRACE 8 #define TIF_SYSCALL_AUDIT 9 #define TIF_POLLING_NRFLAG 16 @@ -158,6 +160,7 @@ extern int vfp_restore_user_hwstate(stru #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY) #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) Index: linux-stable/arch/arm/kernel/asm-offsets.c =================================================================== --- linux-stable.orig/arch/arm/kernel/asm-offsets.c +++ linux-stable/arch/arm/kernel/asm-offsets.c @@ -50,6 +50,7 @@ int main(void) BLANK(); DEFINE(TI_FLAGS, offsetof(struct thread_info, flags)); DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count)); + DEFINE(TI_PREEMPT_LAZY, offsetof(struct thread_info, preempt_lazy_count)); DEFINE(TI_ADDR_LIMIT, offsetof(struct thread_info, addr_limit)); DEFINE(TI_TASK, offsetof(struct thread_info, task)); DEFINE(TI_EXEC_DOMAIN, offsetof(struct thread_info, exec_domain)); Index: linux-stable/arch/arm/kernel/entry-armv.S =================================================================== --- linux-stable.orig/arch/arm/kernel/entry-armv.S +++ linux-stable/arch/arm/kernel/entry-armv.S @@ -221,6 +221,12 @@ __irq_svc: movne r0, #0 @ force flags to 0 tst r0, #_TIF_NEED_RESCHED blne svc_preempt + ldr r8, [tsk, #TI_PREEMPT_LAZY] @ get preempt lazy count + ldr r0, [tsk, #TI_FLAGS] @ get flags + teq r8, #0 @ if preempt lazy count != 0 + movne r0, #0 @ force flags to 0 + tst r0, #_TIF_NEED_RESCHED_LAZY + blne svc_preempt #endif #ifdef CONFIG_TRACE_IRQFLAGS @@ -240,6 +246,8 @@ svc_preempt: 1: bl preempt_schedule_irq @ irq en/disable is done inside ldr r0, [tsk, #TI_FLAGS] @ get new tasks TI_FLAGS tst r0, #_TIF_NEED_RESCHED + bne 1b + tst r0, #_TIF_NEED_RESCHED_LAZY moveq pc, r8 @ go again b 1b #endif Index: linux-stable/arch/arm/kernel/signal.c =================================================================== --- linux-stable.orig/arch/arm/kernel/signal.c +++ linux-stable/arch/arm/kernel/signal.c @@ -639,7 +639,8 @@ asmlinkage int do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall) { do { - if (likely(thread_flags & _TIF_NEED_RESCHED)) { + if (likely(thread_flags & (_TIF_NEED_RESCHED | + _TIF_NEED_RESCHED_LAZY))) { schedule(); } else { if (unlikely(!user_mode(regs)))