|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH V3 4/6] xen/unpopulated-alloc: Add mechanism to use Xen resource
On 25.11.21 03:03, Stefano Stabellini wrote: Hi Stefano, all On Wed, 24 Nov 2021, Oleksandr Tyshchenko wrote:From: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx> The main reason of this change is that unpopulated-alloc code cannot be used in its current form on Arm, but there is a desire to reuse it to avoid wasting real RAM pages for the grant/foreign mappings. The problem is that system "iomem_resource" is used for the address space allocation, but the really unallocated space can't be figured out precisely by the domain on Arm without hypervisor involvement. For example, not all device I/O regions are known by the time domain starts creating grant/foreign mappings. And following the advise from "iomem_resource" we might end up reusing these regions by a mistake. So, the hypervisor which maintains the P2M for the domain is in the best position to provide unused regions of guest physical address space which could be safely used to create grant/foreign mappings. Introduce new helper arch_xen_unpopulated_init() which purpose is to create specific Xen resource based on the memory regions provided by the hypervisor to be used as unused space for Xen scratch pages. If arch doesn't define arch_xen_unpopulated_init() the default "iomem_resource" will be used. Update the arguments list of allocate_resource() in fill_list() to always allocate a region from the hotpluggable range (maximum possible addressable physical memory range for which the linear mapping could be created). If arch doesn't define arch_get_mappable_range() the default range (0,-1) will be used. The behaviour on x86 won't be changed by current patch as both arch_xen_unpopulated_init() and arch_get_mappable_range() are not implemented for it. Also fallback to allocate xenballooned pages (balloon out RAM pages) if we do not have any suitable resource to work with (target_resource is invalid) and as the result we won't be able to provide unpopulated pages on a request. Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> Thanks!What still worries me is a concern with x86's xen_pvh_gnttab_setup() I described in post commit remark ... --- Please note the following: for V3 arch_xen_unpopulated_init() was moved to init() as was agreed and gained __init specifier. So the target_resource is initialized there. With current patch series applied if CONFIG_XEN_UNPOPULATED_ALLOC is enabled: 1. On Arm, under normal circumstances, the xen_alloc_unpopulated_pages() won't be called “before” arch_xen_unpopulated_init(). It will only be called "before" when either ACPI is in use or something wrong happened with DT (and we failed to read xen_grant_frames), so we fallback to xen_xlate_map_ballooned_pages() in arm/xen/enlighten.c:xen_guest_init(), please see "arm/xen: Switch to use gnttab_setup_auto_xlat_frames() for DT" for details. But in that case, I think, it doesn't matter much whether xen_alloc_unpopulated_pages() is called "before" of "after" target_resource initialization, as we don't have extended regions in place the target_resource will remain invalid even after initialization, so xen_alloc_ballooned_pages() will be used in both scenarios. 2. On x86, I am not quite sure which modes use unpopulated-alloc (PVH?), but it looks like xen_alloc_unpopulated_pages() can (and will) be called “before” arch_xen_unpopulated_init(). At least, I see that xen_xlate_map_ballooned_pages() is called in x86/xen/grant-table.c:xen_pvh_gnttab_setup(). According to the initcall levels for both xen_pvh_gnttab_setup() and init() I expect the former to be called earlier. If it is true, the sentence in the commit description which mentions that “behaviour on x86 is not changed” is not precise. I don’t think it would be correct to fallback to xen_alloc_ballooned_pages() just because we haven’t initialized target_resource yet (on x86 it is just assigning it iomem_resource), at least this doesn't look like an expected behaviour and unlikely would be welcome. I am wondering whether it would be better to move arch_xen_unpopulated_init() to a dedicated init() marked with an appropriate initcall level (early_initcall?) to make sure it will always be called *before* xen_xlate_map_ballooned_pages(). What do you think? ... here (#2). Or I really missed something and there wouldn't be an issue?
-- Regards, Oleksandr Tyshchenko
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |