From nobody Thu Dec 18 07:11:31 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3327C197A0 for ; Mon, 20 Nov 2023 18:39:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232509AbjKTSjH (ORCPT ); Mon, 20 Nov 2023 13:39:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232981AbjKTSiy (ORCPT ); Mon, 20 Nov 2023 13:38:54 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75AA11FDB for ; Mon, 20 Nov 2023 10:37:35 -0800 (PST) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AKIHJUs020976; Mon, 20 Nov 2023 18:37:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=E/vsR2CcymYSm985vL9ENNfIO2zw1NKuUZb7kmUZ170=; b=Vkd6eJ/18pLUhz2fwtivxOjtkCWkqw/Ww14fOiWnTKfT59KIXNc3qR4OsUXLcKuc6c7q sb/KnZOLz7roYcedLbKuCE4OcYOJMA+U6Zxi3zMh3lOKueo+y1NHySumGpLpuZbtxm4J 3waMnWWi8ktbk0w6P1/ZRrMCThbLTR1B6w5QIoNU/sDmFPwvjVLuGAttg+5HINHmGybM zVkFYKNYM3WrUwIR6UzS/XvSPUqSEyOwb8Ay29uNkPHnNCbwhV7SxKRpxJwcUY4UeHHC RmdTLIUWZXSar/7pAJU9H0OI303/19jydlisvs7huOkQVQfugploTfLETNxazV0axcaL Eg== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ugckm8h8f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Nov 2023 18:37:23 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AKIJ3Ui004451; Mon, 20 Nov 2023 18:37:22 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uf93kk6nw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Nov 2023 18:37:21 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AKIbJYr24511162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Nov 2023 18:37:20 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CCFFE20040; Mon, 20 Nov 2023 18:37:19 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B2B262004B; Mon, 20 Nov 2023 18:37:19 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 20 Nov 2023 18:37:19 +0000 (GMT) From: Heiko Carstens To: Andrew Morton , Masahiro Yamada Cc: Vaneet Narang , Maninder Singh , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] checkstack: fix printed address Date: Mon, 20 Nov 2023 19:37:17 +0100 Message-Id: <20231120183719.2188479-2-hca@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231120183719.2188479-1-hca@linux.ibm.com> References: <20231120183719.2188479-1-hca@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: wl8vcNd4LKOuvg-on9YCrW2Dwi4CLeR4 X-Proofpoint-GUID: wl8vcNd4LKOuvg-on9YCrW2Dwi4CLeR4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-20_19,2023-11-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=0 mlxlogscore=979 mlxscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311200134 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" All addresses printed by checkstack have an extra incorrect 0 appended at the end. This was introduced with commit 677f1410e058 ("scripts/checkstack.pl: don't display $dre as different entity"): since then the address is taken from the line which contains the function name, instead of the line which contains stack consumption. E.g. on s390: 0000000000100a30 : ... 100a44: e3 f0 ff 70 ff 71 lay %r15,-144(%r15) So the used regex which matches spaces and hexadecimal numbers to extract an address now matches a different substring. Subsequently replacing spaces with 0 appends a zero at the and, instead of replacing leading spaces. Fix this by using the proper regex, and simplify the code a bit. Fixes: 677f1410e058 ("scripts/checkstack.pl: don't display $dre as differen= t entity") Signed-off-by: Heiko Carstens --- scripts/checkstack.pl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index d83ba5d8f3f4..f27d552aec43 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl @@ -138,15 +138,11 @@ $total_size =3D 0; while (my $line =3D ) { if ($line =3D~ m/$funcre/) { $func =3D $1; - next if $line !~ m/^($xs*)/; + next if $line !~ m/^($x*)/; if ($total_size > $min_stack) { push @stack, "$intro$total_size\n"; } - - $addr =3D $1; - $addr =3D~ s/ /0/g; - $addr =3D "0x$addr"; - + $addr =3D "0x$1"; $intro =3D "$addr $func [$file]:"; my $padlen =3D 56 - length($intro); while ($padlen > 0) { --=20 2.39.2 From nobody Thu Dec 18 07:11:31 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A68B0C197A0 for ; Mon, 20 Nov 2023 18:39:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232294AbjKTSjK (ORCPT ); Mon, 20 Nov 2023 13:39:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232607AbjKTSiz (ORCPT ); Mon, 20 Nov 2023 13:38:55 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFD9B1BF9 for ; Mon, 20 Nov 2023 10:37:35 -0800 (PST) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AKIHKYZ021021; Mon, 20 Nov 2023 18:37:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=+F/cUixVAYjDgd9Egr5Yd3zkGzwMoesXvpOYHsfswJE=; b=Uv48w3LgxsFvQ3PmUUGvFxuEgsHl2OxjfQn9tziRgiTPsmLs8YY6g1f4N6izpW8gn8fo Hb+PmXDJ7s9DgIK4OrZCE+2gegg0py30ezzyDs2lKcufzFf1q3f3h+wx+IeFfyNyBQsP MenFpBnG2OvJLpWUqG0Xs5KYD/kg+88B2+jgUtNzjEbHpgZ2ISke3GFVUgwS9qZDKXLn Fb62EPhaxSw6dBKWVqFvvmYWqjDxZp2vNNeWj3wWjFxr5jMGkbjiSe3PkYsVeZeFpJti FIwZfO9CEgymUV0WOC+E50quy/8PTdRmdm2zxq2bLG58xTYZ44UbO6nO9lYOFxsnSZXM KA== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ugckm8h8h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Nov 2023 18:37:23 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AKIJ1Dv004986; Mon, 20 Nov 2023 18:37:22 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uf7yybgvs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Nov 2023 18:37:22 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AKIbKvi45482474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Nov 2023 18:37:20 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 006B620043; Mon, 20 Nov 2023 18:37:20 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D139D2004D; Mon, 20 Nov 2023 18:37:19 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 20 Nov 2023 18:37:19 +0000 (GMT) From: Heiko Carstens To: Andrew Morton , Masahiro Yamada Cc: Vaneet Narang , Maninder Singh , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] checkstack: sort output by size and function name Date: Mon, 20 Nov 2023 19:37:18 +0100 Message-Id: <20231120183719.2188479-3-hca@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231120183719.2188479-1-hca@linux.ibm.com> References: <20231120183719.2188479-1-hca@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: qpMncvlknwdtNkNNmJ1yQGE3iq5VIuMw X-Proofpoint-GUID: qpMncvlknwdtNkNNmJ1yQGE3iq5VIuMw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-20_19,2023-11-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=0 mlxlogscore=684 mlxscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311200134 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Sort output by size and in addition by function name. This increases readability for cases where there are many functions with the same stack usage. Signed-off-by: Heiko Carstens --- scripts/checkstack.pl | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index f27d552aec43..13408714ba0f 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl @@ -189,5 +189,20 @@ if ($total_size > $min_stack) { push @stack, "$intro$total_size\n"; } =20 -# Sort output by size (last field) -print sort { ($b =3D~ /:\t*(\d+)$/)[0] <=3D> ($a =3D~ /:\t*(\d+)$/)[0] } @= stack; +# Sort output by size (last field) and function name if size is the same +sub sort_lines { + my ($a, $b) =3D @_; + + my $num_a =3D $1 if $a =3D~ /:\t*(\d+)$/; + my $num_b =3D $1 if $b =3D~ /:\t*(\d+)$/; + my $func_a =3D $1 if $a =3D~ / (.*):/; + my $func_b =3D $1 if $b =3D~ / (.*):/; + + if ($num_a !=3D $num_b) { + return $num_b <=3D> $num_a; + } else { + return $func_a cmp $func_b; + } +} + +print sort { sort_lines($a, $b) } @stack; --=20 2.39.2 From nobody Thu Dec 18 07:11:31 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CE5CC197A0 for ; Mon, 20 Nov 2023 18:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232981AbjKTSjN (ORCPT ); Mon, 20 Nov 2023 13:39:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233155AbjKTSiz (ORCPT ); Mon, 20 Nov 2023 13:38:55 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3B191FDF for ; Mon, 20 Nov 2023 10:37:35 -0800 (PST) Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AKIFiCt021361; Mon, 20 Nov 2023 18:37:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=lO8b6ZXr7zrGhq7ykp8qfuxFOUwTl24MyRC5J5RxAco=; b=gB6mQUppGlsfKGPQaOH5aYAsVMikkH4cWu7BH/B7YWrmAs+H7mk3zJoydnU4yItpNeqE 9z7xK3R2phtDUjtH+jqzSylrFkW8gCzrLLmSY2RMdi5G+GPSz76yy2o3PT7jG7dH9rbB U+aSPuQ0PO7arHH53coqx34PVYVmuVvwhiGuFRQ3BVpc9B4Nlq5ctwemk1y7Zmk80DwI FnpoLRkfM93QYdYit22p5GWCFlDuh71b2JvGJQ7b1zBjbawi3/WtsCo2Ak1cUq0pW2RH OSEGU4gmqe1SI9MxbRBwj7DUMjS4HrvMi2GtANsReVgRpLLsPnR8alLTG8i40WGgx1/w Hw== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ugcck8s7s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Nov 2023 18:37:23 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AKIJ1Sf004988; Mon, 20 Nov 2023 18:37:22 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uf7yybgvt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Nov 2023 18:37:22 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AKIbKtC38142362 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Nov 2023 18:37:20 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1EAF120040; Mon, 20 Nov 2023 18:37:20 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 04D4F2004B; Mon, 20 Nov 2023 18:37:20 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 20 Nov 2023 18:37:19 +0000 (GMT) From: Heiko Carstens To: Andrew Morton , Masahiro Yamada Cc: Vaneet Narang , Maninder Singh , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] checkstack: allow to pass MINSTACKSIZE parameter Date: Mon, 20 Nov 2023 19:37:19 +0100 Message-Id: <20231120183719.2188479-4-hca@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231120183719.2188479-1-hca@linux.ibm.com> References: <20231120183719.2188479-1-hca@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: QXUHMnfiDbPQtDbzUEehVZCRwAIcngRZ X-Proofpoint-ORIG-GUID: QXUHMnfiDbPQtDbzUEehVZCRwAIcngRZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-20_19,2023-11-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 phishscore=0 adultscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=947 priorityscore=1501 mlxscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311200134 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The checkstack script omits all functions with a stack usage of less than 100 bytes. However the script already has support for a parameter which allows to override the default, but it cannot be set with $ make checkstack Add a MINSTACKSIZE parameter which allows to change the default. This might be useful in order to print the stack usage of all functions, or only those with large stack usage: $ make checkstack MINSTACKSIZE=3D0 $ make checkstack MINSTACKSIZE=3D800 Signed-off-by: Heiko Carstens --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 724c79bebe72..b90413e7e590 100644 --- a/Makefile +++ b/Makefile @@ -1576,7 +1576,8 @@ help: echo ' (default: $(INSTALL_HDR_PATH))'; \ echo '' @echo 'Static analysers:' - @echo ' checkstack - Generate a list of stack hogs' + @echo ' checkstack - Generate a list of stack hogs and consider al= l functions' + @echo ' with a stack size larger than MINSTACKSIZE (d= efault: 100)' @echo ' versioncheck - Sanity check on version.h usage' @echo ' includecheck - Check for duplicate included header files' @echo ' export_report - List the usages of all exported symbols' @@ -2016,9 +2017,10 @@ CHECKSTACK_ARCH :=3D $(SUBARCH) else CHECKSTACK_ARCH :=3D $(ARCH) endif +MINSTACKSIZE ?=3D 100 checkstack: $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ - $(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH) + $(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH) $(MINSTACKSIZ= E) =20 kernelrelease: @$(filechk_kernel.release) --=20 2.39.2