qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: agraf@suse.de
Cc: aliguori@us.ibm.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH 1/6] pseries: Set hash table size based on RAM size
Date: Wed, 26 Sep 2012 13:12:16 +1000	[thread overview]
Message-ID: <1348629141-8719-2-git-send-email-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <1348629141-8719-1-git-send-email-david@gibson.dropbear.id.au>

Currently the pseries machine code always attempts to set the size of the
guests's hash page table to 16MB.  However, because of the way the POWER
MMU works, a suitable hash page table size should really depend on memory
size.  16MB will be excessive for guests with <1GB and RAM, and may not be
enough for guests with >2GB of RAM (depending on guest page size and
other factors).

The usual given rule of thumb is that the hash table should be 1/64 of
the size of memory, but in fact the Linux guests we are aiming at don't
really need that much.  This patch, therefore, changes the hash table
allocation code to aim for 1/128 of the size of RAM (rounding up).  When
using KVM, this size may still be adjusted by the host kernel if it is
unable to allocate a suitable (contiguous) table.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

---

This patch can only be safely applied after my earlier patch
"target-ppc: KVM: Fix some kernel version edge cases for
kvmppc_reset_htab()" (already in ppc-next), otherwise the kernel can
end up advertising to the guest a hash table size different from that
actually allocated by the kernel.
---
 hw/spapr.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/hw/spapr.c b/hw/spapr.c
index 1177efa..a8bd3c1 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -725,9 +725,16 @@ static void ppc_spapr_init(ram_addr_t ram_size,
     spapr->fdt_addr = spapr->rtas_addr - FDT_MAX_SIZE;
     load_limit = spapr->fdt_addr - FW_OVERHEAD;
 
-    /* For now, always aim for a 16MB hash table */
-    /* FIXME: we should change this default based on RAM size */
-    spapr->htab_shift = 24;
+    /* We aim for a hash table of size 1/128 the size of RAM.  The
+     * normal rule of thumb is 1/64 the size of RAM, but that's much
+     * more than needed for the Linux guests we support. */
+    spapr->htab_shift = 18; /* Minimum architected size */
+    while (spapr->htab_shift <= 46) {
+        if ((1ULL << (spapr->htab_shift + 7)) >= ram_size) {
+            break;
+        }
+        spapr->htab_shift++;
+    }
 
     /* init CPUs */
     if (cpu_model == NULL) {
-- 
1.7.10.4

  reply	other threads:[~2012-09-26  3:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-26  3:12 [Qemu-devel] [0/6] Pending pseries updates David Gibson
2012-09-26  3:12 ` David Gibson [this message]
2012-09-26  3:12 ` [Qemu-devel] [PATCH 2/6] target-ppc: Remove unused power_mode field from cpu state David Gibson
2012-09-26  3:12 ` [Qemu-devel] [PATCH 3/6] target-ppc: Extend FPU state for newer POWER CPUs David Gibson
2012-09-26  6:36   ` Aurelien Jarno
2012-09-27  0:03     ` [Qemu-devel] [Qemu-ppc] " David Gibson
2012-09-26  3:12 ` [Qemu-devel] [PATCH 4/6] pseries: Implement PAPR NVRAM David Gibson
2012-09-26 12:55   ` Alexander Graf
2012-09-26 21:25     ` [Qemu-devel] [Qemu-ppc] " Alexander Graf
2012-09-26  3:12 ` [Qemu-devel] [PATCH 5/6] pseries: Don't test for MSR_PR for hypercalls under KVM David Gibson
2012-09-26  3:12 ` [Qemu-devel] [PATCH 6/6] ppc/pseries: Reset VPA registration on CPU reset David Gibson
2012-09-26 12:59 ` [Qemu-devel] [0/6] Pending pseries updates Alexander Graf
2012-09-26 23:31   ` [Qemu-devel] [Qemu-ppc] " David Gibson
2012-09-27  8:05     ` Alexander Graf
2012-09-27 10:29       ` David Gibson

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=1348629141-8719-2-git-send-email-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=agraf@suse.de \
    --cc=aliguori@us.ibm.com \
    --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).