scripts/checkstack.pl
Source file repositories/reference/linux-study-clean/scripts/checkstack.pl
File Facts
- System
- Linux kernel
- Corpus path
scripts/checkstack.pl- Extension
.pl- Size
- 6103 bytes
- Lines
- 209
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- Inferred role
- Support Tooling And Documentation: scripts
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
if ($total_size > $min_stack) {
push @stack, "$intro$total_size\n";
}
$addr = "0x$1";
$intro = "$addr $func [$file]:";
my $padlen = 56 - length($intro);
while ($padlen > 0) {
$intro .= ' ';
$padlen -= 8;
}
$total_size = 0;
}
elsif ($line =~ m/(.*):\s*file format/) {
$file = $1;
$file =~ s/\.ko//;
$lastslash = rindex($file, "/");
if ($lastslash != -1) {
$file = substr($file, $lastslash + 1);
}
}
elsif ($line =~ m/$re/) {
my $size = $1;
$size = hex($size) if ($size =~ /^0x/);
if ($size > 0xf0000000) {
$size = - $size;
$size += 0x80000000;
$size += 0x80000000;
}
next if ($size > 0x10000000);
$total_size += $size;
}
elsif (defined $dre && $line =~ m/$dre/) {
my $size = $1;
$size = hex($size) if ($size =~ /^0x/);
$total_size += $size;
}
elsif (defined $sub) {
my $size = &$sub($line);
$total_size += $size;
}
}
if ($total_size > $min_stack) {
push @stack, "$intro$total_size\n";
}
# Sort output by size (last field) and function name if size is the same
sub sort_lines {
my ($a, $b) = @_;
my $num_a = $1 if $a =~ /:\t*(\d+)$/;
my $num_b = $1 if $b =~ /:\t*(\d+)$/;
my $func_a = $1 if $a =~ / (.*):/;
my $func_b = $1 if $b =~ / (.*):/;
if ($num_a != $num_b) {
return $num_b <=> $num_a;
} else {
return $func_a cmp $func_b;
}
}
print sort { sort_lines($a, $b) } @stack;
Annotation
- Atlas domain: Support Tooling And Documentation / scripts.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.