From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Alexander Graf <agraf@suse.de>
Cc: qemu-ppc@nongnu.org, paulus@samba.org,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH -V4 2/4] target-ppc: Fix page table lookup with kvm enabled
Date: Mon, 07 Oct 2013 19:28:27 +0530 [thread overview]
Message-ID: <87k3hpnpx8.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <EBAFED68-8C91-4224-BDE1-2B2E4121E6F5@suse.de>
Alexander Graf <agraf@suse.de> writes:
> On 01.10.2013, at 03:27, Aneesh Kumar K.V wrote:
>
>> Alexander Graf <agraf@suse.de> writes:
>>
>>> On 09/05/2013 10:16 AM, Aneesh Kumar K.V wrote:
>>>> From: "Aneesh Kumar K.V"<aneesh.kumar@linux.vnet.ibm.com>
>>>>
....
>>
>> Can you explain this better ?
>
> You're basically doing
>
> hwaddr ppc_hash64_pteg_search(...)
> {
> if (kvm) {
> pteg = read_from_kvm();
> foreach pte in pteg {
> if (match) return offset;
> }
> return -1;
> } else {
> foreach pte in pteg {
> pte = read_pte_from_memory();
> if (match) return offset;
> }
> return -1;
> }
> }
>
> This is massive code duplication. The only difference between kvm and
> tcg are the source for the pteg read. David already abstracted the
> actual pte0/pte1 reads away in ppc_hash64_load_hpte0 and
> ppc_hash64_load_hpte1 wrapper functions.
>
> Now imagine we could add a temporary pteg store in env. Then have something like this in ppc_hash64_load_hpte0:
>
> if (need_kvm_htab_access) {
> if (env->current_cached_pteg != this_pteg) (
> read_pteg(env->cached_pteg);
> return env->cached_pteg[x].pte0;
> }
> } else {
> <do what was done before>
> }
>
> That way the actual resolver doesn't care where the PTEG comes from,
> as it only ever checks pte0/pte1 and leaves all the magic on where
> those come from to the load function.
I tried to do this and didn't like the end result. For one we
unnecessarly bloat CPUPPCState struct to now carry a pteg information
and associated array. ie, we need to have now the below in the CPUPPCState.
int pteg_group;
unsigned long hpte[(HPTES_PER_GROUP * 2) + 1];
Also out serach can be much effective with the current code,
while (index < hpte_buf.header.n_valid) {
against
for (i = 0; i < HPTES_PER_GROUP; i++) {
I guess the former is better when we can find invalid hpte entries.
We now also need to update kvm_cpu_synchronize_state to clear
pte_group so that we would not look at the stale values. If we ever want
to use reading pteg in any other place we could possibly look at doing
this. But at this stage, IMHO it unnecessarily make it all complex and
less efficient.
-aneesh
next prev parent reply other threads:[~2013-10-07 13:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1378369007-958-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
[not found] ` <1378369007-958-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
2013-09-25 15:41 ` [Qemu-devel] [PATCH -V4 1/4] target-ppc: Update slb array with correct index values Aneesh Kumar K.V
2013-09-30 17:40 ` Alexander Graf
2013-10-01 1:29 ` Aneesh Kumar K.V
[not found] ` <1378369007-958-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
2013-09-30 17:48 ` [Qemu-devel] [PATCH -V4 2/4] target-ppc: Fix page table lookup with kvm enabled Alexander Graf
2013-09-30 17:50 ` Alexander Graf
2013-10-01 1:27 ` Aneesh Kumar K.V
2013-10-02 13:59 ` Alexander Graf
2013-10-07 13:58 ` Aneesh Kumar K.V [this message]
2013-10-07 14:04 ` Alexander Graf
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=87k3hpnpx8.fsf@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=agraf@suse.de \
--cc=paulus@samba.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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;
as well as URLs for NNTP newsgroup(s).