From patchwork Sun Jul 9 08:30:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ding Tianhong X-Patchwork-Id: 9831709 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 126DF602A0 for ; Sun, 9 Jul 2017 08:31:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1C2027165 for ; Sun, 9 Jul 2017 08:31:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E647F28068; Sun, 9 Jul 2017 08:31:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 535C028210 for ; Sun, 9 Jul 2017 08:31:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Date:Message-ID:To:Subject :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=+Wa8iX0nwQg09glZqSLZmiZCtLgelpX9DnaPMh3z5Bo=; b=OoZwWw4OfVo8pa r3rMy7IdX42OxfZAWI0vhaPeti2IaZdgRZM1m6oJ+HzLbJZWvEYATj/GhwZQUeNPF5E2ZmwsC038X ZZC5XXeDCDb5UhoyL/yeT1GyG0H/VNnARV1EdSZHBxqdS6+iEglx/Rl4fBKy9rTsZmkEMtaDw2dNx XfWzsE4pHyNQTpffaF+tXlMXBMpwrNnDptypwewBlAgo05Qb/4d2FWGt8uyXH/vB4SOHCAlHTDgQH cF/SRF8Dutx9E/vm98hzWH89x2wt26Ter9mYLGNO9UbbXuqPSSZjSVSzdmM+P6pQcV7oQLvykE4zl 17hv6XWohExqsbWskNog==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dU7d2-0007Wq-Ly; Sun, 09 Jul 2017 08:31:44 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dU7cy-0007W1-LL for linux-arm-kernel@lists.infradead.org; Sun, 09 Jul 2017 08:31:42 +0000 Received: from 10.3.17.39 (EHLO DGGEML404-HUB.china.huawei.com) ([10.3.17.39]) by dggrg02-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AQT14790; Sun, 09 Jul 2017 16:31:10 +0800 (CST) Received: from [127.0.0.1] (10.177.23.32) by DGGEML404-HUB.china.huawei.com (10.3.17.39) with Microsoft SMTP Server id 14.3.301.0; Sun, 9 Jul 2017 16:31:01 +0800 From: Ding Tianhong Subject: [PATCH RESEND] arm64: arch_timer: fix the infinite recursion when enable ftrace and erratum workaround To: Mark Rutland , Marc Zyngier , Catalin Marinas , Will Deacon , LinuxArm , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Message-ID: <321e4c16-aa14-beee-b6dc-36e19e5ec35a@huawei.com> Date: Sun, 9 Jul 2017 16:30:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-Originating-IP: [10.177.23.32] X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.5961E9CE.00F6, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 8fe5dbb3e72fafa57868c208cf6da254 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170709_013141_100152_C3AA273A X-CRM114-Status: UNSURE ( 9.67 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 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-Virus-Scanned: ClamAV using ClamSMTP When enable preempt and debug ftrace, and perform the following steps, the system will hang: mount -t debugfs nodev /sys/kernel/debug/ cd /sys/kernel/debug/tracing/ echo function_graph > current_tracer This is because tracing the preempt_disable/enable calls would cause trace_clock() which would get local timer to go into infinite recursion when enable the arch timer erratum workaround for some chips, so Prevent tracing of preempt_disable/enable() in arch_timer_reg_read_stable(). This problem is similar to the fixed by upstream commit 96b3d28bf4 ("sched/clock: Prevent tracing recursion in sched_clock_cpu()"). Fixes: 6acc71ccac71 ("arm64: arch_timer: Allows a CPU-specific erratum to only affect a subset of CPUs") Signed-off-by: Ding Tianhong Tested-by: Hanjun Guo Acked-by: Mark Rutland Acked-by: Marc Zyngier --- arch/arm64/include/asm/arch_timer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h index 74d08e4..67bb7a4 100644 --- a/arch/arm64/include/asm/arch_timer.h +++ b/arch/arm64/include/asm/arch_timer.h @@ -65,13 +65,13 @@ struct arch_timer_erratum_workaround { u64 _val; \ if (needs_unstable_timer_counter_workaround()) { \ const struct arch_timer_erratum_workaround *wa; \ - preempt_disable(); \ + preempt_disable_notrace(); \ wa = __this_cpu_read(timer_unstable_counter_workaround); \ if (wa && wa->read_##reg) \ _val = wa->read_##reg(); \ else \ _val = read_sysreg(reg); \ - preempt_enable(); \ + preempt_enable_notrace(); \ } else { \ _val = read_sysreg(reg); \ } \