20230517-linuxkm-benchmarks#6418
Conversation
…ble-asynccrypt; update failure message for the opensslextra AC_CHECK_HEADER() test.
…STACK and WOLFSSL_NO_FLOAT_FMT codepaths, SAVE/RESTORE_VECTOR_REGISTERS, refactor of several stack array initializations that broke in the kernel, and replacement of an fputs() call with printf().
… memset, not the zero initializer, for C++ compatibility.
…n the haveAESNI path for WOLFSSL_LINUXKM, because the failure mode is module crash.
…FREE_VAR() and WC_FREE_ARRAY() for pedantic semicolon swallowing.
…inly by supporting NO_STDIO_FILESYSTEM.
… be per-process rather than per-CPU, and add migrate_disable/enable() to kernel_fpu_begin/end() because preempt_disable() is just a barrier on _PREEMPT_VOLUNTARY kernels; linuxkm/linuxkm_wc_port.h: activate SAVE/RESTORE_VECTOR_REGISTERS() whenever defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS) for benchmark.c support, independent of vector crypto features; fix and optimize various alignment issues with stack and heap allocations; fix macro definitions for XMALLOC/XREALLOC/XFREE to correctly use kvmalloc and friends when defined(HAVE_KVMALLOC), and to use wolfSSL_Malloc() and friends when defined(WOLFSSL_TRACK_MEMORY); purge stale LINUXKM_SIMD_IRQ code.
| if (haveAESNI) { | ||
| #ifdef WOLFSSL_LINUXKM | ||
| /* runtime alignment check */ | ||
| if ((unsigned long)&aes->key & 0xf) { |
There was a problem hiding this comment.
For portability seems like size_t would be better? Also using 0xFULL?
There was a problem hiding this comment.
Only the bottom 4 bits matter here, so I figured casting to unsigned long was fine and keeps it maximally efficient.
But we do actually have a right way to do this -- wc_ptr_t, set up in types.h. Will use that.
Btw, size_t is not reliably the same size as a pointer -- ran into this recently in-real-life. That can produce inefficiencies or truncation warnings depending on which way it goes.
| ret = DoClientHelloStateless(ssl, input, inOutIdx, helloSz); | ||
| if (ret != 0 || !ssl->options.dtlsStateful) { | ||
| int alertType = TranslateErrorToAlert(ret); | ||
| if (alertType != invalid_alert) |
There was a problem hiding this comment.
all credit to cppcheck -- it's a fidgity tool but it's worth the trouble to figure it out.
| #define NO_MAIN_FUNCTION | ||
| #define current_time benchmark_current_time | ||
| #define WOLFSSL_NO_FLOAT_FMT | ||
| #include "/home/douzzer/com/wolfssl/src/wolfssl/wolfcrypt/benchmark/benchmark.c" |
There was a problem hiding this comment.
Hard coded douzzer?? Is it possible to have a relative path or to get the path a different way?
| #define FLT_FMT "%0ld,%09lu" | ||
| #define FLT_FMT_PREC "%0ld.%0*lu" | ||
| #define FLT_FMT_PREC2 FLT_FMT_PREC | ||
| #define FLT_FMT_ARGS(x) (long)(x), ((x) < 0) ? (unsigned long)(-(((x) - (double)(long)(x)) * 1000000000.0)) : (unsigned long)(((x) - (double)(long)(x)) * 1000000000.0) |
There was a problem hiding this comment.
yeah sure I'll fix that -- but note there's a ton of overlong line in benchmark.c. it's a bit of a shambles...
| void bench_hmac_sha(int useDeviceID) | ||
| { | ||
| byte key[] = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, | ||
| static const byte key[] = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, |
There was a problem hiding this comment.
Would prefer just const. These shouldn't need to be static right?
There was a problem hiding this comment.
crashes without static. the problem is stack initialization. exact root cause unknown, but suspect alignment weirdness.
There was a problem hiding this comment.
(am changing all of those to WOLFSSL_SMALL_STACK_STATIC -- good enough for test.c, good enough for benchmark.c)
| { | ||
| ecc_key userA, userB; | ||
| #define BENCH_ECCENCRYPT_MSG_SIZE 48 | ||
| #define BENCH_ECCENCRYPT_OUT_SIZE (BENCH_ECCENCRYPT_MSG_SIZE + WC_SHA256_DIGEST_SIZE + (MAX_ECC_BITS+3)/4 + 2) |
…GISTERS() failure trap in benchmark.c, proper path to benchmark.c in linuxkm/module_hooks.c, and proper casting in aes.c. also harmonized semantics and prototype of bench_ripemd().
|
Jenkins, retest this please. |
|
note for posterity: the CI failure on the final commit in this PR is a Jenkins/github state model conflict. the single subtest at issue, |
refactor
benchmark.cfor linux kernel compatibility --WOLFSSL_SMALL_STACKandWOLFSSL_NO_FLOAT_FMTcodepaths,SAVE/RESTORE_VECTOR_REGISTERS, refactor of several stack array initializations that broke in the kernel, and replacement of anfputs()call withprintf();configure.ac: add--enable-linuxkm-benchmarks; add check forasync.{c,h}when--enable-asynccrypt; update failure message for the opensslextraAC_CHECK_HEADER()test;linuxkm/linuxkm_memory.c: refactorSAVE/RESTORE_VECTOR_REGISTERS()to be per-process rather than per-CPU, and addmigrate_disable/enable()tokernel_fpu_begin/end()becausepreempt_disable()is just a barrier on_PREEMPT_VOLUNTARYkernels;linuxkm/linuxkm_wc_port.h: activateSAVE/RESTORE_VECTOR_REGISTERS()wheneverdefined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS)forbenchmark.csupport, independent of vector crypto features;linuxkm/linuxkm_wc_port.h: fix and optimize various alignment issues with stack and heap allocations;fix macro definitions for
XMALLOC/XREALLOC/XFREEto correctly usekvmallocand friends whendefined(HAVE_KVMALLOC), and to usewolfSSL_Malloc()and friends whendefined(WOLFSSL_TRACK_MEMORY);purge stale
LINUXKM_SIMD_IRQcode;wolfssl/wolfcrypt/mem_track.h: refactor for linuxkm compatibility, mainly by supportingNO_STDIO_FILESYSTEM;wolfcrypt/src/aes.c: inwc_AesSetKeyLocal(), add an alignment check in thehaveAESNIpath forWOLFSSL_LINUXKM, because the failure mode is module crash.also various unrelated point fixes for analyzer carps, one commit per fix.
tested with
wolfssl-multi-test.sh ... super-quick-check '.*linuxkm.*' benchmark-wolfcrypt-intelasm-all benchmark-wolfcrypt-noasm-all