[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v12 09/12] xen: add cache coloring allocator for domains


  • To: Carlo Nonato <carlo.nonato@xxxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 16 Dec 2024 14:08:13 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=minervasys.tech smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wW9Eczi97SpgvR7eCDs1FQ0fLj0o4WlujxzIJR3BSck=; b=ypSK1MvqXZ7u9lGPZ9a6RcotholWoC/MDNhjJIM7C4KsqlI99Y5KCx63hM8RqXXiqx3d3qzSt/eBGvU3ZlMDkisfxl1Td1U2Uz1Q0SjixpqxW8YpzY7eccA6FWk5Z2unvvvV/4paETVoBJbGZWN4JBPMfDtv+YlqrAt6ieYYCoGg+dognByPZkLH744z2ql6+lH8y7LxpOa2OqQ2Hv+I9bNLO7buAirwq7wwBIzX+ZalAvDNYg6QQsi3vGqs6Pcf0PajXWdpyXkh9OUwhqbSHZgoHosWwwBABYUB1GX6PZCBg3YfPZFe1SYPjb+ZwKKSHob3uT54NUlMNZEBkvB0JA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TshjHTNKH17CwxpCWl0hdMZrxz22K247PKv1akTw6sSr35NRCMWDFtp3csogENDnbaVsmedD/38F8f5OKnTEWoSTqT/lzZ2YSCjpbma87AcpKkqun2Fd27FIsmsd57g0m2qhLuhMJ2hA2Cj2vYksnmDkqudT0hwnMbWulINhZtlZcM9w19uDLAKKHj+zjx9rtpHHDFogFPRTSegf8kse0Tba/IfQi4yvV3Uy0dLAF5EUytvw6/FdLyUjS3rlfemNE5JF+lpePfdztwXwL9dP8jz6D4Jb/5ZHBsY9W3Rq/9kvxamBI1JBqQqeV44EVvpWVn/5LNbroRfebh15WLrXkg==
  • Cc: <andrea.bastoni@xxxxxxxxxxxxxxx>, <marco.solieri@xxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 16 Dec 2024 13:08:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 13/12/2024 17:28, Carlo Nonato wrote:
> 
> 
> Add a new memory page allocator that implements the cache coloring mechanism.
> The allocation algorithm enforces equal frequency distribution of cache
> partitions, following the coloring configuration of a domain. This allows
> for an even utilization of cache sets for every domain.
> 
> Pages are stored in a color-indexed array of lists. Those lists are filled
> by a simple init function which computes the color of each page.
> When a domain requests a page, the allocator extracts the page from the list
> with the maximum number of free pages among those that the domain can access,
> given its coloring configuration.
> 
> The allocator can only handle requests of order-0 pages. This allows for
> easier implementation and since cache coloring targets only embedded systems,
> it's assumed not to be a major problem.
> 
> The buddy allocator must coexist with the colored one because the Xen heap
> isn't colored. For this reason a new Kconfig option and a command line
> parameter are added to let the user set the amount of memory reserved for
> the buddy allocator. Even when cache coloring is enabled, this memory
> isn't managed by the colored allocator.
> 
> Colored heap information is dumped in the dump_heap() debug-key function.
> 
> Based on original work from: Luca Miccio <lucmiccio@xxxxxxxxx>
> 
> Signed-off-by: Marco Solieri <marco.solieri@xxxxxxxxxxxxxxx>
> Signed-off-by: Carlo Nonato <carlo.nonato@xxxxxxxxxxxxxxx>
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> v12:
> - fixed #ifdef CONFIG_LLC_COLORING in init_color_heap_pages()
> v11:
> - CONFIG_BUDDY_ALLOCATOR_SIZE depends on CONFIG_LLC_COLORING
> - buddy_alloc_size is defined only if CONFIG_LLC_COLORING
> - buddy-alloc-size param is parsed only if CONFIG_LLC_COLORING
> v10:
> - stated explicit dependency on CONFIG_LLC_COLORING for buddy-alloc-size
> - fix for MISRA rule 20.7 parenthesis
> v9:
> - added ASSERT(order == 0) when freeing a colored page
> - moved buddy_alloc_size initialization logic in Kconfig
> v8:
> - requests that uses MEMF_* flags that can't be served are now going to fail
> - free_color_heap_page() is called directly from free_heap_pages()
> v7:
> - requests to alloc_color_heap_page() now fail if MEMF_bits is used
> v6:
> - colored allocator functions are now static
> v5:
> - Carlo Nonato as the new author
> - the colored allocator balances color usage for each domain and it searches
>   linearly only in the number of colors (FIXME removed)
> - addedd scrub functionality
> - removed stub functions (still requires some macro definition)
> - addr_to_color turned to mfn_to_color for easier operations
> - removed BUG_ON in init_color_heap_pages() in favor of panic()
> - only non empty page lists are logged in dump_color_heap()
> v4:
> - moved colored allocator code after buddy allocator because it now has
>   some dependencies on buddy functions
> - buddy_alloc_size is now used only by the colored allocator
> - fixed a bug that allowed the buddy to merge pages when they were colored
> - free_color_heap_page() now calls mark_page_free()
> - free_color_heap_page() uses of the frametable array for faster searches
> - added FIXME comment for the linear search in free_color_heap_page()
> - removed alloc_color_domheap_page() to let the colored allocator exploit
>   some more buddy allocator code
> - alloc_color_heap_page() now allocs min address pages first
> - reduced the mess in end_boot_allocator(): use the first loop for
>   init_color_heap_pages()
> - fixed page_list_add_prev() (list.h) since it was doing the opposite of
>   what it was supposed to do
> - fixed page_list_add_prev() (non list.h) to check also for next existence
> - removed unused page_list_add_next()
> - moved p2m code in another patch
> ---
>  docs/misc/cache-coloring.rst      |  37 ++++++
>  docs/misc/xen-command-line.pandoc |  14 +++
>  xen/arch/arm/include/asm/mm.h     |   5 +
[...]

> +#ifdef CONFIG_LLC_COLORING
> +/* Page is cache colored */
> +#define _PGC_colored      PG_shift(4)
NIT: do we really need to define it if it's not used? I don't like this concept 
but
I quickly checked new arches and they also copied some flags that are not used, 
so
maybe it's the proper way to go.

Acked-by: Michal Orzel <michal.orzel@xxxxxxx>

~Michal




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.