From patchwork Sun Jun 21 01:10:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 6651861 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3A3DBC05AD for ; Sun, 21 Jun 2015 01:11:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56813206AD for ; Sun, 21 Jun 2015 01:11:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 83884206AF for ; Sun, 21 Jun 2015 01:11:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755605AbbFUBLI (ORCPT ); Sat, 20 Jun 2015 21:11:08 -0400 Received: from mail-lb0-f182.google.com ([209.85.217.182]:34593 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932520AbbFUBLH (ORCPT ); Sat, 20 Jun 2015 21:11:07 -0400 Received: by lbbti3 with SMTP id ti3so90677068lbb.1 for ; Sat, 20 Jun 2015 18:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hbjF0SEOF0jMUyxMvs52zZOJmSGwbwApxvO+FkpJ5Do=; b=W0xDaXn6uGJ7ubgkn5OWFzxqzRFo334KF/9HDvQ0fZxzCvX5Ok9xxwe1CGR/yOPy8w XmEmJeUCqZx6EXDXpcIkybHAc3oXy7701WA/evC04MH+tBMQJ8R3O+Bld48pntNm31gr A2v8eDqBW/dYb5QjAmnBRJ+PkKlDMraYwhUwI= 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:in-reply-to :references; bh=hbjF0SEOF0jMUyxMvs52zZOJmSGwbwApxvO+FkpJ5Do=; b=lCQ6B/dNjP1M8zSBmCwM5QCWNiYeC1ofUeTGVOueoO30FAeq9q9BIYXzxNGwyhW169 uPSOOYrrGGVCfQWr67MhDAwfgvgaRjMo/nF/BTMaAdmQSIunFh8ePrHabbon1NHte33w 9a6aP1GY6FlQCwXgUs0OusHjlGmxUPjQFkUicikG5f3ENzxr8zTaL73o9SrIfYS4B2A0 u3kJXRC6dBF5/qFzoBsqFZtqdEeb5N/EKJp+gLmzZ29FcLDAcurjYZtqyMtkvb2wy8XO oS2or0voSR+ohTLCk4TU+dhnt0K7FybZUMSQP2wfxBSa4FmqCPqifqHEMNSyQGtdMov2 EaHg== X-Gm-Message-State: ALoCoQkj7XBnj/3BUwQA4pU1hXirR5CST6UNweVjkhQuf9hloDXpmRsIJRnEb7zk1Jt0xCS9hgBc X-Received: by 10.152.120.135 with SMTP id lc7mr23653713lab.107.1434849065169; Sat, 20 Jun 2015 18:11:05 -0700 (PDT) Received: from spencer.imf.au.dk ([130.225.20.51]) by mx.google.com with ESMTPSA id k10sm3602165lbq.9.2015.06.20.18.11.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Jun 2015 18:11:04 -0700 (PDT) From: Rasmus Villemoes To: Michal Marek Cc: linux-kbuild@vger.kernel.org, Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [RFC 1/4] scripts: add stackusage script Date: Sun, 21 Jun 2015 03:10:43 +0200 Message-Id: <1434849046-19920-2-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1434849046-19920-1-git-send-email-linux@rasmusvillemoes.dk> References: <1434849046-19920-1-git-send-email-linux@rasmusvillemoes.dk> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current checkstack.pl script has a few problems, stemming from the overly simplistic attempt at parsing objdump output with regular expresions: For example, on x86_64 it doesn't take the push instruction into account, making it consistently underestimate the real stack use, and it also doesn't capture stack pointer adjustments of exactly 128 bytes [1]. Since newer gcc (>= 4.6) knows about -fstack-usage, we might as well take the information straight from the horse's mouth. This patch introduces scripts/stackusage, which is a simple wrapper for running make with EXTRA_CFLAGS set to -fstack-usage. Example use is scripts/stackusage -o out.su -- -j8 fs/ext4/ Arguments after -- are passed to make. Afterwards, we find all newly created .su files, massage them a little, sort by stack use and concatenate the result to a single output file. [1] Since gcc encodes that by 48 83 c4 80 add $0xffffffffffffff80,%rsp and not 48 81 ec 80 00 00 00 sub $0x80,%rsp since -128 fits in an imm8. Signed-off-by: Rasmus Villemoes --- scripts/stackusage | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 scripts/stackusage diff --git a/scripts/stackusage b/scripts/stackusage new file mode 100755 index 000000000000..d631af648ae7 --- /dev/null +++ b/scripts/stackusage @@ -0,0 +1,40 @@ +#!/bin/sh + +outfile="" +now=`date +%s` + +while [ $# -gt 0 ] +do + case "$1" in + -o) + outfile="$2" + echo "$outfile" + shift 2;; + -h) + echo "usage: $0 [-o outfile] -- " + exit 0;; + --) + shift + break;; + -*) + echo >&2 "usage: $0 [-o outfile] -- " + exit 1;; + *) break;; + esac +done + +if [ -z "$outfile" ] +then + outfile=`mktemp --tmpdir stackusage.$$.XXXX` +fi + +make EXTRA_CFLAGS="-fstack-usage" "$@" + +# Prepend directory name to file names, remove line/column +# information, make file/function/size/type properly tab-separated. +find . -name '*.su' -newermt "@${now}" -print | \ + xargs perl -MFile::Basename -pe \ + '$d = dirname($ARGV); s#([^:]+):([0-9]+:){2}#$d/$1\t#;' | \ + sort -k3,3nr > "${outfile}" + +echo "$0: output written to ${outfile}"