From patchwork Thu Mar 28 20:25:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 2359391 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 0680DDF2A1 for ; Thu, 28 Mar 2013 20:28:35 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ULJOT-0005pN-Of; Thu, 28 Mar 2013 20:25:53 +0000 Received: from mail-pa0-f45.google.com ([209.85.220.45]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ULJOP-0005oU-Tm for linux-arm-kernel@lists.infradead.org; Thu, 28 Mar 2013 20:25:51 +0000 Received: by mail-pa0-f45.google.com with SMTP id kl13so66145pab.18 for ; Thu, 28 Mar 2013 13:25:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=wXi7Od1xSJikqVv7Z9jY1v0d8rMen1IDZ41HsLxurHk=; b=G3tZiujMoMlMmN6NJxtyBk2B6NYUMt7qi69Eel7SDDovfElEmjZiK1jVfvDJyOBREg a5/4XAHIqb52+1tkjXKJtnlz5u5a6KSQBpao3MEmnWDYbKML1ZLApAYrxg0OmR/8uGNu nnwZldrMCg8GpsDk1KHS8JkX/ePDIecD468fa2f7anpYU1PwdfGUkVptG7dmlXDBby/o PsJaUUyqzgYal5ML1PdbIqgbZuzAPsHssyuymny1cS4qfFxkVGDB1rKRlbuT6PYBdqC6 T3WtAS9p2hEpFdNLn8vDOvxQAapsoBua2u2BwJDc0lwvsU5IWPha77xoLko2ni0K9fAv o+oA== X-Received: by 10.68.7.106 with SMTP id i10mr16923pba.43.1364502347269; Thu, 28 Mar 2013 13:25:47 -0700 (PDT) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPS id t5sm75820pbi.10.2013.03.28.13.25.45 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 28 Mar 2013 13:25:46 -0700 (PDT) From: Kevin Hilman To: Russell King , linux-arm-kernel@lists.infradead.org Subject: [PATCH v3] ARM: add support for context tracking subsystem Date: Thu, 28 Mar 2013 13:25:44 -0700 Message-Id: <1364502344-12189-1-git-send-email-khilman@linaro.org> X-Mailer: git-send-email 1.8.2 X-Gm-Message-State: ALoCoQlanN1f5Z9584k7Hwh0F+KZtrBPPiwsiLFUNBtwCXid9AeVuPQxvmWHSOvXbDk8g+1QdN8n X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130328_162550_116739_0652FB1B X-CRM114-Status: GOOD ( 15.77 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.45 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Frederic Weisbecker , Mats Liljegren , Paul McKenney , linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org commit 91d1aa43 (context_tracking: New context tracking susbsystem) generalized parts of the RCU userspace extended quiescent state into the context tracking subsystem. Context tracking is then used to implement adaptive tickless (a.k.a extended nohz) To support the new context tracking subsystem on ARM, the user/kernel boundary transtions need to be instrumented. For exceptions and IRQs in usermode, the existing usr_entry macro is used to instrument the user->kernel transition. For the return to usermode path, the ret_to_user* path is instrumented. Using the usr_entry macro, this covers interrupts in userspace, data abort and prefetch abort exceptions in userspace as well as undefined exceptions in userspace (which is where FP emulation and VFP are handled.) For syscalls, the slow return path is covered by instrumenting the ret_to_user path. In addition, the syscall entry point is instrumented which covers the user->kernel transition for both fast and slow syscalls, and an additional instrumentation point is added for the fast syscall return path (ret_fast_syscall). Cc: Mats Liljegren Cc: Frederic Weisbecker Signed-off-by: Kevin Hilman --- Updates from v2: - optionally save/restore registers before calling user_enter/user_exit (suggested by Russell King) Updates from v1: - instrument entry/exit points directly in assembly, instead of C code - combined exceptions and syscalls into a single patch - covers VFP and FP emulation now (v1 limitation pointed out by Russell) Depends on the previously posted prerequistes series: [PATCH 0/3] ARM: context tracking support prerequisites http://marc.info/?l=linux-kernel&m=136382248131438&w=2 Both of which are combined on top of Frederic's 3.9-rc1-nohz1 branch and available here: git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux.git arm-nohz-v3/context-tracking arch/arm/Kconfig | 1 + arch/arm/include/asm/thread_info.h | 1 + arch/arm/kernel/entry-armv.S | 1 + arch/arm/kernel/entry-common.S | 3 +++ arch/arm/kernel/entry-header.S | 28 ++++++++++++++++++++++++++++ 5 files changed, 34 insertions(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index ba8bf89..0b13689 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -59,6 +59,7 @@ config ARM select OLD_SIGSUSPEND3 select OLD_SIGACTION select HAVE_VIRT_CPU_ACCOUNTING + select HAVE_CONTEXT_TRACKING help The ARM series is a line of low-power-consumption RISC chip designs licensed by ARM Ltd and targeted at embedded applications and diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h index cddda1f..1995d1a 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -152,6 +152,7 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *, #define TIF_SYSCALL_AUDIT 9 #define TIF_SYSCALL_TRACEPOINT 10 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */ +#define TIF_NOHZ 12 /* in adaptive nohz mode */ #define TIF_USING_IWMMXT 17 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ #define TIF_RESTORE_SIGMASK 20 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index 0f82098..3449d30 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -396,6 +396,7 @@ ENDPROC(__pabt_svc) #ifdef CONFIG_IRQSOFF_TRACER bl trace_hardirqs_off #endif + ct_user_exit, save = 0 .endm .macro kuser_cmpxchg_check diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index 3248cde..c8b42de 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -41,6 +41,7 @@ ret_fast_syscall: /* perform architecture specific actions before user return */ arch_ret_to_user r1, lr + ct_user_enter restore_user_regs fast = 1, offset = S_OFF UNWIND(.fnend ) @@ -76,6 +77,7 @@ no_work_pending: #endif /* perform architecture specific actions before user return */ arch_ret_to_user r1, lr + ct_user_enter, save = 0 restore_user_regs fast = 0, offset = 0 ENDPROC(ret_to_user_from_irq) @@ -394,6 +396,7 @@ ENTRY(vector_swi) mcr p15, 0, ip, c1, c0 @ update control register #endif enable_irq + ct_user_exit get_thread_info tsk adr tbl, sys_call_table @ load syscall table pointer diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S index 9a8531e..782a949 100644 --- a/arch/arm/kernel/entry-header.S +++ b/arch/arm/kernel/entry-header.S @@ -164,6 +164,34 @@ #endif /* !CONFIG_THUMB2_KERNEL */ /* + * Context tracking subsystem. Used to instrument transitions + * between user and kernel mode. + */ + .macro ct_user_exit, save = 1 +#ifdef CONFIG_CONTEXT_TRACKING + .if \save + stmdb sp!, {r0-r3, ip, lr} + bl user_exit + ldmia sp!, {r0-r3, ip, lr} + .else + bl user_exit + .endif +#endif + .endm + + .macro ct_user_enter, save = 1 +#ifdef CONFIG_CONTEXT_TRACKING + .if \save + stmdb sp!, {r0-r3, ip, lr} + bl user_enter + ldmia sp!, {r0-r3, ip, lr} + .else + bl user_enter + .endif +#endif + .endm + +/* * These are the registers used in the syscall handler, and allow us to * have in theory up to 7 arguments to a function - r0 to r6. *