Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1179184imu; Tue, 20 Nov 2018 13:03:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/UJ3kLAI38f5KE9IvYphFl6jP6n0JQhNbuxSo7LG09o6u7TphnE08vFg/y1hxGP0C3gVdzR X-Received: by 2002:a17:902:7443:: with SMTP id e3mr925839plt.304.1542747799923; Tue, 20 Nov 2018 13:03:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542747799; cv=none; d=google.com; s=arc-20160816; b=hBkS0iwX0wyPojw5+lhFU4KfOjtyDEQu3XVkQcrGZsYzHMClywNUofsjcxIiS9uXm2 Dm7aX7bdKrdZLOoKEE3SlV9I6cFY5CnzSUPPJpLiYrl2ik2WDnJBreY4GACz0NjyoBkh rHNDfPoYVaXWhyG3f9CTQevQPm6Tvo+dZr5l7PMCi1i7UjLxaiN0veK5j5lOdhFg2OmN bmDLXF8EG989QjOb7c2OniSSNI2hbqIpjoMVBw0EeD0p3I9pxIOuWlYTBVAVn38CtxMh evNn0BlZMcXpir0CPaMnVzWEOlosnRNb7CmY1xtc4bJ3pC52HIKkoB8wy3hcospRx+BF nD5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:content-transfer-encoding :mime-version:references:in-reply-to:subject:cc:to:from; bh=QTkKDErc6r689Sg9iRsb9haYyB+sFdp4VijLGNcLpCA=; b=aQdAP4CcIMaJfi47jS5yKCw1eHYyuvn33C5/csnFp3nNRzP1KA5lFRlLAuS2ARF6Dj f4b4g4DkGTUQAa4B8Hl54vzBNAfxfZPlA+onqdDHEo1Ow7qvJkLlGelel8iBy6Si3nbA 2w8jH1SGKZcZ7b1qs75wfQUKmuF5jICL1BnFsl6V09bVBRbjIPm+JviGtwOm5o4m9aOB d/9/ExHqe0W90u1N/HLaAEQT1krm++MXzCwp09L/IDo8xj4vPi31iWmJz/BUNHZrTkYJ sszvqhM20KLFbvr/yVtEFzfZrTkDihwMRuPc/Cy/hAwo96vfk6d9XUuLNHPQ6VKBgGtF LUDg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vt.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10si29915407pfm.37.2018.11.20.13.03.01; Tue, 20 Nov 2018 13:03:19 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vt.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726442AbeKUFeS (ORCPT + 99 others); Wed, 21 Nov 2018 00:34:18 -0500 Received: from outbound.smtp.vt.edu ([198.82.183.121]:57994 "EHLO omr2.cc.vt.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726001AbeKUFeR (ORCPT ); Wed, 21 Nov 2018 00:34:17 -0500 Received: from mr6.cc.vt.edu (mr6.cc.ipv6.vt.edu [IPv6:2607:b400:92:8500:0:af:2d00:4488]) by omr2.cc.vt.edu (8.14.4/8.14.4) with ESMTP id wAKJ3cxA019062 for ; Tue, 20 Nov 2018 14:03:38 -0500 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by mr6.cc.vt.edu (8.14.7/8.14.7) with ESMTP id wAKJ3WDk004157 for ; Tue, 20 Nov 2018 14:03:38 -0500 Received: by mail-qt1-f197.google.com with SMTP id b16so973213qtc.22 for ; Tue, 20 Nov 2018 11:03:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to:references :mime-version:content-transfer-encoding:date:message-id; bh=QTkKDErc6r689Sg9iRsb9haYyB+sFdp4VijLGNcLpCA=; b=hPgFOhz8kSq4BLPAhyYoZhseH8Kiu+9xW+dneZbaqTSHyWFKbW67Vf3yRHxigdUwoY TErX8pgcQrmKBLvC8OwvS1QDcYNVmT56Mp0IF1wm36BMfEPgo39O/oyIp97dYA5UHT6Y l3nH2XzPMQvkKhuVIk51A2fk0Jye/SrdHaEUHuywHn9SYq0YfJ+8qPAbdSry4W25X7fm 0w8YF9vK2QxfssNWhXZDiBngIat7K+e4C3TenUNPDGjuMu0gN6eCVI+F44Qa47fv4zWx mVQ75wx/1BqAOvV6zjBgnPo/gZCcwwWgyjanxnRSN9x5achTas9M5th4qV8Li9UBfgtv kXqw== X-Gm-Message-State: AA+aEWYLiVIfCIRdTp4lMOEx85Uy976m5zP9jFLrOEcSvUcRFxuhOMxO rsQ3EAPzkfUx0UIByWbQUuzapcSsJurzx/oY2ekVaiGg1MKsevPzOA1nJGJvo13Bs9lUNtOf4xS o9Ppunwwvjjddza/mhjPiIjDASsiG09eRKbY= X-Received: by 2002:a37:6413:: with SMTP id y19mr2838294qkb.215.1542740612705; Tue, 20 Nov 2018 11:03:32 -0800 (PST) X-Received: by 2002:a37:6413:: with SMTP id y19mr2838277qkb.215.1542740612411; Tue, 20 Nov 2018 11:03:32 -0800 (PST) Received: from turing-police.cc.vt.edu (turing-police.cc.ipv6.vt.edu. [2001:468:c80:2103:f21f:afff:fe0c:8ada]) by smtp.gmail.com with ESMTPSA id n26sm7326271qkg.74.2018.11.20.11.03.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Nov 2018 11:03:29 -0800 (PST) From: valdis.kletnieks@vt.edu X-Google-Original-From: Valdis.Kletnieks@vt.edu X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7+dev To: Pintu Agarwal Cc: open list , linux-arm-kernel@lists.infradead.org, Russell King - ARM Linux , kernelnewbies@kernelnewbies.org, Jungseok Lee , catalin.marinas@arm.com, will.deacon@arm.com, Takahiro Akashi , mark.rutland@arm.com, Sungjinn Chung Subject: Re: [ARM64] Printing IRQ stack usage information In-Reply-To: References: <28496.1542300549@turing-police.cc.vt.edu> <49219.1542367988@turing-police.cc.vt.edu> <5997.1542386778@turing-police.cc.vt.edu> <15703.1542393111@turing-police.cc.vt.edu> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==_Exmh_1542740607_2819P"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit Date: Tue, 20 Nov 2018 14:03:28 -0500 Message-ID: <38799.1542740608@turing-police.cc.vt.edu> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --==_Exmh_1542740607_2819P Content-Type: text/plain; charset=us-ascii On Tue, 20 Nov 2018 18:21:33 +0530, Pintu Agarwal said: > + sp = current_stack_pointer; > + if (on_irq_stack(sp, cpu)) { > + stack_start = (unsigned long)per_cpu(irq_stack, cpu); > + last_usage = per_cpu(irq_stack_usage, cpu); > + curr_usage = sp - stack_start; > + pr_info("cpu:%d : sp: %lu, stack_start: %lu, usage: %lu\n", cpu, sp, stack_start, (sp - stack_start)); > + if (curr_usage > last_usage) > + per_cpu(irq_stack_usage, cpu) = curr_usage; > + } This code only works if called from the function that uses the deepest amount of stack, because curr_usage depends on the current stack pointer. If some other routine went 2,934 bytes further into the stack and then returned, you'll never know. What you want instead is a way to see what the deepest point reached during the current call, and compare that to the previous low. How to detect the used stack? Go look at how the code currently detects how deep the kernel stacks reached. (Hint 1: look at check_stack_usage() in kernel/exit.c and stack_not_used(). Hint 2: what other support code is implied by the implementation of stack_not used()? > Which is the best place to invoke this ? > I have the following option: > 1. kernel/softirq.c => __do_softirq() > 2. arch/arm64/kernel/smp.c => handle_IPI() > 3. kernel/softirq.c => irq_exit() > 4. ??? Pondering the above, what other implementations might work? Hint: if you have a similar irq_stack_not_used() function, do you need any additional code in *any* of those 4 places? (And yes, I could just splat out the needed code - but you'd learn nowhere near as much that way.. :) --==_Exmh_1542740607_2819P Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Comment: Exmh version 2.9.0 11/07/2018 iQEVAwUBW/Raf40DS38y7CIcAQJlIAf/ZwgLssOW1kKbDHlhdiZqMxTkeroALLNs PsLoezZywUY+BnN27zys0F6zRG6t11P29NhoI5sCMSHwRliulMmfFb2AABtlW93e R2Y6YbgbI47wnZw4KUDB09ty14r+DlT7O1ETBqIsmtkeGx1JVBePnRGGiljGIJV4 Jfj8aGNzKPqt4X/nt/by2frSne7H6kkoCOjvcjKzCLFXkGTSuiiYxyq/ldu299nW OR2+9XtfukCMe0jOvVdWagj70C4EkoLlAjjGOFvmX8ogBrtMkklgBkehaYBc99sL JkrRRC8VZzTxzw1CQEh91DMrxtZaY7nSjSNSysMACB6U1fTOfywB7g== =TbrW -----END PGP SIGNATURE----- --==_Exmh_1542740607_2819P--