OPENSSL_INSTRUMENT_BUS(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… OPENSSL_INSTRUMENT_BUS πŸ’…

okay so this is page OPENSSL_INSTRUMENT_BUS(3ossl) from the OpenSSL fam β€” yes the 3ossl bit is the manual section, we love a labeled queen πŸŽ€


✨ NAME ✨

OPENSSL_instrument_bus, OPENSSL_instrument_bus2 β€” these two literally exist to instrument references to the memory bus πŸ¦‹


🌸 SYNOPSIS 🌸

#ifdef OPENSSL_CPUID_OBJ
size_t OPENSSL_instrument_bus(unsigned int *vector, size_t num);
size_t OPENSSL_instrument_bus2(unsigned int *vector, size_t num, size_t max);
#endif

bestie note: yes the #ifdef OPENSSL_CPUID_OBJ is doing the heavy lifting there, don't forget it πŸ’…


πŸ”₯ DESCRIPTION πŸ”₯

So here's the tea β˜• β€” it was empirically found that the timings of references to primary memory are subject to irregular, apparently non-deterministic variations. Like, they're just out here being chaotic. The subroutines in question instrument these references for the purposes of gathering randomness for a random number generator. Iconic behavior honestly.

To make it bus-bound, a 'flush cache line' instruction is used between probes ✨ In addition, probes are added to vector elements in an atomic or interlocked manner, which should contribute additional noise on multi-processor systems. Main character energy on the multi-processor front, fr fr.

πŸ™ˆ heads up: this also means that vector[num] should be zeroed upon invocation (if you want to retrieve actual probe values). Don't skip that step bestie, it's giving undefined-vibes otherwise.

OPENSSL_instrument_bus() performs num probes and records the number of oscillator cycles every probe took 🫢

OPENSSL_instrument_bus2() on the other hand accumulates consecutive probes with the same value, i.e. in a way it records the duration of periods when probe values appeared deterministic. The subroutine performs at most max probes in an attempt to fill the vector[num], with a max value of 0 meaning "as many as it takes." no cap, it will literally go until it's done 😭


⭐ RETURN VALUES ⭐

A return value of 0 indicates that the CPU is not capable of performing the benchmark β€” either because the oscillator counter or 'flush cache line' is not available on the current platform πŸ’€

For reference, on x86, 'flush cache line' was introduced with the SSE2 extensions. iykyk 🌈

Otherwise, the number of recorded values is returned πŸ‘‘


Copyright 2011-2018 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


aaaand that's the whole page, bestie πŸ“ this was version 3.5.6, dated 2026-04-07, brought to you by the OPENSSL_INSTRUMENT_BUS(3ossl) girlies β€” slay and read your licenses πŸ’–πŸ§š

πŸ“¦ where this page comes from