summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2020-01-23 17:01:39 +0100
committerPaul Moore <paul@paul-moore.com>2020-03-23 11:14:35 -0400
commit9b129c41ac1f43d373742697aa2faf6040b9dfab (patch)
tree25c69d113e954473adb7b5209c76b67773a383e9 /include
parentf5b3166d6126f4a45b59d6af6780b5e00a0e9867 (diff)
downloadlibseccomp-9b129c41ac1f43d373742697aa2faf6040b9dfab.tar.gz
arch: use gperf to generate a perfact hash to lookup syscall names
This patch significantly improves the performance of seccomp_syscall_resolve_name since it replaces the expensive strcmp for each syscall in the database, with a lookup table. The complexity for syscall_resolve_num is not changed and it uses the linear search, that is anyway less expensive than seccomp_syscall_resolve_name as it uses an index for comparison instead of doing a string comparison. On my machine, calling 1000 seccomp_syscall_resolve_name_arch and seccomp_syscall_resolve_num_arch over the entire syscalls DB passed from ~0.45 sec to ~0.06s. PM: After talking with Giuseppe I made a number of additional changes, some substantial, the highlights include: * various style tweaks * .gitignore fixes * fixed subject line, tweaked the description * dropped the arch-syscall-validate changes as they were masking other problems * extracted the syscalls.csv and file deletions to other patches to keep this one more focused * fixed the x86, x32, arm, all the MIPS ABIs, s390, and s390x ABIs as the syscall offsets were not properly incorporated into this change * cleaned up the ABI specific headers * cleaned up generate_syscalls_perf.sh and renamed to arch-gperf-generate * fixed problems with automake's file packaging Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Reviewed-by: Tom Hromatka <tom.hromatka@oracle.com> [PM: see notes in the "PM" section above] Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'include')
-rw-r--r--include/seccomp-syscalls.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/seccomp-syscalls.h b/include/seccomp-syscalls.h
index d7eb383..2a4ebd3 100644
--- a/include/seccomp-syscalls.h
+++ b/include/seccomp-syscalls.h
@@ -274,6 +274,7 @@
#define __PNR_utimensat_time64 -10240
#define __PNR_ppoll -10241
#define __PNR_renameat -10242
+#define __PNR_riscv_flush_icache -10243
/*
* libseccomp syscall definitions
@@ -1507,6 +1508,12 @@
#define __SNR_restart_syscall __NR_restart_syscall
+#ifdef __NR_riscv_flush_icache
+#define __SNR_riscv_flush_icache __NR_riscv_flush_icache
+#else
+#define __SNR_riscv_flush_icache __PNR_riscv_flush_icache
+#endif
+
#ifdef __NR_rmdir
#define __SNR_rmdir __NR_rmdir
#else