From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua1-x932.google.com ([2607:f8b0:4864:20::932]) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1gNXPz-0005ai-Ht for kernelnewbies@kernelnewbies.org; Fri, 16 Nov 2018 01:15:51 -0500 Received: by mail-ua1-x932.google.com with SMTP id p9so7891404uaa.5 for ; Thu, 15 Nov 2018 22:15:50 -0800 (PST) MIME-Version: 1.0 References: <28496.1542300549@turing-police.cc.vt.edu> In-Reply-To: <28496.1542300549@turing-police.cc.vt.edu> From: Pintu Agarwal Date: Fri, 16 Nov 2018 11:44:36 +0530 Message-ID: Subject: Re: [ARM64] Printing IRQ stack usage information To: Valdis Kletnieks Cc: mark.rutland@arm.com, Jungseok Lee , kernelnewbies@kernelnewbies.org, catalin.marinas@arm.com, Sungjinn Chung , will.deacon@arm.com, open list , Russell King - ARM Linux , Takahiro Akashi , linux-arm-kernel@lists.infradead.org List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org Message-ID: <20181116061436.koNIPaEPXZBiOC7_qO8DTvJzaPupxe3tsPA-8vf8wCQ@z> On Thu, 15 Nov 2018, 10:19 pm > On Thu, 15 Nov 2018 18:52:39 +0530, Pintu Agarwal said: > > > Currently, when I tested this (as a proc interface), I got the below output: > > CPU UNUSED-STACK ACTUAL-STACK > > 0 16368 16384 > > > 3) How should I test it to get the different usage values for unused stack ? > > Can I get these values by implementing a sample interrupt handler, > > and printing information from there? > > Hint 1: If you're in a state where seq_printf() is legal, how many IRQ's are > on this processor's IRQ stack? > > Hint 2: What are the chances that some other CPU is currently in an IRQ? > (run 'top' and look for what percent of time that's happening) > > Hint 3: what are the chances that the value of irq_stack_ptr is already stale > by the time seq_printf() finishes running? > > Hint 4: what happens to the validity of your output if you get rescheduled > in the middle of that for_each loop? > > (In other words, this code is terribly racy and is probably not going to answer > whatever debugging question you were working on.. Okay. Thanks so much for your hints. Yes, I understand that this code is horribly ugly and bad. But this is only to understand if the below logic is fine to get the irq stack usage: {{{ for_each_present_cpu(cpu) { irq_stack_ptr = IRQ_STACK_PTR(cpu); //unsigned long sp = current_stack_pointer; stack_start = (unsigned long)per_cpu(irq_stack, cpu); free_stack = irq_stack_ptr - stack_start; seq_printf(m, "%2d %10lu %10d\n", cpu, free_stack, actual); } }}} Of course, final plan is not the proc entry, but to find a relevant place to invoke it, probably during boot time, or during backtrace. > If your question is "Did one > of the CPUs blow out its IRQ stack (or come close to doing so)?" there's better > approaches. > Yes, exactly, this is what the main intention. If you have any better idea about this approach, please refer me. It will be of great help. Thank You! > _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies