From patchwork Wed Oct 14 07:13:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 54888 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by patches.linaro.org (Postfix) with ESMTPS id F130623012 for ; Wed, 14 Oct 2015 07:13:47 +0000 (UTC) Received: by lbcao8 with SMTP id ao8sf20750321lbc.1 for ; Wed, 14 Oct 2015 00:13:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:subject:to:references:cc:from :message-id:date:user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=gk3lu0U4lynMSqROYuixxfxZTWqSarfYrB3psnl1J9k=; b=SXpw78ZzQFMIPRNi23Ld4GzJJdJmuQ9QH83ormzlywFgF1HDMlZsgR/XFxvBxYovKV CuUdQ6O2vJNzHFH1Nj1o4S6c1pTNTh8lVcSgDB4VHzVFLDpcN+/73E/wKUaUBCA/bYYD qHQHN7g3QuS8+qCMl/8HXoJAAJUqNheh3Kchvtw6UDNYb1HZrPgz48fp9xSsdCq0yhyz VGYlLRJW7RQXDjEvDlVRmVh3sAl1487pQGRBCpQjJAQuUcekSh53rpBq7qzdj3Y0T5M8 Y4olvY9D3Te2rnXuPzNdsRy77YlqWXvda/6WkTayXRIcOOyxzQed28dPJASkL4ie1YrQ iDMA== X-Gm-Message-State: ALoCoQmqMrI7ULo4I/7LPQkdumT3Nudw/ghF+UwNR30Xhm3JZnuBRn4HTGDqAjklp+pKIPZUZK9F X-Received: by 10.112.184.170 with SMTP id ev10mr374057lbc.4.1444806826617; Wed, 14 Oct 2015 00:13:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.163.194 with SMTP id m185ls4002lfe.66.gmail; Wed, 14 Oct 2015 00:13:46 -0700 (PDT) X-Received: by 10.112.13.201 with SMTP id j9mr721948lbc.45.1444806826443; Wed, 14 Oct 2015 00:13:46 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id n18si4665137lfn.65.2015.10.14.00.13.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2015 00:13:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbbpp2 with SMTP id pp2so10310568lbb.0 for ; Wed, 14 Oct 2015 00:13:46 -0700 (PDT) X-Received: by 10.112.129.202 with SMTP id ny10mr698106lbb.112.1444806826186; Wed, 14 Oct 2015 00:13:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2544175lbq; Wed, 14 Oct 2015 00:13:45 -0700 (PDT) X-Received: by 10.66.162.168 with SMTP id yb8mr2137253pab.48.1444806824852; Wed, 14 Oct 2015 00:13:44 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fy5si11106763pbb.14.2015.10.14.00.13.44; Wed, 14 Oct 2015 00:13:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752840AbbJNHNn (ORCPT + 30 others); Wed, 14 Oct 2015 03:13:43 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:33899 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752522AbbJNHNi (ORCPT ); Wed, 14 Oct 2015 03:13:38 -0400 Received: by pabws5 with SMTP id ws5so15335901pab.1 for ; Wed, 14 Oct 2015 00:13:37 -0700 (PDT) X-Received: by 10.66.221.104 with SMTP id qd8mr2052257pac.155.1444806817474; Wed, 14 Oct 2015 00:13:37 -0700 (PDT) Received: from [192.168.1.225] (61-205-2-169m5.grp1.mineo.jp. [61.205.2.169]) by smtp.googlemail.com with ESMTPSA id yl2sm7545466pac.46.2015.10.14.00.13.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2015 00:13:36 -0700 (PDT) Subject: Re: [PATCH v4 2/2] arm64: Expand the stack trace feature to support IRQ stack To: James Morse , Jungseok Lee References: <1444231692-32722-1-git-send-email-jungseoklee85@gmail.com> <1444231692-32722-3-git-send-email-jungseoklee85@gmail.com> <5617CE26.10604@arm.com> Cc: catalin.marinas@arm.com, will.deacon@arm.com, linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, barami97@gmail.com, linux-kernel@vger.kernel.org From: AKASHI Takahiro Message-ID: <561E009B.3070001@linaro.org> Date: Wed, 14 Oct 2015 16:13:31 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <5617CE26.10604@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: takahiro.akashi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On 10/09/2015 11:24 PM, James Morse wrote: > Hi Jungseok, > > On 07/10/15 16:28, Jungseok Lee wrote: >> Currently, a call trace drops a process stack walk when a separate IRQ >> stack is used. It makes a call trace information much less useful when >> a system gets paniked in interrupt context. > > panicked > >> This patch addresses the issue with the following schemes: >> >> - Store aborted stack frame data >> - Decide whether another stack walk is needed or not via current sp >> - Loosen the frame pointer upper bound condition > > It may be worth merging this patch with its predecessor - anyone trying to > bisect a problem could land between these two patches, and spend time > debugging the truncated call traces. > > >> diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h >> index 6ea82e8..e5904a1 100644 >> --- a/arch/arm64/include/asm/irq.h >> +++ b/arch/arm64/include/asm/irq.h >> @@ -2,13 +2,25 @@ >> #define __ASM_IRQ_H >> >> #include >> +#include >> >> #include >> >> struct irq_stack { >> void *stack; >> + struct stackframe frame; >> }; >> >> +DECLARE_PER_CPU(struct irq_stack, irq_stacks); > > Good idea, storing this in the per-cpu data makes it immune to stack > corruption. Is this the only reason that you have a dummy stack frame in per-cpu data? By placing this frame in an interrupt stack, I think, we will be able to eliminate changes in dump_stace(). and > >> diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c >> index 407991b..5124649 100644 >> --- a/arch/arm64/kernel/stacktrace.c >> +++ b/arch/arm64/kernel/stacktrace.c >> @@ -43,7 +43,27 @@ int notrace unwind_frame(struct stackframe *frame) >> low = frame->sp; >> high = ALIGN(low, THREAD_SIZE); >> >> - if (fp < low || fp > high - 0x18 || fp & 0xf) >> + /* >> + * A frame pointer would reach an upper bound if a prologue of the >> + * first function of call trace looks as follows: >> + * >> + * stp x29, x30, [sp,#-16]! >> + * mov x29, sp >> + * >> + * Thus, the upper bound is (top of stack - 0x20) with consideration > > The terms 'top' and 'bottom' of the stack are confusing, your 'top' appears > to be the highest address, which is used first, making it the bottom of the > stack. > > I would try to use the terms low/est and high/est, in keeping with the > variable names in use here. > > >> + * of a 16-byte empty space in THREAD_START_SP. >> + * >> + * The value, 0x20, however, does not cover all cases as interrupts >> + * are handled using a separate stack. That is, a call trace can start >> + * from elx_irq exception vectors. The symbols could not be promoted >> + * to candidates for a stack trace under the restriction, 0x20. >> + * >> + * The scenario is handled without complexity as 1) considering >> + * (bottom of stack + THREAD_START_SP) as a dummy frame pointer, the >> + * content of which is 0, and 2) allowing the case, which changes >> + * the value to 0x10 from 0x20. > > Where has 0x20 come from? The old value was 0x18. > > My understanding is the highest part of the stack looks like this: > high [ off-stack ] > high - 0x08 [ left free by THREAD_START_SP ] > high - 0x10 [ left free by THREAD_START_SP ] > high - 0x18 [#1 x30 ] > high - 0x20 [#1 x29 ] > > So the condition 'fp > high - 0x18' prevents returning either 'left free' > address, or off-stack-value as a frame. Changing it to 'fp > high - 0x10' > allows the first half of that reserved area to be a valid stack frame. > > This change is breaking perf using incantations [0] and [1]: > > Before, with just patch 1/2: > ---__do_softirq > | > |--92.95%-- __handle_domain_irq > | __irqentry_text_start > | el1_irq > | > > After, with both patches: > ---__do_softirq > | > |--83.83%-- __handle_domain_irq > | __irqentry_text_start > | el1_irq > | | > | |--99.39%-- 0x400008040d00000c > | --0.61%-- [...] > | This also shows that walk_stackframe() doesn't walk through a process stack. Now I'm trying the following hack on top of Jungseok's patch. (It doesn't traverse from an irq stack to an process stack yet. I need modify unwind_frame().) Thanks, -Takahiro AKASHI ----8<---- --- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 650cc05..5fbd1ea 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -185,14 +185,12 @@ alternative_endif mov x23, sp and x23, x23, #~(THREAD_SIZE - 1) cmp x20, x23 // check irq re-enterance + mov x19, sp beq 1f - str x29, [x19, #IRQ_FRAME_FP] - str x21, [x19, #IRQ_FRAME_SP] - str x22, [x19, #IRQ_FRAME_PC] - mov x29, x24 -1: mov x19, sp - csel x23, x19, x24, eq // x24 = top of irq stack - mov sp, x23 + mov sp, x24 // x24 = top of irq stack + stp x29, x22, [sp, #-32]! + mov x29, sp +1: .endm /*