2023-12-19 12:50:44

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v1 0/5] Modify some code about checkstack

This is based on 6.7-rc6 and on top of the following patch:

https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/checkstack-add-loongarch-support-for-scripts-checkstackpl.patch

If it is possible, I think it would be best to keep the series together
and merge it through the akpm tree.

Tiezhu Yang (5):
scripts/checkstack.pl: Remove ia64 support
scripts/checkstack.pl: Add min_stack to the usage comment
scripts/checkstack.pl: Match all stack sizes for some archs
scripts/checkstack.pl: Change min_stack to 512 by default
docs: submit-checklist: Remove all of "make namespacecheck"

.../translations/ja_JP/SubmitChecklist | 4 ++--
.../zh_CN/process/submit-checklist.rst | 3 +--
.../zh_TW/process/submit-checklist.rst | 3 +--
scripts/checkstack.pl | 20 ++++++++-----------
4 files changed, 12 insertions(+), 18 deletions(-)

--
2.42.0



2023-12-19 12:50:57

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v1 2/5] scripts/checkstack.pl: Add min_stack to the usage comment

After commit 572220aad525 ("scripts/checkstack.pl: Add argument
to print stacks greather than value."), it is appropriate to add
min_stack to the usage comment, then the users know explicitly
that "min_stack" can be specified like "arch".

Signed-off-by: Tiezhu Yang <[email protected]>
---
scripts/checkstack.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index 0c99b380cebb..50820d47db15 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -18,7 +18,7 @@
# loongarch port by Youling Tang <[email protected]>
#
# Usage:
-# objdump -d vmlinux | scripts/checkstack.pl [arch]
+# objdump -d vmlinux | scripts/checkstack.pl [arch] [min_stack]
#
# TODO : Port to all architectures (one regex per arch)

--
2.42.0


2023-12-19 12:51:19

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v1 3/5] scripts/checkstack.pl: Match all stack sizes for some archs

For some unknown reason the regular expression for checkstack
only matches three digit numbers starting with the number "3",
or any higher number. Which means that it skips any stack sizes
smaller than 304 bytes. This makes the checkstack script a bit
less useful than it could be.

Change the script to match any number. To be filtered out stack
sizes can be configured with the min_stack variable, which omits
any stack frame sizes smaller than 100 bytes by default.

This is similar with commit aab1f809d754 ("scripts/checkstack.pl:
match all stack sizes for s390").

Signed-off-by: Tiezhu Yang <[email protected]>
---
scripts/checkstack.pl | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index 50820d47db15..5e8f1c20e31c 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -74,16 +74,16 @@ my (@stack, $re, $dre, $sub, $x, $xs, $funcre, $min_stack);
$re = qr/.*(?:linkw %fp,|addaw )#-([0-9]{1,4})(?:,%sp)?$/o;
} elsif ($arch eq 'mips64') {
#8800402c: 67bdfff0 daddiu sp,sp,-16
- $re = qr/.*daddiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+ $re = qr/.*daddiu.*sp,sp,-([0-9]{1,8})/o;
} elsif ($arch eq 'mips') {
#88003254: 27bdffe0 addiu sp,sp,-32
- $re = qr/.*addiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+ $re = qr/.*addiu.*sp,sp,-([0-9]{1,8})/o;
} elsif ($arch eq 'nios2') {
#25a8: defffb04 addi sp,sp,-20
- $re = qr/.*addi.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+ $re = qr/.*addi.*sp,sp,-([0-9]{1,8})/o;
} elsif ($arch eq 'openrisc') {
# c000043c: 9c 21 fe f0 l.addi r1,r1,-272
- $re = qr/.*l\.addi.*r1,r1,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+ $re = qr/.*l\.addi.*r1,r1,-([0-9]{1,8})/o;
} elsif ($arch eq 'parisc' || $arch eq 'parisc64') {
$re = qr/.*ldo ($x{1,8})\(sp\),sp/o;
} elsif ($arch eq 'powerpc' || $arch =~ /^ppc(64)?(le)?$/ ) {
@@ -97,10 +97,10 @@ my (@stack, $re, $dre, $sub, $x, $xs, $funcre, $min_stack);
$re = qr/.*(?:lay|ag?hi).*\%r15,-([0-9]+)(?:\(\%r15\))?$/o;
} elsif ($arch eq 'sparc' || $arch eq 'sparc64') {
# f0019d10: 9d e3 bf 90 save %sp, -112, %sp
- $re = qr/.*save.*%sp, -(([0-9]{2}|[3-9])[0-9]{2}), %sp/o;
+ $re = qr/.*save.*%sp, -([0-9]{1,8}), %sp/o;
} elsif ($arch =~ /^riscv(64)?$/) {
#ffffffff8036e868: c2010113 addi sp,sp,-992
- $re = qr/.*addi.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+ $re = qr/.*addi.*sp,sp,-([0-9]{1,8})/o;
} elsif ($arch =~ /^loongarch(32|64)?$/) {
#9000000000224708: 02ff4063 addi.d $sp, $sp, -48(0xfd0)
$re = qr/.*addi\..*sp, .*sp, -([0-9]{1,8}).*/o;
--
2.42.0


2023-12-19 12:51:26

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v1 4/5] scripts/checkstack.pl: Change min_stack to 512 by default

According to Documentation/process/submit-checklist.rst, checkstack
does not point out problems explicitly, but any one function that
uses more than 512 bytes on the stack is a candidate for change,
hence it is better to omit any stack frame sizes smaller than 512
bytes, just change min_stack to 512 by default.

Signed-off-by: Tiezhu Yang <[email protected]>
---
scripts/checkstack.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index 5e8f1c20e31c..40ab29f77b5b 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -47,7 +47,7 @@ my (@stack, $re, $dre, $sub, $x, $xs, $funcre, $min_stack);

$min_stack = shift;
if ($min_stack eq "" || $min_stack !~ /^\d+$/) {
- $min_stack = 100;
+ $min_stack = 512;
}

$x = "[0-9a-f]"; # hex character
--
2.42.0


2023-12-19 12:51:30

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v1 5/5] docs: submit-checklist: Remove all of "make namespacecheck"

After commit 7dfbea4c468c ("scripts: remove namespace.pl"),
scripts/namespace.pl has been removed from the kernel, and
"make namespacecheck" has been removed from the English
version of submit-checklist.rst, so also remove it in the
related translations.

Signed-off-by: Tiezhu Yang <[email protected]>
---
Documentation/translations/ja_JP/SubmitChecklist | 4 ++--
Documentation/translations/zh_CN/process/submit-checklist.rst | 3 +--
Documentation/translations/zh_TW/process/submit-checklist.rst | 3 +--
3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/Documentation/translations/ja_JP/SubmitChecklist b/Documentation/translations/ja_JP/SubmitChecklist
index 4429447b0965..1759c6b452d6 100644
--- a/Documentation/translations/ja_JP/SubmitChecklist
+++ b/Documentation/translations/ja_JP/SubmitChecklist
@@ -56,8 +56,8 @@ Linux カーネルパッチ投稿者向けチェックリスト

9: sparseを利用してちゃんとしたコードチェックをしてください。

-10: 'make checkstack' と 'make namespacecheck' を利用し、問題が発見されたら
- 修正してください。'make checkstack' は明示的に問題を示しませんが、どれか
+10: 'make checkstack' を利用し、問題が発見されたら修正してください。
+ 'make checkstack' は明示的に問題を示しませんが、どれか
1つの関数が512バイトより大きいスタックを使っていれば、修正すべき候補と
なります。

diff --git a/Documentation/translations/zh_CN/process/submit-checklist.rst b/Documentation/translations/zh_CN/process/submit-checklist.rst
index 3d6ee21c74ae..10536b74aeec 100644
--- a/Documentation/translations/zh_CN/process/submit-checklist.rst
+++ b/Documentation/translations/zh_CN/process/submit-checklist.rst
@@ -53,8 +53,7 @@ Linux内核补丁提交检查单
9) 通过 sparse 清查。
(参见 Documentation/translations/zh_CN/dev-tools/sparse.rst )

-10) 使用 ``make checkstack`` 和 ``make namespacecheck`` 并修复他们发现的任何
- 问题。
+10) 使用 ``make checkstack`` 并修复他们发现的任何问题。

.. note::

diff --git a/Documentation/translations/zh_TW/process/submit-checklist.rst b/Documentation/translations/zh_TW/process/submit-checklist.rst
index 942962d1e2f4..dda456a73147 100644
--- a/Documentation/translations/zh_TW/process/submit-checklist.rst
+++ b/Documentation/translations/zh_TW/process/submit-checklist.rst
@@ -56,8 +56,7 @@ Linux內核補丁提交檢查單
9) 通過 sparse 清查。
(參見 Documentation/translations/zh_CN/dev-tools/sparse.rst )

-10) 使用 ``make checkstack`` 和 ``make namespacecheck`` 並修復他們發現的任何
- 問題。
+10) 使用 ``make checkstack`` 並修復他們發現的任何問題。

.. note::

--
2.42.0


2023-12-19 12:59:26

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v1 1/5] scripts/checkstack.pl: Remove ia64 support

After commit cf8e8658100d ("arch: Remove Itanium (IA-64) architecture"),
the ia64 port has been removed from the kernel, so also remove the ia64
specific bits from the checkstack.pl script.

Signed-off-by: Tiezhu Yang <[email protected]>
---
scripts/checkstack.pl | 4 ----
1 file changed, 4 deletions(-)

diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index e9d01b999b74..0c99b380cebb 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -8,7 +8,6 @@
# Original idea maybe from Keith Owens
# s390 port and big speedup by Arnd Bergmann <[email protected]>
# Mips port by Juan Quintela <[email protected]>
-# IA64 port via Andreas Dilger
# Arm port by Holger Schurig
# Random bits by Matt Mackall <[email protected]>
# M68k port by Geert Uytterhoeven and Andreas Schwab
@@ -69,9 +68,6 @@ my (@stack, $re, $dre, $sub, $x, $xs, $funcre, $min_stack);
# 2f60: 48 81 ec e8 05 00 00 sub $0x5e8,%rsp
$re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%(e|r)sp$/o;
$dre = qr/^.*[as][du][db] (%.*),\%(e|r)sp$/o;
- } elsif ($arch eq 'ia64') {
- #e0000000044011fc: 01 0f fc 8c adds r12=-384,r12
- $re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o;
} elsif ($arch eq 'm68k') {
# 2b6c: 4e56 fb70 linkw %fp,#-1168
# 1df770: defc ffe4 addaw #-28,%sp
--
2.42.0