All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Johansson via qemu development <qemu-devel@nongnu.org>
To: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
Cc: qemu-devel@nongnu.org,
	 Richard Henderson <richard.henderson@linaro.org>,
	qemu-riscv@nongnu.org, qemu-s390x@nongnu.org,
	qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
	 Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 03/24] accel/tcg: Widen TranslationBlock::flags to 64 bits
Date: Fri, 27 Nov 2026 12:03:25 +0100	[thread overview]
Message-ID: <awlUl2by0PPZ2K7N@hive.localdomain> (raw)
In-Reply-To: <20261126233604.67722-4-philmd@oss.qualcomm.com>

On 27/11/26, Philippe Mathieu-Daudé wrote:
> 32-bit host support was removed in v11.0.0 (with commit 372ec46b9f
> "meson: Reject 32-bit hosts"), so there is no reason to keep the TB
> flags 32-bit. The wider field fills the 4-byte hole between icount
> and tc, leaving sizeof(TranslationBlock) unchanged. Widen
> TCGTBCPUState::flags too.
> 
> Feed the upper 32 bits into the TB hash, and adapt format string.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> ---
>  accel/tcg/tb-hash.h              | 5 +++--
>  include/accel/tcg/tb-cpu-state.h | 2 +-
>  include/exec/translation-block.h | 2 +-
>  accel/tcg/cpu-exec.c             | 2 +-
>  4 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/accel/tcg/tb-hash.h b/accel/tcg/tb-hash.h
> index f7b159f04cb6..819b594618aa 100644
> --- a/accel/tcg/tb-hash.h
> +++ b/accel/tcg/tb-hash.h
> @@ -63,9 +63,10 @@ static inline unsigned int tb_jmp_cache_hash_func(vaddr pc)
>  
>  static inline
>  uint32_t tb_hash_func(tb_page_addr_t phys_pc, vaddr pc,
> -                      uint32_t flags, uint64_t flags2, uint32_t cf_mask)
> +                      uint64_t flags, uint64_t flags2, uint32_t cf_mask)
>  {
> -    return qemu_xxhash8(phys_pc, pc, flags2, flags, cf_mask);
> +    /* Fold the upper flag bits into the cf_mask slot. */
> +    return qemu_xxhash8(phys_pc, pc, flags2, flags, cf_mask ^ (flags >> 32));
>  }

From what I can tell, while cf_mask ^ (flags >> 32) does increase the
probability for hash collisions it should still be extremely rare.
Currently the only possibility for extra collision is with the riscv ALTFMT,
BIG_ENDIAN, SDEXT_STEP fields and CF_COUNT_MASK, from what I can tell.

IMO, for the time being this wouldn't cause any real performance issues
compared to say adding an extra word to qemu_xxhash8().

Reviewed-by: Anton Johansson <anjo@rev.ng>


WARNING: multiple messages have this Message-ID (diff)
From: Anton Johansson via <qemu-arm@nongnu.org>
To: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
Cc: qemu-devel@nongnu.org,
	 Richard Henderson <richard.henderson@linaro.org>,
	qemu-riscv@nongnu.org, qemu-s390x@nongnu.org,
	qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
	 Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 03/24] accel/tcg: Widen TranslationBlock::flags to 64 bits
Date: Fri, 27 Nov 2026 12:03:25 +0100	[thread overview]
Message-ID: <awlUl2by0PPZ2K7N@hive.localdomain> (raw)
In-Reply-To: <20261126233604.67722-4-philmd@oss.qualcomm.com>

On 27/11/26, Philippe Mathieu-Daudé wrote:
> 32-bit host support was removed in v11.0.0 (with commit 372ec46b9f
> "meson: Reject 32-bit hosts"), so there is no reason to keep the TB
> flags 32-bit. The wider field fills the 4-byte hole between icount
> and tc, leaving sizeof(TranslationBlock) unchanged. Widen
> TCGTBCPUState::flags too.
> 
> Feed the upper 32 bits into the TB hash, and adapt format string.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> ---
>  accel/tcg/tb-hash.h              | 5 +++--
>  include/accel/tcg/tb-cpu-state.h | 2 +-
>  include/exec/translation-block.h | 2 +-
>  accel/tcg/cpu-exec.c             | 2 +-
>  4 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/accel/tcg/tb-hash.h b/accel/tcg/tb-hash.h
> index f7b159f04cb6..819b594618aa 100644
> --- a/accel/tcg/tb-hash.h
> +++ b/accel/tcg/tb-hash.h
> @@ -63,9 +63,10 @@ static inline unsigned int tb_jmp_cache_hash_func(vaddr pc)
>  
>  static inline
>  uint32_t tb_hash_func(tb_page_addr_t phys_pc, vaddr pc,
> -                      uint32_t flags, uint64_t flags2, uint32_t cf_mask)
> +                      uint64_t flags, uint64_t flags2, uint32_t cf_mask)
>  {
> -    return qemu_xxhash8(phys_pc, pc, flags2, flags, cf_mask);
> +    /* Fold the upper flag bits into the cf_mask slot. */
> +    return qemu_xxhash8(phys_pc, pc, flags2, flags, cf_mask ^ (flags >> 32));
>  }

From what I can tell, while cf_mask ^ (flags >> 32) does increase the
probability for hash collisions it should still be extremely rare.
Currently the only possibility for extra collision is with the riscv ALTFMT,
BIG_ENDIAN, SDEXT_STEP fields and CF_COUNT_MASK, from what I can tell.

IMO, for the time being this wouldn't cause any real performance issues
compared to say adding an extra word to qemu_xxhash8().

Reviewed-by: Anton Johansson <anjo@rev.ng>


WARNING: multiple messages have this Message-ID (diff)
From: Anton Johansson via <qemu-riscv@nongnu.org>
To: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
Cc: qemu-devel@nongnu.org,
	 Richard Henderson <richard.henderson@linaro.org>,
	qemu-riscv@nongnu.org, qemu-s390x@nongnu.org,
	qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
	 Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 03/24] accel/tcg: Widen TranslationBlock::flags to 64 bits
Date: Fri, 27 Nov 2026 12:03:25 +0100	[thread overview]
Message-ID: <awlUl2by0PPZ2K7N@hive.localdomain> (raw)
In-Reply-To: <20261126233604.67722-4-philmd@oss.qualcomm.com>

On 27/11/26, Philippe Mathieu-Daudé wrote:
> 32-bit host support was removed in v11.0.0 (with commit 372ec46b9f
> "meson: Reject 32-bit hosts"), so there is no reason to keep the TB
> flags 32-bit. The wider field fills the 4-byte hole between icount
> and tc, leaving sizeof(TranslationBlock) unchanged. Widen
> TCGTBCPUState::flags too.
> 
> Feed the upper 32 bits into the TB hash, and adapt format string.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> ---
>  accel/tcg/tb-hash.h              | 5 +++--
>  include/accel/tcg/tb-cpu-state.h | 2 +-
>  include/exec/translation-block.h | 2 +-
>  accel/tcg/cpu-exec.c             | 2 +-
>  4 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/accel/tcg/tb-hash.h b/accel/tcg/tb-hash.h
> index f7b159f04cb6..819b594618aa 100644
> --- a/accel/tcg/tb-hash.h
> +++ b/accel/tcg/tb-hash.h
> @@ -63,9 +63,10 @@ static inline unsigned int tb_jmp_cache_hash_func(vaddr pc)
>  
>  static inline
>  uint32_t tb_hash_func(tb_page_addr_t phys_pc, vaddr pc,
> -                      uint32_t flags, uint64_t flags2, uint32_t cf_mask)
> +                      uint64_t flags, uint64_t flags2, uint32_t cf_mask)
>  {
> -    return qemu_xxhash8(phys_pc, pc, flags2, flags, cf_mask);
> +    /* Fold the upper flag bits into the cf_mask slot. */
> +    return qemu_xxhash8(phys_pc, pc, flags2, flags, cf_mask ^ (flags >> 32));
>  }

From what I can tell, while cf_mask ^ (flags >> 32) does increase the
probability for hash collisions it should still be extremely rare.
Currently the only possibility for extra collision is with the riscv ALTFMT,
BIG_ENDIAN, SDEXT_STEP fields and CF_COUNT_MASK, from what I can tell.

IMO, for the time being this wouldn't cause any real performance issues
compared to say adding an extra word to qemu_xxhash8().

Reviewed-by: Anton Johansson <anjo@rev.ng>


  reply	other threads:[~2026-11-27 10:57 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 23:35 [PATCH 00/24] accel/tcg: Widen TranslationBlock::flags to 64 bits Philippe Mathieu-Daudé
2026-11-26 23:35 ` [PATCH 01/24] target/arm: Widen CPUARMTBFlags::flags " Philippe Mathieu-Daudé
2026-11-27  9:58   ` Anton Johansson via
2026-11-27  9:58     ` Anton Johansson via qemu development
2026-11-27  9:58     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 02/24] accel/tcg: Update stale TranslationBlock::jmp_lock comment Philippe Mathieu-Daudé
2026-11-27  9:59   ` Anton Johansson via
2026-11-27  9:59     ` Anton Johansson via qemu development
2026-11-27  9:59     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 03/24] accel/tcg: Widen TranslationBlock::flags to 64 bits Philippe Mathieu-Daudé
2026-11-27 11:03   ` Anton Johansson via qemu development [this message]
2026-11-27 11:03     ` Anton Johansson via
2026-11-27 11:03     ` Anton Johansson via
2026-11-27 12:30     ` Philippe Mathieu-Daudé
2026-11-26 23:35 ` [PATCH 04/24] target/arm: Update TB flags split comment for 64-bit tb->flags Philippe Mathieu-Daudé
2026-11-27 11:09   ` Anton Johansson via
2026-11-27 11:09     ` Anton Johansson via qemu development
2026-11-27 11:09     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 05/24] target/alpha: Use 64-bit TB flags Philippe Mathieu-Daudé
2026-11-27 11:11   ` Anton Johansson via
2026-11-27 11:11     ` Anton Johansson via
2026-11-27 11:11     ` Anton Johansson via qemu development
2026-11-26 23:35 ` [PATCH 06/24] target/avr: " Philippe Mathieu-Daudé
2026-11-27 11:12   ` Anton Johansson via qemu development
2026-11-27 11:12     ` Anton Johansson via
2026-11-27 11:12     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 07/24] target/hexagon: " Philippe Mathieu-Daudé
2026-11-27  4:56   ` Brian Cain
2026-12-01  2:22   ` Brian Cain
2026-11-26 23:35 ` [PATCH 08/24] target/hppa: " Philippe Mathieu-Daudé
2026-11-27 11:13   ` Anton Johansson via qemu development
2026-11-27 11:13     ` Anton Johansson via
2026-11-27 11:13     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 09/24] target/i386: " Philippe Mathieu-Daudé
2026-11-27 11:14   ` Anton Johansson via qemu development
2026-11-27 11:14     ` Anton Johansson via
2026-11-27 11:14     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 10/24] target/loongarch: " Philippe Mathieu-Daudé
2026-11-27 11:16   ` Anton Johansson via qemu development
2026-11-27 11:16     ` Anton Johansson via
2026-11-27 11:16     ` Anton Johansson via
2026-11-30  1:03   ` Bibo Mao
2026-11-26 23:35 ` [PATCH 11/24] target/m68k: " Philippe Mathieu-Daudé
2026-11-27 11:16   ` Anton Johansson via qemu development
2026-11-27 11:16     ` Anton Johansson via
2026-11-27 11:16     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 12/24] target/microblaze: " Philippe Mathieu-Daudé
2026-11-27 11:17   ` Anton Johansson via
2026-11-27 11:17     ` Anton Johansson via
2026-11-27 11:17     ` Anton Johansson via qemu development
2026-11-26 23:35 ` [PATCH 13/24] target/mips: " Philippe Mathieu-Daudé
2026-11-27 11:19   ` Anton Johansson via qemu development
2026-11-27 11:19     ` Anton Johansson via
2026-11-27 11:19     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 14/24] target/or1k: " Philippe Mathieu-Daudé
2026-11-27 11:20   ` Anton Johansson via qemu development
2026-11-27 11:20     ` Anton Johansson via
2026-11-27 11:20     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 15/24] target/ppc: " Philippe Mathieu-Daudé
2026-11-27  7:57   ` Chinmay Rath
2026-11-27 12:09     ` Philippe Mathieu-Daudé
2026-11-26 23:35 ` [PATCH 16/24] target/riscv: " Philippe Mathieu-Daudé
2026-11-27 11:23   ` Anton Johansson via
2026-11-27 11:23     ` Anton Johansson via
2026-11-27 11:23     ` Anton Johansson via qemu development
2026-12-01  1:15   ` Alistair Francis
2026-12-01  1:16   ` Alistair Francis
2026-11-26 23:35 ` [PATCH 17/24] target/riscv: Partially revert use of tb->cs_base Philippe Mathieu-Daudé
2026-11-27 11:26   ` Anton Johansson via qemu development
2026-11-27 11:26     ` Anton Johansson via
2026-11-27 11:26     ` Anton Johansson via
2026-12-01  1:18   ` Alistair Francis
2026-11-26 23:35 ` [PATCH 18/24] target/rx: Use 64-bit TB flags Philippe Mathieu-Daudé
2026-11-27 11:27   ` Anton Johansson via qemu development
2026-11-27 11:27     ` Anton Johansson via
2026-11-27 11:27     ` Anton Johansson via
2026-11-28 13:42   ` yoshinori.sato
2026-11-26 23:35 ` [PATCH 19/24] target/s390x: " Philippe Mathieu-Daudé
2026-11-27 11:27   ` Anton Johansson via
2026-11-27 11:27     ` Anton Johansson via qemu development
2026-11-27 11:27     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 20/24] target/sh4: " Philippe Mathieu-Daudé
2026-11-27 11:29   ` Anton Johansson via
2026-11-27 11:29     ` Anton Johansson via qemu development
2026-11-27 11:29     ` Anton Johansson via
2026-11-28 13:42   ` yoshinori.sato
2026-11-26 23:35 ` [PATCH 21/24] target/sparc: " Philippe Mathieu-Daudé
2026-11-27 11:30   ` Anton Johansson via
2026-11-27 11:30     ` Anton Johansson via qemu development
2026-11-27 11:30     ` Anton Johansson via
2026-11-26 23:36 ` [PATCH 22/24] target/tricore: " Philippe Mathieu-Daudé
2026-11-27 11:31   ` Anton Johansson via
2026-11-27 11:31     ` Anton Johansson via qemu development
2026-11-27 11:31     ` Anton Johansson via
2026-11-26 23:36 ` [PATCH 23/24] target/xtensa: " Philippe Mathieu-Daudé
2026-11-27 11:32   ` Anton Johansson via qemu development
2026-11-27 11:32     ` Anton Johansson via
2026-11-27 11:32     ` Anton Johansson via
2026-11-26 23:36 ` [PATCH 24/24] accel/tcg: Update TranslationBlock::cs_base description Philippe Mathieu-Daudé
2026-11-27 11:34   ` Anton Johansson via
2026-11-27 11:34     ` Anton Johansson via qemu development
2026-11-27 11:34     ` Anton Johansson via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awlUl2by0PPZ2K7N@hive.localdomain \
    --to=qemu-devel@nongnu.org \
    --cc=anjo@rev.ng \
    --cc=pbonzini@redhat.com \
    --cc=philmd@oss.qualcomm.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.