qemu-e2k/include/qemu
Laurent Vivier 3bfe57165b numa: equally distribute memory on nodes
When there are more nodes than available memory to put the minimum
allowed memory by node, all the memory is put on the last node.

This is because we put (ram_size / nb_numa_nodes) &
~((1 << mc->numa_mem_align_shift) - 1); on each node, and in this
case the value is 0. This is particularly true with pseries,
as the memory must be aligned to 256MB.

To avoid this problem, this patch uses an error diffusion algorithm [1]
to distribute equally the memory on nodes.

We introduce numa_auto_assign_ram() function in MachineClass
to keep compatibility between machine type versions.
The legacy function is used with pseries-2.9, pc-q35-2.9 and
pc-i440fx-2.9 (and previous), the new one with all others.

Example:

qemu-system-ppc64 -S -nographic  -nodefaults -monitor stdio -m 1G -smp 8 \
                  -numa node -numa node -numa node \
                  -numa node -numa node -numa node

Before:

(qemu) info numa
6 nodes
node 0 cpus: 0 6
node 0 size: 0 MB
node 1 cpus: 1 7
node 1 size: 0 MB
node 2 cpus: 2
node 2 size: 0 MB
node 3 cpus: 3
node 3 size: 0 MB
node 4 cpus: 4
node 4 size: 0 MB
node 5 cpus: 5
node 5 size: 1024 MB

After:
(qemu) info numa
6 nodes
node 0 cpus: 0 6
node 0 size: 0 MB
node 1 cpus: 1 7
node 1 size: 256 MB
node 2 cpus: 2
node 2 size: 0 MB
node 3 cpus: 3
node 3 size: 256 MB
node 4 cpus: 4
node 4 size: 256 MB
node 5 cpus: 5
node 5 size: 256 MB

[1] https://en.wikipedia.org/wiki/Error_diffusion

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20170502162955.1610-2-lvivier@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
[ehabkost: s/ram_size/size/ at numa_default_auto_assign_ram()]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2017-05-11 16:08:47 -03:00
..
acl.h
atomic.h atomics: Add __nocheck atomic operations 2016-10-26 08:28:57 -07:00
base64.h
bcd.h
bitmap.h bitmap: add bitmap_copy_and_clear_atomic 2017-04-24 10:12:28 +02:00
bitops.h bitops: fix rol/ror when shift is zero 2016-11-15 10:05:50 +11:00
bswap.h
buffer.h
compiler.h use _Static_assert in QEMU_BUILD_BUG_ON 2017-05-05 12:09:59 +02:00
config-file.h arch_init: Remove unnecessary default_config_files table 2017-01-23 21:25:36 -02:00
coroutine_int.h aio: introduce aio_co_schedule and aio_co_wake 2017-02-21 11:14:07 +00:00
coroutine.h coroutine: Extract qemu_aio_coroutine_enter 2017-04-11 20:07:15 +08:00
crc32c.h
cutils.h util/cutils: Change qemu_strtosz*() from int64_t to uint64_t 2017-02-23 20:35:36 +01:00
envlist.h
error-report.h qemu-error: remove dependency of stubs on monitor 2016-11-01 16:06:57 +01:00
event_notifier.h event_notifier: cleanups around event_notifier_set_handler 2017-01-16 17:52:35 +01:00
fifo8.h
fifo32.h
fprintf-fn.h
futex.h qemu-thread: optimize QemuLockCnt with futexes on Linux 2017-01-16 13:25:18 +00:00
hbitmap.h hbitmap: Add hbitmap_is_serializable() 2017-01-26 10:25:01 +08:00
help_option.h
host-utils.h Drop QEMU_GNUC_PREREQ() checks for gcc older than 4.1 2017-04-20 18:33:33 +01:00
id.h
int128.h tcg: Add atomic128 helpers 2016-10-26 08:29:01 -07:00
iov.h
jhash.h Jhash: add linux kernel jhashtable in qemu 2016-09-27 17:54:21 +08:00
log.h log: Add locking to large logging blocks 2016-11-01 10:29:03 -06:00
main-loop.h event_notifier: cleanups around event_notifier_set_handler 2017-01-16 17:52:35 +01:00
memfd.h
mmap-alloc.h exec, kvm, target-ppc: Move getrampagesize() to common code 2017-03-03 11:30:59 +11:00
module.h qmp: Dumb down how we run QMP command registration 2017-03-05 09:02:10 +01:00
notify.h
option_int.h
option.h keyval: New keyval_parse() 2017-03-07 16:07:46 +01:00
osdep.h mem-prealloc: reduce large guest start-up and migration time. 2017-03-14 13:26:36 +01:00
path.h
processor.h
qdist.h
qht.h include: Fix typos found by codespell 2017-01-24 23:26:52 +03:00
queue.h migration: migrate QTAILQ 2017-01-24 17:54:47 +00:00
range.h
ratelimit.h
rcu_queue.h
rcu.h all: Remove unnecessary glib.h includes 2016-06-07 18:19:24 +03:00
readline.h
seqlock.h seqlock: use atomic writes for the sequence 2016-10-04 10:00:26 +02:00
sockets.h sockets: Delete unused helper socket_address_crumple() 2017-05-09 09:14:40 +02:00
systemd.h qemu-ga: obey LISTEN_PID when using systemd socket activation 2017-03-19 11:12:12 +01:00
thread-posix.h qemu-thread: introduce QemuRecMutex 2016-10-28 21:50:18 +08:00
thread-win32.h win32: replace custom mutex and condition variable with native primitives 2017-03-27 14:41:01 +02:00
thread.h qemu-thread: optimize QemuLockCnt with futexes on Linux 2017-01-16 13:25:18 +00:00
throttle-options.h throttle: factor out duplicate code 2017-02-28 10:31:46 +01:00
throttle.h
timed-average.h
timer.h cpus: introduce cpu_update_icount helper 2017-04-10 10:23:38 +01:00
typedefs.h numa: equally distribute memory on nodes 2017-05-11 16:08:47 -03:00
unicode.h
uri.h Remove unused function declarations 2016-09-15 15:32:22 +03:00
uuid.h vl: Switch qemu_uuid to QemuUUID 2016-09-23 11:42:52 +08:00
xattr.h include: Fix typos found by codespell 2017-01-24 23:26:52 +03:00