[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 02/20] exec: Split out variable page size support to exec-
From: |
David Hildenbrand |
Subject: |
Re: [PATCH v3 02/20] exec: Split out variable page size support to exec-vary.c |
Date: |
Mon, 23 Sep 2019 10:26:31 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
On 22.09.19 05:54, Richard Henderson wrote:
> The next patch will play a trick with "const" that will
> confuse the compiler about the uses of target_page_bits
> within exec.c. Moving everything to a new file prevents
> this confusion.
>
> No functional change so far.
>
> Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
> Reviewed-by: Paolo Bonzini <address@hidden>
> Signed-off-by: Richard Henderson <address@hidden>
> ---
> Makefile.target | 2 +-
> include/qemu-common.h | 6 +++++
> exec-vary.c | 57 +++++++++++++++++++++++++++++++++++++++++++
> exec.c | 34 --------------------------
> 4 files changed, 64 insertions(+), 35 deletions(-)
> create mode 100644 exec-vary.c
>
> diff --git a/Makefile.target b/Makefile.target
> index 5e916230c4..ca3d14efe1 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -107,7 +107,7 @@ obj-y += trace/
>
> #########################################################
> # cpu emulator library
> -obj-y += exec.o
> +obj-y += exec.o exec-vary.o
> obj-y += accel/
> obj-$(CONFIG_TCG) += tcg/tcg.o tcg/tcg-op.o tcg/tcg-op-vec.o
> tcg/tcg-op-gvec.o
> obj-$(CONFIG_TCG) += tcg/tcg-common.o tcg/optimize.o
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index 8d84db90b0..082da59e85 100644
> --- a/include/qemu-common.h
> +++ b/include/qemu-common.h
> @@ -74,6 +74,12 @@ void cpu_exec_step_atomic(CPUState *cpu);
> */
> bool set_preferred_target_page_bits(int bits);
>
> +/**
> + * finalize_target_page_bits:
> + * Commit the final value set by set_preferred_target_page_bits.
> + */
> +void finalize_target_page_bits(void);
> +
> /**
> * Sends a (part of) iovec down a socket, yielding when the socket is full,
> or
> * Receives data into a (part of) iovec from a socket,
> diff --git a/exec-vary.c b/exec-vary.c
> new file mode 100644
> index 0000000000..48c0ab306c
> --- /dev/null
> +++ b/exec-vary.c
> @@ -0,0 +1,57 @@
> +/*
> + * Variable page size handling
> + *
> + * Copyright (c) 2003 Fabrice Bellard
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, see
> <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu-common.h"
> +#include "exec/exec-all.h"
> +
> +#ifdef TARGET_PAGE_BITS_VARY
> +int target_page_bits;
> +bool target_page_bits_decided;
> +#endif
> +
> +bool set_preferred_target_page_bits(int bits)
> +{
> + /*
> + * The target page size is the lowest common denominator for all
> + * the CPUs in the system, so we can only make it smaller, never
> + * larger. And we can't make it smaller once we've committed to
> + * a particular size.
> + */
> +#ifdef TARGET_PAGE_BITS_VARY
> + assert(bits >= TARGET_PAGE_BITS_MIN);
> + if (target_page_bits == 0 || target_page_bits > bits) {
> + if (target_page_bits_decided) {
> + return false;
> + }
> + target_page_bits = bits;
> + }
> +#endif
> + return true;
> +}
> +
> +void finalize_target_page_bits(void)
> +{
> +#ifdef TARGET_PAGE_BITS_VARY
> + if (target_page_bits == 0) {
> + target_page_bits = TARGET_PAGE_BITS_MIN;
> + }
> + target_page_bits_decided = true;
> +#endif
> +}
I wonder if it would be nicer to handle this in the header file instead,
providing dummy functions there.
--
Thanks,
David / dhildenb
- [PATCH v3 00/20] Move rom and notdirty handling to cputlb, Richard Henderson, 2019/09/21
- [PATCH v3 01/20] exec: Use TARGET_PAGE_BITS_MIN for TLB flags, Richard Henderson, 2019/09/21
- [PATCH v3 02/20] exec: Split out variable page size support to exec-vary.c, Richard Henderson, 2019/09/21
- Re: [PATCH v3 02/20] exec: Split out variable page size support to exec-vary.c,
David Hildenbrand <=
- [PATCH v3 04/20] exec: Restrict TARGET_PAGE_BITS_VARY assert to CONFIG_DEBUG_TCG, Richard Henderson, 2019/09/21
- [PATCH v3 03/20] exec: Use const alias for TARGET_PAGE_BITS_VARY, Richard Henderson, 2019/09/21
- [PATCH v3 05/20] exec: Promote TARGET_PAGE_MASK to target_long, Richard Henderson, 2019/09/21
- [PATCH v3 06/20] exec: Tidy TARGET_PAGE_ALIGN, Richard Henderson, 2019/09/21
- [PATCH v3 07/20] exec: Cache TARGET_PAGE_MASK for TARGET_PAGE_BITS_VARY, Richard Henderson, 2019/09/21
- [PATCH v3 08/20] cputlb: Disable __always_inline__ without optimization, Richard Henderson, 2019/09/21