Message ID | 20200217173452.15243-73-imammedo@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | refactor main RAM allocation to use hostmem backend | expand |
On 2/17/20 9:34 AM, Igor Mammedov wrote: > all boards were switched to using memdev backend for main RAM, > so we can drop no longer used memory_region_allocate_system_memory() > > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > --- > CC: ehabkost@redhat.com > CC: pbonzini@redhat.com > --- > include/hw/boards.h | 32 -------------------------------- > hw/core/numa.c | 34 ---------------------------------- > 2 files changed, 66 deletions(-) Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~
On 2/17/20 6:34 PM, Igor Mammedov wrote: > all boards were switched to using memdev backend for main RAM, > so we can drop no longer used memory_region_allocate_system_memory() > > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > --- > CC: ehabkost@redhat.com > CC: pbonzini@redhat.com > --- > include/hw/boards.h | 32 -------------------------------- > hw/core/numa.c | 34 ---------------------------------- > 2 files changed, 66 deletions(-) > > diff --git a/include/hw/boards.h b/include/hw/boards.h > index ae2b60fb5e..142b86d0ae 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -12,38 +12,6 @@ > #include "qom/object.h" > #include "hw/core/cpu.h" > > -/** > - * memory_region_allocate_system_memory - Allocate a board's main memory > - * @mr: the #MemoryRegion to be initialized > - * @owner: the object that tracks the region's reference count > - * @name: name of the memory region > - * @ram_size: size of the region in bytes > - * > - * This function allocates the main memory for a board model, and > - * initializes @mr appropriately. It also arranges for the memory > - * to be migrated (by calling vmstate_register_ram_global()). > - * > - * Memory allocated via this function will be backed with the memory > - * backend the user provided using "-mem-path" or "-numa node,memdev=..." > - * if appropriate; this is typically used to cause host huge pages to be > - * used. This function should therefore be called by a board exactly once, > - * for the primary or largest RAM area it implements. > - * > - * For boards where the major RAM is split into two parts in the memory > - * map, you can deal with this by calling memory_region_allocate_system_memory() > - * once to get a MemoryRegion with enough RAM for both parts, and then > - * creating alias MemoryRegions via memory_region_init_alias() which > - * alias into different parts of the RAM MemoryRegion and can be mapped > - * into the memory map in the appropriate places. > - * > - * Smaller pieces of memory (display RAM, static RAMs, etc) don't need > - * to be backed via the -mem-path memory backend and can simply > - * be created via memory_region_init_ram(). > - */ > -void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, > - const char *name, > - uint64_t ram_size); > - > #define TYPE_MACHINE_SUFFIX "-machine" > > /* Machine class name that needs to be used for class-name-based machine > diff --git a/hw/core/numa.c b/hw/core/numa.c > index e6baf2c33e..316bc50d75 100644 > --- a/hw/core/numa.c > +++ b/hw/core/numa.c > @@ -806,40 +806,6 @@ void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **errp) > } > } > > -static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, > - const char *name, > - uint64_t ram_size) > -{ > - if (mem_path) { > -#ifdef __linux__ > - memory_region_init_ram_from_file(mr, owner, name, ram_size, 0, 0, > - mem_path, &error_fatal); > -#else > - fprintf(stderr, "-mem-path not supported on this host\n"); > - exit(1); > -#endif > - } else { > - memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal); > - } > - vmstate_register_ram_global(mr); > -} > - > -void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, > - const char *name, > - uint64_t ram_size) > -{ > - MachineState *ms = MACHINE(qdev_get_machine()); > - > - if (ms->numa_state == NULL || > - ms->numa_state->num_nodes == 0 || numa_uses_legacy_mem()) { > - allocate_system_memory_nonnuma(mr, owner, name, ram_size); > - return; > - } > - > - memory_region_init(mr, owner, name, ram_size); > - numa_init_memdev_container(ms, mr); > -} > - > static void numa_stat_memory_devices(NumaNodeMem node_mem[]) > { > MemoryDeviceInfoList *info_list = qmp_memory_device_list(); > Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff --git a/include/hw/boards.h b/include/hw/boards.h index ae2b60fb5e..142b86d0ae 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -12,38 +12,6 @@ #include "qom/object.h" #include "hw/core/cpu.h" -/** - * memory_region_allocate_system_memory - Allocate a board's main memory - * @mr: the #MemoryRegion to be initialized - * @owner: the object that tracks the region's reference count - * @name: name of the memory region - * @ram_size: size of the region in bytes - * - * This function allocates the main memory for a board model, and - * initializes @mr appropriately. It also arranges for the memory - * to be migrated (by calling vmstate_register_ram_global()). - * - * Memory allocated via this function will be backed with the memory - * backend the user provided using "-mem-path" or "-numa node,memdev=..." - * if appropriate; this is typically used to cause host huge pages to be - * used. This function should therefore be called by a board exactly once, - * for the primary or largest RAM area it implements. - * - * For boards where the major RAM is split into two parts in the memory - * map, you can deal with this by calling memory_region_allocate_system_memory() - * once to get a MemoryRegion with enough RAM for both parts, and then - * creating alias MemoryRegions via memory_region_init_alias() which - * alias into different parts of the RAM MemoryRegion and can be mapped - * into the memory map in the appropriate places. - * - * Smaller pieces of memory (display RAM, static RAMs, etc) don't need - * to be backed via the -mem-path memory backend and can simply - * be created via memory_region_init_ram(). - */ -void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, - const char *name, - uint64_t ram_size); - #define TYPE_MACHINE_SUFFIX "-machine" /* Machine class name that needs to be used for class-name-based machine diff --git a/hw/core/numa.c b/hw/core/numa.c index e6baf2c33e..316bc50d75 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -806,40 +806,6 @@ void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **errp) } } -static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, - const char *name, - uint64_t ram_size) -{ - if (mem_path) { -#ifdef __linux__ - memory_region_init_ram_from_file(mr, owner, name, ram_size, 0, 0, - mem_path, &error_fatal); -#else - fprintf(stderr, "-mem-path not supported on this host\n"); - exit(1); -#endif - } else { - memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal); - } - vmstate_register_ram_global(mr); -} - -void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, - const char *name, - uint64_t ram_size) -{ - MachineState *ms = MACHINE(qdev_get_machine()); - - if (ms->numa_state == NULL || - ms->numa_state->num_nodes == 0 || numa_uses_legacy_mem()) { - allocate_system_memory_nonnuma(mr, owner, name, ram_size); - return; - } - - memory_region_init(mr, owner, name, ram_size); - numa_init_memdev_container(ms, mr); -} - static void numa_stat_memory_devices(NumaNodeMem node_mem[]) { MemoryDeviceInfoList *info_list = qmp_memory_device_list();
all boards were switched to using memdev backend for main RAM, so we can drop no longer used memory_region_allocate_system_memory() Signed-off-by: Igor Mammedov <imammedo@redhat.com> --- CC: ehabkost@redhat.com CC: pbonzini@redhat.com --- include/hw/boards.h | 32 -------------------------------- hw/core/numa.c | 34 ---------------------------------- 2 files changed, 66 deletions(-)