Skip to contentSkip to conversation

xen: Spread boot time page scrubbing across all available CPU's (v8)

PATCH New Konrad Rzeszutek Wilk 1 participant 1 message Jun 13, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Spread boot time page scrubbing across all available CPU's (v8)

From: Malcolm Crossley <[email protected]>

The page scrubbing is done in 128MB chunks in lockstep across all the non-SMT CPU's. This allows for the boot CPU to hold the heap_lock whilst each chunk is being scrubbed and then release the heap_lock when the CPU's are finished scrubing their individual chunk. This allows for the heap_lock to not be held continously and for pending softirqs are to be serviced periodically across the CPU's.

The page scrub memory chunks are allocated to the CPU's in a NUMA aware fashion to reduce socket interconnect overhead and improve performance. Specifically in the first phase we scrub at the same time on all the NUMA nodes that have CPUs - we also weed out the SMT threads so that we only use cores (that gives a 50% boost). The second phase is for NUMA nodes that have no CPUs - for that we use the closest NUMA node's CPUs (non-SMT again) to do the job.

This patch reduces the boot page scrub time on a 128GB 64 core AMD Opteron 6386 machine from 49 seconds to 3 seconds.
On a IvyBridge-EX 8 socket box with 1.5TB it cuts it down from 15 minutes to 63 seconds.

---

v2
- Reduced default chunk size to 128MB
- Added code to scrub NUMA nodes with no active CPU linked to them
- Be robust to boot CPU not being linked to a NUMA node

v3:
- Don't use SMT threads
- Take care of remainder if the number of CPUs (or memory) is odd
- Restructure the worker thread
- s/u64/unsigned long/

v4:
- Don't use all CPUs on non-CPU NUMA nodes, just closest one
- Syntax, and docs updates
- Compile on ARM
- Fix bug when NUMA node has 0 pages

v5:
- Properly figure out best NUMA node.
- Fix comments to be proper style.

v6:
- Missing page shift on default values, optimize cpumask usage.
- Fix case of NODE having one page and below first_valid_mfn
- Add Reviewed-by

v7:
- Add Reviewed-by
- Fix issues spotted by Andrew.

v8:
- Fix issue spotted by Konrad.

---
 docs/misc/xen-command-line.markdown |   10 ++
 xen/common/page_alloc.c             |  214 ++++++++++++++++++++++++++++++++---
 xen/include/asm-arm/numa.h          |    1 +
 3 files changed, 207 insertions(+), 18 deletions(-)
docs/misc/xen-command-line.markdown +10 -0
index 25829fe..94f04bd 100644
@@ -198,6 +198,16 @@ Scrub free RAM during boot.  This is a safety feature to prevent
 accidentally leaking sensitive VM data into other VMs if Xen crashes
 and reboots.
 
+### `bootscrub_chunk`
+> `= <size>`
+
+> Default: `128M`
+
+Maximum RAM block size chunks to be scrubbed whilst holding the page heap lock
+and not running softirqs. Reduce this if softirqs are not being run frequently
+enough. Setting this to a high value may cause boot failure, particularly if
+the NMI watchdog is also enabled.
+
 ### cachesize
 > `= <size>`
 
xen/common/page_alloc.c +196 -18

250 lines not on this page · raw message

xen/include/asm-arm/numa.h +1 -0
index cb8f2ba..2c019d7 100644
@@ -12,6 +12,7 @@ static inline __attribute__((pure)) int phys_to_nid(paddr_t addr)
 
 /* XXX: implement NUMA support */
 #define node_spanned_pages(nid) (total_pages)
+#define node_start_pfn(nid) (frametable_base_mfn)
 #define __node_distance(a, b) (20)
 
 #endif /* __ARCH_ARM_NUMA_H */
Signature · 1 line
1.7.7.6