Received: by 10.213.65.68 with SMTP id h4csp2490922imn; Mon, 9 Apr 2018 04:29:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx48ol0dO6k7Mm+ecMo6TzdzsgNorPmZj1sNTzQhJ37fwSJqh0M534PNoOjkzkUn/CpoDQ4n4 X-Received: by 2002:a17:902:2ac3:: with SMTP id j61-v6mr38060116plb.224.1523273383767; Mon, 09 Apr 2018 04:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523273383; cv=none; d=google.com; s=arc-20160816; b=XCrOrvWce54GvOK/pROItYJ3EjBOWA6gyumeLgClZgMZUS+5xfkI9FDg0ETsBvmLc6 utKyQoKcQaPa9CO19W9dngINcyKz4Tks9PYsB5G0zpZ8690rHFlf6FS+lXUoBDVpVBPy xj3igYmgaHOOG35A6NP2mH/mduZ3wlo2w8sui03bYzUCr6Rb1kqMPip2mQF8m/XnS1k1 MPcj6GuFIgbvnN6dO+KoM35kPEQ8Up6EU6pgc6T5XH0oXqRUJcO612uv/gZghrgSK9GZ 10lDtmUD2Ux2+d9JibnSezyAE7huku7G0K1hcOZLPXqr8YZLroCW9e4xlkp/6s6+k+9i qaNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=fnVQeJfw1Yp7WzoskdaBw7V7r6wpRYbbwE7sTUhF2HY=; b=QleHZ9G+ElMV++EYi2q8xFBufi2jO7+rwxtdGj2h+hD6gSXRVoCRp4GLmTNLnJLSf7 S+/53nWcuWJ9v+lUIO8+RKYcWg4Vsz8Cf+p3shNSKv8JYho/dv/5pJse4G05QWxUdMCU lQaSoW1hKUlNUIosVyiaUe0PFTB31BDoJ+MkiHZrd55KqKRvM61LtQrfbz5Tk5VzxglS 5dEmzbFBCJu8JSaAV2E3Xk8csBigvSx9j/KHDs/pjh0LgGjKCn6jRqn2YVX/PW5EtxXP lM2BVy/NX46dIxVOroLwod/rZTA/RjQhzX1z9lNTmoCHIQqcak9vcR+AGbXseuPgSbF4 VYRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1-v6si118323plk.611.2018.04.09.04.29.06; Mon, 09 Apr 2018 04:29:43 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751742AbeDIL0H (ORCPT + 99 others); Mon, 9 Apr 2018 07:26:07 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54974 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751671AbeDIL0F (ORCPT ); Mon, 9 Apr 2018 07:26:05 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 79BACF; Mon, 9 Apr 2018 04:26:05 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CF0E23F487; Mon, 9 Apr 2018 04:26:02 -0700 (PDT) Date: Mon, 9 Apr 2018 12:26:00 +0100 From: Mark Rutland To: "Ji.Zhang" Cc: Catalin Marinas , Will Deacon , Matthias Brugger , Ard Biesheuvel , James Morse , Dave Martin , Marc Zyngier , Michael Weiser , Julien Thierry , Xie XiuQi , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com, shadanji@163.com Subject: Re: [PATCH] arm64: avoid race condition issue in dump_backtrace Message-ID: <20180409112559.uh76jpiytznymw6w@lakrids.cambridge.arm.com> References: <1521687960-3744-1-git-send-email-ji.zhang@mediatek.com> <20180322055929.z25brvwlmdighz66@salmiak> <1521711329.26617.31.camel@mtksdccf07> <20180326113932.2i6qp3776jtmcqk4@lakrids.cambridge.arm.com> <1522229612.26617.47.camel@mtksdccf07> <20180328101240.moo44g5qd3qjuxgn@lakrids.cambridge.arm.com> <1522397292.26617.63.camel@mtksdccf07> <20180404090431.rqwtaqovipxa5gta@lakrids.cambridge.arm.com> <1523174328.26617.91.camel@mtksdccf07> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1523174328.26617.91.camel@mtksdccf07> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 08, 2018 at 03:58:48PM +0800, Ji.Zhang wrote: > Yes, I see where the loop is, I have missed that the loop may cross > different stacks. > Define a nesting order and check against is a good idea, and it can > resolve the issue exactly, but as you mentioned before, we have no idea > how to handle with overflow and sdei stack, and the nesting order is > strongly related with the scenario of the stack, which means if someday > we add another stack, we should consider the relationship of the new > stack with other stacks. From the perspective of your experts, is that > suitable for doing this in unwind? > > Or could we just find some way easier but not so accurate, eg. > Proposal 1: > When we do unwind and detect that the stack spans, record the last fp of > previous stack and next time if we get into the same stack, compare it > with that last fp, the new fp should still smaller than last fp, or > there should be potential loop. > For example, when we unwind from irq to task, we record the last fp in > irq stack such as last_irq_fp, and if it unwind task stack back to irq > stack, no matter if it is the same irq stack with previous, just let it > go and compare the new irq fp with last_irq_fp, although the process may > be wrong since from task stack it could not unwind to irq stack, but the > whole process will eventually stop. I agree that saving the last fp per-stack could work. > Proposal 2: > So far we have four types of stack: task, irq, overflow and sdei, could > we just assume that the MAX number of stack spanning is just 3 > times?(task->irq->overflow->sdei or task->irq->sdei->overflow), if yes, > we can just check the number of stack spanning when we detect the stack > spans. I also agree that counting the number of stack transitions will prevent an inifinite loop, even if less accurately than proposal 1. I don't have a strong preference either way. Thanks, Mark.