On Mon, Jun 5, 2017 at 6:49 PM, Emilio G. Cota <c...@braap.org> wrote: > This is a constant used as a hint for padding structs to hopefully avoid > false cache line sharing. > > The constant can be set at configure time by defining QEMU_CACHELINE_SIZE > via --extra-cflags. If not set there, we try to obtain the value from > the machine running the configure script. If we fail, we default to > reasonable values, i.e. 128 bytes for ppc64 and 64 bytes for all others. > > Note: the configure script only picks up the cache line size when run > on Linux hosts because I have no other platforms (e.g. Windows, BSD's) > to test on. > > Signed-off-by: Emilio G. Cota <c...@braap.org> > --- > configure | 38 ++++++++++++++++++++++++++++++++++++++ > include/qemu/compiler.h | 17 +++++++++++++++++ > 2 files changed, 55 insertions(+) > > diff --git a/configure b/configure > index 13e040d..6a68cb2 100755 > --- a/configure > +++ b/configure > @@ -4832,6 +4832,41 @@ EOF > fi > fi > > +# Find out the size of a cache line on the host > +# TODO: support more platforms > +cat > $TMPC<<EOF > +#ifdef __linux__ > + > +#include <stdio.h> > + > +#define SYSFS "/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size" > + > +int main(int argc, char *argv[]) > +{ > + unsigned int size; > + FILE *fp; > + > + fp = fopen(SYSFS, "r"); > + if (fp == NULL) { > + return -1; > + } > + if (!fscanf(fp, "%u", &size)) { > + return -1; > + } > + return size; > +} > +#else > +#error Cannot find host cache line size > +#endif > +EOF
Is there any reason not to use sysconf(_SC_LEVEL1_DCACHE_LINESIZE)? Thanks, -- Pranith