From patchwork Mon Jul 13 05:29:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 6774121 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 433A1C05AC for ; Mon, 13 Jul 2015 05:34:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 67863205D8 for ; Mon, 13 Jul 2015 05:34:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7178820678 for ; Mon, 13 Jul 2015 05:34:02 +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 1ZEWKN-0003W5-VE; Mon, 13 Jul 2015 05:30:55 +0000 Received: from mail-pa0-f44.google.com ([209.85.220.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZEWKL-0003Tf-AB for linux-arm-kernel@lists.infradead.org; Mon, 13 Jul 2015 05:30:53 +0000 Received: by pachj5 with SMTP id hj5so25773743pac.3 for ; Sun, 12 Jul 2015 22:30:31 -0700 (PDT) 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:in-reply-to :references; bh=pZo237xUC4d4GqZcQfMuaDA+jzv4AQkppGDxe9Ucz20=; b=K8vUS5EG1FllR4mbK/NMPC+CLOImlTlBJX2kql9OgWH5/TlRDm7zuMFx8x4wVLh0g4 QNM+WxuGTItveuIbq4+vu4wLGK8hDp8fpeZBnpLTara9a4PUopps+5agqyVpt15ehNiC 2+jdd/OknGeoOWXzwL6Nc7IoM5uKOTl7hEPgr67RQ1DARmLm9g/Y4afNCkObFDo+Z0J3 sxqD4+cctJkaCHMA1WrA4Hb+m1Ey6NfakW4WsCF8PXPtytTvv5LcEsxrUKeYn5T7BmoN 1dpj3yTw9cbVU5bbQD9W9OFACtVaYNhED1u+GfAlIVS5WsNa2L4i6l+KlIsjJeZW9EeL Ru4A== X-Gm-Message-State: ALoCoQkdUNrOcJjiAJX+BGLVKb/6/9fN0ND5xAzxaZ00bWtz1418zLYhjoOTjTUuGndysWufBYFC X-Received: by 10.70.22.235 with SMTP id h11mr66436497pdf.135.1436765431811; Sun, 12 Jul 2015 22:30:31 -0700 (PDT) Received: from localhost.localdomain (61-205-7-98m5.grp1.mineo.jp. [61.205.7.98]) by smtp.googlemail.com with ESMTPSA id cz1sm16903229pbc.84.2015.07.12.22.30.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 12 Jul 2015 22:30:30 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, rostedt@goodmis.org Subject: [RFC 1/3] ftrace: adjust a function's pc to search for in check_stack() for arm64 Date: Mon, 13 Jul 2015 14:29:33 +0900 Message-Id: <1436765375-7119-2-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436765375-7119-1-git-send-email-takahiro.akashi@linaro.org> References: <1436765375-7119-1-git-send-email-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150712_223053_386820_24CC9107 X-CRM114-Status: GOOD ( 12.68 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jungseoklee85@gmail.com, linux-kernel@vger.kernel.org, AKASHI Takahiro , broonie@kernel.org, david.griego@linaro.org, olof@lixom.net, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Ftace's stack tracer on arm64 returns wrong information about call stacks: Depth Size Location (50 entries) ----- ---- -------- 0) 5256 0 notifier_call_chain+0x30/0x94 1) 5256 0 ftrace_call+0x0/0x4 2) 5256 0 notifier_call_chain+0x2c/0x94 3) 5256 0 raw_notifier_call_chain+0x34/0x44 4) 5256 0 timekeeping_update.constprop.9+0xb8/0x114 5) 5256 0 update_wall_time+0x408/0x6dc Most of 'Size' fields are unexpectedly zero. This is because stack tracer fails to recognize each function's stack frame in check_stack(). Stack tracer searches for a function's pc in the stack based on the list returned by save_stack_trace(), but save_stack_trace() on arm64 does not return the exact return address saved in a stack frame, but a value decrmented by 4 (which means a branch instruction's address). This behavior was introduced by commit e306dfd06fcb ("ARM64: unwind: Fix PC calculation") So the matching doesn't succeed in most cases. This problem can be fixed either by a) reverting the commit above b) adding an arm64-specific hack to check_patch() This patch does b). Signed-off-by: AKASHI Takahiro --- kernel/trace/trace_stack.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c index 3f34496..7086fc3 100644 --- a/kernel/trace/trace_stack.c +++ b/kernel/trace/trace_stack.c @@ -143,7 +143,11 @@ check_stack(unsigned long ip, unsigned long *stack) p = start; for (; p < top && i < max_stack_trace.nr_entries; p++) { +#ifdef CONFIG_ARM64 + if (*p == (stack_dump_trace[i] + 4)) { +#else if (*p == stack_dump_trace[i]) { +#endif this_size = stack_dump_index[i++] = (top - p) * sizeof(unsigned long); found = 1;