From patchwork Thu Sep 1 13:35:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pratyush Anand X-Patchwork-Id: 9309057 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 B7D9160756 for ; Thu, 1 Sep 2016 13:37:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE5302941C for ; Thu, 1 Sep 2016 13:37:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B320A29421; Thu, 1 Sep 2016 13:37:20 +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=-3.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id AC18429420 for ; Thu, 1 Sep 2016 13:37:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bfS9i-0001bH-D2; Thu, 01 Sep 2016 13:35:46 +0000 Received: from mail-yb0-f174.google.com ([209.85.213.174]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bfS9d-00015A-QU for linux-arm-kernel@lists.infradead.org; Thu, 01 Sep 2016 13:35:43 +0000 Received: by mail-yb0-f174.google.com with SMTP id 125so28027718ybe.3 for ; Thu, 01 Sep 2016 06:35:21 -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; bh=Sl0QAJWhdhl9hEv/CI5caXn3VXEclKxcFQ0av0gttJo=; b=mtgW6eleAQDf9LXdh9Ba9+QaLqvaD3EnGs/OWWsWIanWBnGpRGQrCxaEXWWiFz1KJZ iHuF61Qr5W4Ys/P4ELi1lg6SOfcwh3fB0oGm1alOgIF792Y3yVkrPiZ2INjLWlEV67a9 FtmgpEX+ONwYezFPdvOwIKwXeQHrg+jPK8l06lhUnzP8ac8E2XopCI0+zisFcBWbkuB7 ch0dqzYRUgOVKzWM1kcCnopyW1tq6Bab/wDx3vNIzsGhxseWKIIoQoyBAP5Nec/XvKRI TZjTME+O8S+RYFLszhzdLRDD9imnT0ne145QCQAqtUTBi9UctpgLryT4xpVLx1IWnjq8 kebQ== X-Gm-Message-State: AE9vXwPVn43qjEVptfpIy/lGiPl2FFyZFrKuZQNE2ZGHmH48rsqi1EMbIzSScMHK1GDKQBCR X-Received: by 10.37.60.67 with SMTP id j64mr12761074yba.111.1472736920618; Thu, 01 Sep 2016 06:35:20 -0700 (PDT) Received: from localhost ([122.180.204.190]) by smtp.gmail.com with ESMTPSA id s126sm1730394yws.13.2016.09.01.06.35.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Sep 2016 06:35:19 -0700 (PDT) From: Pratyush Anand To: takahiro.akashi@linaro.org, dave.long@linaro.org Subject: [PATCH V2] arm64:ftrace: add save_stack_trace_regs() Date: Thu, 1 Sep 2016 19:05:16 +0530 Message-Id: <4f7d7a6bff7f06f814bf9a2bdc90bb0e3b833b66.1472734699.git.panand@redhat.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160901_063541_976332_EFB44B12 X-CRM114-Status: GOOD ( 11.34 ) 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: catalin.marinas@arm.com, will.deacon@arm.com, james.morse@arm.com, 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-Virus-Scanned: ClamAV using ClamSMTP Implement save_stack_trace_regs, so that stacktrace of a kprobe events can be obtained. Signed-off-by: Pratyush Anand Reviewed-by: James Morse --- V1 to V2: Rebased to latest kernel. I see following stack trace for kprobe at xhci_irq(): echo stacktrace > /sys/kernel/debug/tracing/trace_options echo "p xhci_irq" > /sys/kernel/debug/tracing/kprobe_events echo 1 > /sys/kernel/debug/tracing/events/kprobes/enable more /sys/kernel/debug/tracing/trace -0 [004] d.h. 1356.000496: p_xhci_irq_0:(xhci_irq+0x0/0x9ac) -0 [004] d.h. 1356.000497: => xhci_irq => __handle_irq_event_percpu => handle_irq_event_percpu => handle_irq_event => handle_fasteoi_irq => generic_handle_irq => __handle_domain_irq => gic_handle_irq => el1_irq => arch_cpu_idle => default_idle_call => cpu_startup_entry => secondary_start_kernel => arch/arm64/kernel/stacktrace.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index d9751a4769e7..bd6d9d8087f0 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -152,6 +152,24 @@ static int save_trace(struct stackframe *frame, void *d) return trace->nr_entries >= trace->max_entries; } +void save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace) +{ + struct stack_trace_data data; + struct stackframe frame; + + data.trace = trace; + data.skip = trace->skip; + data.no_sched_functions = 0; + + frame.fp = regs->regs[29]; + frame.sp = regs->sp; + frame.pc = regs->pc; + + walk_stackframe(current, &frame, save_trace, &data); + if (trace->nr_entries < trace->max_entries) + trace->entries[trace->nr_entries++] = ULONG_MAX; +} + void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) { struct stack_trace_data data;