diff options
author | Tobin C. Harding <me@tobin.cc> | 2018-02-18 21:23:44 -0500 |
---|---|---|
committer | Tobin C. Harding <me@tobin.cc> | 2018-04-06 18:50:34 -0400 |
commit | 5e4bac34edc7829b4a0749e3870d4a171c1f036f (patch) | |
tree | 37e73e94625c0f9f6aab110ba9fdebf30d84058c /scripts/leaking_addresses.pl | |
parent | b401f56f33bf551304cc4ca4f503863ee6ac7787 (diff) |
leaking_addresses: cache architecture name
Currently we are repeatedly calling `uname -m`. This is causing the
script to take a long time to run (more than 10 seconds to parse
/proc/kallsyms). We can use Perl state variables to cache the result of
the first call to `uname -m`. With this change in place the script
scans the whole kernel in under a minute.
Cache machine architecture in state variable.
Signed-off-by: Tobin C. Harding <me@tobin.cc>
Diffstat (limited to 'scripts/leaking_addresses.pl')
-rwxr-xr-x | scripts/leaking_addresses.pl | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl index 2ad6e7fb6698..6e5bc57caeaa 100755 --- a/scripts/leaking_addresses.pl +++ b/scripts/leaking_addresses.pl | |||
@@ -175,7 +175,7 @@ sub is_32bit | |||
175 | 175 | ||
176 | sub is_ix86_32 | 176 | sub is_ix86_32 |
177 | { | 177 | { |
178 | my $arch = `uname -m`; | 178 | state $arch = `uname -m`; |
179 | 179 | ||
180 | chomp $arch; | 180 | chomp $arch; |
181 | if ($arch =~ m/i[3456]86/) { | 181 | if ($arch =~ m/i[3456]86/) { |
@@ -198,12 +198,14 @@ sub is_arch | |||
198 | 198 | ||
199 | sub is_x86_64 | 199 | sub is_x86_64 |
200 | { | 200 | { |
201 | return is_arch('x86_64'); | 201 | state $is = is_arch('x86_64'); |
202 | return $is; | ||
202 | } | 203 | } |
203 | 204 | ||
204 | sub is_ppc64 | 205 | sub is_ppc64 |
205 | { | 206 | { |
206 | return is_arch('ppc64'); | 207 | state $is = is_arch('ppc64'); |
208 | return $is; | ||
207 | } | 209 | } |
208 | 210 | ||
209 | # Gets config option value from kernel config file. | 211 | # Gets config option value from kernel config file. |