[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 1/3] compiler: define QEMU_CACHELINE_SIZE
From: |
Pranith Kumar |
Subject: |
Re: [Qemu-devel] [PATCH v2 1/3] compiler: define QEMU_CACHELINE_SIZE |
Date: |
Tue, 6 Jun 2017 01:39:45 -0400 |
On Mon, Jun 5, 2017 at 6:49 PM, Emilio G. Cota <address@hidden> 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 <address@hidden>
> ---
> 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
- [Qemu-devel] [PATCH v2 0/3] tcg: allocate TB structs preceding translated code, Emilio G. Cota, 2017/06/05
- [Qemu-devel] [PATCH v2 1/3] compiler: define QEMU_CACHELINE_SIZE, Emilio G. Cota, 2017/06/05
- Re: [Qemu-devel] [PATCH v2 1/3] compiler: define QEMU_CACHELINE_SIZE,
Pranith Kumar <=
- Re: [Qemu-devel] [PATCH v2 1/3] compiler: define QEMU_CACHELINE_SIZE, Richard Henderson, 2017/06/06
- Re: [Qemu-devel] [PATCH v2 1/3] compiler: define QEMU_CACHELINE_SIZE, Emilio G. Cota, 2017/06/06
- Re: [Qemu-devel] [PATCH v2 1/3] compiler: define QEMU_CACHELINE_SIZE, Richard Henderson, 2017/06/06
- Re: [Qemu-devel] [PATCH v2 1/3] compiler: define QEMU_CACHELINE_SIZE, Geert Martin Ijewski, 2017/06/06
- Re: [Qemu-devel] [PATCH v2 1/3] compiler: define QEMU_CACHELINE_SIZE, Emilio G. Cota, 2017/06/06
- Re: [Qemu-devel] [PATCH v2 1/3] compiler: define QEMU_CACHELINE_SIZE, Geert Martin Ijewski, 2017/06/06
[Qemu-devel] [PATCH v2 2/3] tests: use QEMU_CACHELINE_SIZE instead of hard-coding it, Emilio G. Cota, 2017/06/05
[Qemu-devel] [PATCH v2 3/3] tcg: allocate TB structs before the corresponding translated code, Emilio G. Cota, 2017/06/05