[PATCH RFC 2/2] xen/mm: Return claim information from avail_node_heap_pages()
Andrew Cooper <[email protected]> Mon, 3 Aug 2026 13:17:39 +0100
| Newsgroups | gmane.comp.emulators.xen.devel |
|---|---|
| Message-ID | <[email protected]> |
Fully RFC.
With per-node claims, avail_node_heap_pages() becomes:
claim_info_t avail_node_heap_pages(unsigned int nodeid)
{
claim_info_t info = {};
if ( nodeid < MAX_NUMNODES && node_online(nodeid) )
{
spin_lock(&heap_lock);
info.avail = node_avail_pages[nodeid];
info.claimed = node_outstanding_claims[nodeid];
spin_unlock(&heap_lock);
}
return info;
}
along with modifications to the callers. I'm not intending to submit this
patch as-is, but it is present to help judge the naming.
Not-Really-Signed-off-by: Andrew Cooper <[email protected]>
---
CC: Anthony PERARD <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Bernhard Kaindl <[email protected]>
---
xen/common/numa.c | 2 +-
xen/common/page_alloc.c | 8 +++++---
xen/common/sysctl.c | 2 +-
xen/include/xen/mm.h | 2 +-
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/xen/common/numa.c b/xen/common/numa.c
index 92f8f1cedce1..eef8be06944e 100644
--- a/xen/common/numa.c
+++ b/xen/common/numa.c
@@ -713,7 +713,7 @@ static void cf_check dump_numa(unsigned char key)
printk("NODE%u start->%lu size->%lu free->%lu\n",
i, node_start_pfn(i), node_spanned_pages(i),
- avail_node_heap_pages(i));
+ avail_node_heap_pages(i).avail);
/* Sanity check mfn_to_nid() */
if ( node_spanned_pages(i) > 1 && mfn_to_nid(mfn) != i )
printk("mfn_to_nid(%"PRI_mfn") -> %d should be %u\n",
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index 900fcf5755c1..0b0f2033e738 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -2852,12 +2852,14 @@ unsigned long avail_domheap_pages_region(
return avail_heap_pages(zone_lo, zone_hi, node);
}
-unsigned long avail_node_heap_pages(unsigned int nodeid)
+claim_info_t avail_node_heap_pages(unsigned int nodeid)
{
+ claim_info_t info = {};
+
if ( nodeid < MAX_NUMNODES && node_online(nodeid) )
- return node_avail_pages[nodeid];
+ info.avail = node_avail_pages[nodeid];
- return 0;
+ return info;
}
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 35c132564ef1..4d8dba51eb63 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -315,7 +315,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
if ( node_online(i) )
{
meminfo.memsize = node_spanned_pages(i) << PAGE_SHIFT;
- meminfo.memfree = avail_node_heap_pages(i) << PAGE_SHIFT;
+ meminfo.memfree = avail_node_heap_pages(i).avail << PAGE_SHIFT;
}
else
meminfo.memsize = meminfo.memfree = XEN_INVALID_MEM_SZ;
diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
index 74d28d2a1b7a..e8b81c0f1fc6 100644
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -137,6 +137,7 @@ typedef struct {
unsigned long avail, claimed;
} claim_info_t;
claim_info_t get_outstanding_claims(void);
+claim_info_t avail_node_heap_pages(unsigned int nodeid);
/* Domain suballocator. These functions are *not* interrupt-safe.*/
void init_domheap_pages(paddr_t ps, paddr_t pe);
@@ -145,7 +146,6 @@ struct page_info *alloc_domheap_pages(
void free_domheap_pages(struct page_info *pg, unsigned int order);
unsigned long avail_domheap_pages_region(
unsigned int node, unsigned int min_width, unsigned int max_width);
-unsigned long avail_node_heap_pages(unsigned int nodeid);
#define alloc_domheap_page(d,f) (alloc_domheap_pages(d,0,f))
#define free_domheap_page(p) (free_domheap_pages(p,0))
--
2.39.5