mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kbuild: speed up checksyscalls.sh
@ 2017-06-01 14:57 Arnd Bergmann
  2017-06-08 18:02 ` Masahiro Yamada
  2017-06-09 16:16 ` Masahiro Yamada
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2017-06-01 14:57 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Michal Marek, linux-kbuild, linux-kernel, sam, Arnd Bergmann

checksyscalls.sh is run at every "make" run while building the kernel,
even if no files have changed. I looked at where we spend time in
a trivial empty rebuild and found checksyscalls.sh to be a source
of noticeable overhead, as it spawns a lot of child processes just
to call 'cat' copying from stdin to stdout, once for each of the
over 400 x86 syscalls.

Using a shell-builtin (echo) instead of the external command gives
us a 13x speedup:

    Before		   After
real	0m1.018s       real	0m0.077s
user	0m0.068s       user	0m0.048s
sys	0m0.156s       sys	0m0.024s

The time it took to rebuild a single file on my machine dropped
from 5.5 seconds to 4.5 seconds.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/checksyscalls.sh | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh
index 0cce56da3706..b8c9d2b04ffc 100755
--- a/scripts/checksyscalls.sh
+++ b/scripts/checksyscalls.sh
@@ -231,15 +231,12 @@ EOF
 }
 
 syscall_list() {
-    grep '^[0-9]' "$1" | sort -n | (
+    grep '^[0-9]' "$1" | sort -n |
 	while read nr abi name entry ; do
-	    cat <<EOF
-#if !defined(__NR_${name}) && !defined(__IGNORE_${name})
-#warning syscall ${name} not implemented
-#endif
-EOF
+		echo "#if !defined(__NR_${name}) && !defined(__IGNORE_${name})"
+		echo "#warning syscall ${name} not implemented"
+		echo "#endif"
 	done
-    )
 }
 
 (ignore_list && syscall_list $(dirname $0)/../arch/x86/entry/syscalls/syscall_32.tbl) | \
-- 
2.9.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kbuild: speed up checksyscalls.sh
  2017-06-01 14:57 [PATCH] kbuild: speed up checksyscalls.sh Arnd Bergmann
@ 2017-06-08 18:02 ` Masahiro Yamada
  2017-06-09 16:16 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2017-06-08 18:02 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Michal Marek, Linux Kbuild mailing list,
	Linux Kernel Mailing List, Sam Ravnborg

Hi Arnd,

2017-06-01 23:57 GMT+09:00 Arnd Bergmann <arnd@arndb.de>:
> checksyscalls.sh is run at every "make" run while building the kernel,
> even if no files have changed. I looked at where we spend time in
> a trivial empty rebuild and found checksyscalls.sh to be a source
> of noticeable overhead, as it spawns a lot of child processes just
> to call 'cat' copying from stdin to stdout, once for each of the
> over 400 x86 syscalls.
>
> Using a shell-builtin (echo) instead of the external command gives
> us a 13x speedup:
>
>     Before                 After
> real    0m1.018s       real     0m0.077s
> user    0m0.068s       user     0m0.048s
> sys     0m0.156s       sys      0m0.024s
>
> The time it took to rebuild a single file on my machine dropped
> from 5.5 seconds to 4.5 seconds.
>


I will apply this patch.
On my PC, I did not see such a big difference as you saw, though.
Big or small, it is speed-up anyway.


My test result.  Three times for each.


Without this patch:

masahiro@grover:~/workspace/linux$ time make  prepare0
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh

real 0m0.556s
user 0m0.048s
sys 0m0.028s
masahiro@grover:~/workspace/linux$ time make  prepare0
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh

real 0m0.531s
user 0m0.052s
sys 0m0.012s
masahiro@grover:~/workspace/linux$ time make  prepare0
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh

real 0m0.530s
user 0m0.040s
sys 0m0.020s



With this patch:

masahiro@grover:~/workspace/linux$ git log -1 --oneline
b7a9f79 kbuild: speed up checksyscalls.sh
masahiro@grover:~/workspace/linux$ time make  prepare0
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh

real 0m0.384s
user 0m0.040s
sys 0m0.008s
masahiro@grover:~/workspace/linux$ time make  prepare0
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh

real 0m0.386s
user 0m0.048s
sys 0m0.000s
masahiro@grover:~/workspace/linux$ time make  prepare0
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh

real 0m0.384s
user 0m0.024s
sys 0m0.024s




-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kbuild: speed up checksyscalls.sh
  2017-06-01 14:57 [PATCH] kbuild: speed up checksyscalls.sh Arnd Bergmann
  2017-06-08 18:02 ` Masahiro Yamada
@ 2017-06-09 16:16 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2017-06-09 16:16 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Michal Marek, Linux Kbuild mailing list,
	Linux Kernel Mailing List, Sam Ravnborg

2017-06-01 23:57 GMT+09:00 Arnd Bergmann <arnd@arndb.de>:
> checksyscalls.sh is run at every "make" run while building the kernel,
> even if no files have changed. I looked at where we spend time in
> a trivial empty rebuild and found checksyscalls.sh to be a source
> of noticeable overhead, as it spawns a lot of child processes just
> to call 'cat' copying from stdin to stdout, once for each of the
> over 400 x86 syscalls.
>
> Using a shell-builtin (echo) instead of the external command gives
> us a 13x speedup:
>
>     Before                 After
> real    0m1.018s       real     0m0.077s
> user    0m0.068s       user     0m0.048s
> sys     0m0.156s       sys      0m0.024s
>
> The time it took to rebuild a single file on my machine dropped
> from 5.5 seconds to 4.5 seconds.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied to linux-kbuild/kbuild.  Thanks!




-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-09 16:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-01 14:57 [PATCH] kbuild: speed up checksyscalls.sh Arnd Bergmann
2017-06-08 18:02 ` Masahiro Yamada
2017-06-09 16:16 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®