From patchwork Mon Apr 14 12:03:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ding Tianhong X-Patchwork-Id: 3980331 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AED679F336 for ; Mon, 14 Apr 2014 12:06:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF271201F7 for ; Mon, 14 Apr 2014 12:06:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA981201ED for ; Mon, 14 Apr 2014 12:06:48 +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 1WZfck-0006CF-0S; Mon, 14 Apr 2014 12:04:30 +0000 Received: from szxga03-in.huawei.com ([119.145.14.66]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WZfcg-0005x8-Hf for linux-arm-kernel@lists.infradead.org; Mon, 14 Apr 2014 12:04:27 +0000 Received: from 172.24.2.119 (EHLO szxeml206-edg.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id ANI24149; Mon, 14 Apr 2014 20:03:26 +0800 (CST) Received: from SZXEML421-HUB.china.huawei.com (10.82.67.160) by szxeml206-edg.china.huawei.com (172.24.2.59) with Microsoft SMTP Server (TLS) id 14.3.158.1; Mon, 14 Apr 2014 20:02:47 +0800 Received: from [127.0.0.1] (10.177.22.246) by szxeml421-hub.china.huawei.com (10.82.67.160) with Microsoft SMTP Server id 14.3.158.1; Mon, 14 Apr 2014 20:03:14 +0800 Message-ID: <534BCE80.3090406@huawei.com> Date: Mon, 14 Apr 2014 20:03:12 +0800 From: Ding Tianhong User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: Catalin Marinas , Will Deacon , , Xinwei Hu , , "linux-kernel@vger.kernel.org" Subject: [PATCH] arm64: Flush the process's mm context TLB entries when switching X-Originating-IP: [10.177.22.246] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140414_050427_304840_FAABC989 X-CRM114-Status: GOOD ( 14.55 ) X-Spam-Score: -1.7 (-) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,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 I met a problem when migrating process by following steps: 1) The process was already running on core 0. 2) Set the CPU affinity of the process to 0x02 and move it to core 1, it could work well. 3) Set the CPU affinity of the process to 0x01 and move it to core 0 again, the problem occurs and the process was killed. --------------------------------------------------------------------- Aborting.../init: line 29: 434 Aborted setsid cttyhack sh Console sh exited with 134, respawning... fork_test[440]: unhandled level 2 translation fault (11) at 0x00000000, esr 0x83 000006 pgd = ffffffc01a505000 [00000000] *pgd=000000001a3f4003, *pmd=0000000000000000 CPU: 0 PID: 440 Comm: fork_test Not tainted 3.13.0+ #7 task: ffffffc01a41c800 ti: ffffffc01a55c000 task.ti: ffffffc01a55c000 PC is at 0x0 LR is at 0x0 pc : [<0000000000000000>] lr : [<0000000000000000>] pstate: 20000000 sp : 0000007fdeb1dc50 x29: 0000000000000000 x28: 0000000000000000 x27: 0000000000000000 x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 x23: 0000000000000000 x22: 0000000000000000 x21: 0000000000400570 x20: 0000000000000000 x19: 0000000000400570 x18: 0000007fdeb1d9e0 x17: 0000007fa7a65840 x16: 0000000000410a50 x15: 0000007fa7b3b028 x14: 0000000000000040 x13: 0000000000000090 x12: 000000000013c000 x11: 000000000002b028 x10: 0000000000000000 x9 : 00000000ffffffff x8 : 0000000000000104 x7 : 0000000000000000 x6 : 0000000000000000 x5 : 00000000fbad2a84 x4 : 0000000000000000 x3 : 0000000000000000 x2 : 0000000000000020 x1 : 0000007fa7b356f0 x0 : ffffffffffffffff CPU: 0 PID: 440 Comm: fork_test Not tainted 3.13.0+ #7 Call trace: [] dump_backtrace+0x0/0x12c [] show_stack+0x14/0x1c [] dump_stack+0x70/0x90 [] __do_user_fault+0x48/0xf4 [] do_page_fault+0x168/0x378 [] do_translation_fault+0xc0/0xf0 [] do_mem_abort+0x3c/0x9c Exception stack(0xffffffc01a55fe30 to 0xffffffc01a55ff50) fe20: 00400570 00000000 00000000 00000000 fe40: ffffffff ffffffff 00000000 00000000 ffffffff ffffffff 000000dc 00000000 fe60: 00000003 00000004 00000000 00000000 00000000 00000000 000001bb 00000000 fe80: 00000000 00000000 00000000 0000007f 1a41c800 ffffffc0 00095508 ffffffc0 fea0: 00100100 00000000 00200200 00000000 fffffff6 00000000 00001000 00000000 fec0: deb1dc00 0000007f 000839ec ffffffc0 ffffffff ffffffff a7b356f0 0000007f fee0: 00000020 00000000 00000000 00000000 00000000 00000000 fbad2a84 00000000 ff00: 00000000 00000000 00000000 00000000 00000104 00000000 ffffffff 00000000 ff20: 00000000 00000000 0002b028 00000000 0013c000 00000000 00000090 00000000 ff40: 00000040 00000000 a7b3b028 0000007f ---------------------------- cut here ----------------------------------- It was a very strange problem that the PC and LR are both 0, and the esr is 0x83000006, it means that the used for instruction access generated MMU faults and synchronous external aborts, including synchronous parity errors. I try to fix the problem by invalidating the process's TLB entries when switching, it will make the context stale and pick new one, and then it could work well. So I think in some situation that after the process switching, the modification of the TLB entries in the new core didn't inform all other cores to invalidate the old TLB entries which was in the inner shareable caches, and then if the process schedule to another core, the old TLB entries may occur MMU faults. Signed-off-by: Ding Tianhong --- arch/arm64/kernel/process.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 6391485..d7d8439 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -283,6 +283,13 @@ static void tls_thread_switch(struct task_struct *next) : : "r" (tpidr), "r" (tpidrro)); } +static void tlb_flush_thread(struct task_struct *prev) +{ + /* Flush the prev task's TLB entries */ + if (prev->mm) + flush_tlb_mm(prev->mm); +} + /* * Thread switching. */ @@ -296,6 +303,8 @@ struct task_struct *__switch_to(struct task_struct *prev, hw_breakpoint_thread_switch(next); contextidr_thread_switch(next); + tlb_flush_thread(prev); + /* * Complete any pending TLB or cache maintenance on this CPU in case * the thread migrates to a different CPU.