[PATCH v2 2/2] xen/mm: reject XENMEM_claim_pages when using LLC coloring

Roger Pau Monne posted 2 patches 2 weeks ago
[PATCH v2 2/2] xen/mm: reject XENMEM_claim_pages when using LLC coloring
Posted by Roger Pau Monne 2 weeks ago
The coloring allocator ignores claims, reject the usage of the hypercall if
LLC coloring is enabled.  Note that the usage of alloc_color_heap_page() is
selected at boot time, and it's a system wide decision.  Once enabled all
domains will use alloc_color_heap_page() for allocations, which ignores any
outstanding claims.

The hypercall can be enabled if/when LLC coloring is adjusted to support
claims.

Fixes: 95debe51a936 ("xen: add cache coloring allocator for domains")
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/common/memory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/common/memory.c b/xen/common/memory.c
index ae805ccbe4d1..3d978227276a 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -1660,6 +1660,9 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
 
     case XENMEM_claim_pages:
+        if ( llc_coloring_enabled )
+            return -EOPNOTSUPP;
+
         if ( unlikely(start_extent) )
             return -EINVAL;
 
-- 
2.51.0


Re: [PATCH v2 2/2] xen/mm: reject XENMEM_claim_pages when using LLC coloring
Posted by Andrew Cooper 2 weeks ago
On 24/12/2025 7:40 pm, Roger Pau Monne wrote:
> The coloring allocator ignores claims, reject the usage of the hypercall if

Minor grammar nit.  You want a semicolon here rather than a comma.

> LLC coloring is enabled.  Note that the usage of alloc_color_heap_page() is
> selected at boot time, and it's a system wide decision.  Once enabled all
> domains will use alloc_color_heap_page() for allocations, which ignores any
> outstanding claims.
>
> The hypercall can be enabled if/when LLC coloring is adjusted to support
> claims.
>
> Fixes: 95debe51a936 ("xen: add cache coloring allocator for domains")
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Re: [PATCH v2 2/2] xen/mm: reject XENMEM_claim_pages when using LLC coloring
Posted by Andrew Cooper 2 weeks ago
On 24/12/2025 8:33 pm, Andrew Cooper wrote:
> On 24/12/2025 7:40 pm, Roger Pau Monne wrote:
>> The coloring allocator ignores claims, reject the usage of the hypercall if
> Minor grammar nit.  You want a semicolon here rather than a comma.
>
>> LLC coloring is enabled.  Note that the usage of alloc_color_heap_page() is
>> selected at boot time, and it's a system wide decision.  Once enabled all
>> domains will use alloc_color_heap_page() for allocations, which ignores any
>> outstanding claims.
>>
>> The hypercall can be enabled if/when LLC coloring is adjusted to support
>> claims.
>>
>> Fixes: 95debe51a936 ("xen: add cache coloring allocator for domains")
>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

With whatever config I've got lying around, this doesn't compile.  It needs

diff --git a/xen/common/memory.c b/xen/common/memory.c
index 3d978227276a..10becf7c1f4c 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -16,6 +16,7 @@
 #include <xen/iocap.h>
 #include <xen/ioreq.h>
 #include <xen/lib.h>
+#include <xen/llc-coloring.h>
 #include <xen/mem_access.h>
 #include <xen/mm.h>
 #include <xen/numa.h>

added.

~Andrew