From: Zhao Liu <zhao1.liu@intel.com>
To: John Snow <jsnow@redhat.com>
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>,
Zhao Liu <zhao1.liu@intel.com>
Subject: Re: [PATCH] i386/cpu: mark CPU properties as const
Date: Fri, 20 Nov 2026 17:58:23 +0800 [thread overview]
Message-ID: <awAZv3AsmNdJ7oUW@intel.com> (raw)
In-Reply-To: <20261119180859.1044425-1-jsnow@redhat.com>
Hi John,
On Thu, Nov 19, 2026 at 01:08:59PM -0500, John Snow wrote:
> Date: Thu, 19 Nov 2026 13:08:59 -0500
> From: John Snow <jsnow@redhat.com>
> Subject: [PATCH] i386/cpu: mark CPU properties as const
>
> Currently, these large property tables are loaded in the read-write
> `.data` segment; by marking them as const they can be loaded as part
> of `.rodata` instead, where these tables can be shared between multiple
> instances of QEMU as RssFile memory instead of RssAnon memory.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
> target/i386/cpu-internal.h | 2 +-
> target/i386/cpu-system.c | 2 +-
> target/i386/cpu.c | 30 +++++++++++++++---------------
> target/i386/kvm/tdx.c | 2 +-
> 4 files changed, 18 insertions(+), 18 deletions(-)
I'm fine with the "const" change, but it seems only
cpuid2_cache_descriptors can move to .rodata:
$ objdump -t build/libqemu-x86_64-softmmu.a.p/target_i386_cpu.c.o | grep -wE 'feature_word_info|cpuid2_cache_descriptors|epyc_v5_cache_info|epyc_v4_cache_info'
0000000000005fa0 l O .data.rel.ro.local 0000000000000020 epyc_v4_cache_info
0000000000005f80 l O .data.rel.ro.local 0000000000000020 epyc_v5_cache_info
0000000000000d20 g O .rodata 0000000000001284 cpuid2_cache_descriptors
00000000000060a0 g O .data.rel.ro.local 0000000000006a80 feature_word_info
I think it's because FeatureWordInfo and CPUCaches have pointer fields.
So with the commit message fixed:
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
...
Futhermore, for CPUCaches, it could embed the cache info by value:
typedef struct CPUCaches {
CPUCacheInfo l1d_cache;
CPUCacheInfo l1i_cache;
CPUCacheInfo l2_cache;
CPUCacheInfo l3_cache;
} CPUCaches;
although the cache info will be stored in .rodata, this would also give
each vCPU its own copy, so smp-cache would no longer modify the global
tables. The cost is that CPUX86State grows per vCPU (from 4 pointers to
4 full CPUCacheInfo). So, maybe there’s room for further optimization,
but that’s a separate issue, not a blocker for this patch.
For FeatureWordInfo, what I can think of right now is to make the
feature name array a fixed length like:
#define FEAT_NAME_SIZE 36 /* strlen("vmx-invept-single-context-noglobals") + 1 */
typedef struct FeatureWordInfo {
FeatureWordType type;
char feat_names[64][FEAT_NAME_SIZE];
...
} FeatureWordInfo;
Thanks,
Zhao
prev parent reply other threads:[~2026-11-20 9:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 18:08 [PATCH] i386/cpu: mark CPU properties as const John Snow
2026-11-19 18:40 ` Peter Maydell
2026-11-19 18:55 ` Richard Henderson
2026-11-20 9:58 ` Zhao Liu [this message]
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=awAZv3AsmNdJ7oUW@intel.com \
--to=zhao1.liu@intel.com \
--cc=jsnow@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox