From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Alejandro Vallejo <alejandro.vallejo@cloud.com>
Cc: xen-devel@lists.xenproject.org,
Bernhard Kaindl <bernhard.kaindl@cloud.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Anthony PERARD <anthony.perard@vates.tech>,
Michal Orzel <michal.orzel@amd.com>,
Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [PATCH 06/11] xen/page_alloc: Hook per-node claims to alloc_heap_pages()
Date: Fri, 6 Jun 2025 10:22:56 +0200 [thread overview]
Message-ID: <aEKlYAp3PkXC5OsE@macbook.local> (raw)
In-Reply-To: <20250314172502.53498-7-alejandro.vallejo@cloud.com>
On Fri, Mar 14, 2025 at 05:24:57PM +0000, Alejandro Vallejo wrote:
> Extend the claim checks in alloc_heap_pages() to exact-node claims. The
> logic is slightly more complicated, so the patch moves it all to an
> auxiliary function.
>
> exact-node claims also follow global claims in order to ensure both can
> coexist in the same system.
>
> Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
> ---
> xen/common/page_alloc.c | 44 ++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 41 insertions(+), 3 deletions(-)
>
> diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
> index 7fe574b29407..cfaa64d3b858 100644
> --- a/xen/common/page_alloc.c
> +++ b/xen/common/page_alloc.c
> @@ -991,6 +991,46 @@ static void init_free_page_fields(struct page_info *pg)
> page_set_owner(pg, NULL);
> }
>
> +/*
> + * Determine whether a heap allocation is allowed after considering all
> + * outstanding claims in the system.
> + *
> + * Exact-node allocations must also take into account global claims!
> + *
> + * e.g:
> + * Consider a domain for which toolstack issued a non-exact claim of 75% of
> + * host memory and another domain for which toolstack tries to issue an
> + * exact-node claim of 50% of host memory. If the exact claim didn't consider
> + * non-exact claims too we would overallocate, which is exactly what claims
s/overallocate/overclaim/ or maybe "attempt to overallocate".
> + * are trying to prevent.
> + */
> +static bool can_alloc(struct domain *d, unsigned int memflags,
d can be const here, this helper is just a checker that doesn't modify
anything.
> + unsigned long request)
> +{
> + nodeid_t node = (memflags & MEMF_exact_node) ? MEMF_get_node(memflags) :
> + NUMA_NO_NODE;
> +
> + if ( outstanding_claims + request <= total_avail_pages )
> + {
> + if ( node == NUMA_NO_NODE )
> + return true;
> +
> + if ( pernode_oc[node] + request <= pernode_avail_pages[node] )
> + return true;
> + }
You can possibly join all conditions in a single clause?
if ( outstanding_claims + request <= total_avail_pages &&
(node == NUMA_NO_NODE ||
pernode_oc[node] + request <= pernode_avail_pages[node]) )
return true;
> +
> + /*
> + * Not enough unclaimed memory. Only allow if it's already claimed on the
> + * right node. d->claim_node == NUMA_NO_NODE if the claim isn't on an
> + * exact node.
> + *
> + * Only refcounted allocs attributed to domains may have been claimed
Nit: missing full stop at the end of the sentence.
Thanks, Roger.
next prev parent reply other threads:[~2025-06-06 8:23 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 17:24 [PATCH 00/11] Add support for exact-node memory claims Alejandro Vallejo
2025-03-14 17:24 ` [PATCH 01/11] xen/memory: Mask XENMEMF_node() to 8 bits Alejandro Vallejo
2025-03-17 16:33 ` Jan Beulich
2025-03-18 16:10 ` Alejandro Vallejo
2025-03-14 17:24 ` [PATCH 02/11] xen/page_alloc: Remove `claim` from domain_set_outstanding_pages() Alejandro Vallejo
2025-06-05 16:42 ` Roger Pau Monné
2025-06-10 12:23 ` Jan Beulich
2025-06-10 12:52 ` Roger Pau Monné
2025-06-10 17:51 ` Alejandro Vallejo
2025-06-10 12:37 ` Jan Beulich
2025-03-14 17:24 ` [PATCH 03/11] xen/page_alloc: Add static per-node counts of free pages Alejandro Vallejo
2025-06-05 16:46 ` Roger Pau Monné
2025-06-11 13:35 ` Jan Beulich
2025-03-14 17:24 ` [PATCH 04/11] xen: Add node argument to domain_{adjust_tot_pages,set_outstanding_pages}() Alejandro Vallejo
2025-06-06 7:57 ` Roger Pau Monné
2025-06-11 13:43 ` Jan Beulich
2025-03-14 17:24 ` [PATCH 05/11] xen: Create per-node outstanding claims Alejandro Vallejo
2025-06-06 8:14 ` Roger Pau Monné
2025-06-06 8:36 ` Roger Pau Monné
2025-03-14 17:24 ` [PATCH 06/11] xen/page_alloc: Hook per-node claims to alloc_heap_pages() Alejandro Vallejo
2025-06-06 8:22 ` Roger Pau Monné [this message]
2025-03-14 17:24 ` [PATCH 07/11] xen/page_alloc: Set node affinity when claiming pages from an exact node Alejandro Vallejo
2025-06-06 8:34 ` Roger Pau Monné
2025-06-11 13:51 ` Jan Beulich
2025-03-14 17:24 ` [PATCH 08/11] xen/memory: Enable parsing NUMA node argument in XENMEM_claim_pages Alejandro Vallejo
2025-06-06 8:51 ` Roger Pau Monné
2025-03-14 17:25 ` [PATCH 09/11] tools/xc: Add `node` argument to xc_domain_claim_pages() Alejandro Vallejo
2025-06-06 9:02 ` Roger Pau Monné
2025-03-14 17:25 ` [PATCH 10/11] tools/xl: Expose a "claim_on_node" setting in xl.cfg Alejandro Vallejo
2025-06-06 9:00 ` Roger Pau Monné
2025-03-14 17:25 ` [PATCH 11/11] docs/man: Document the new claim_on_node option Alejandro Vallejo
2025-06-06 9:03 ` Roger Pau Monné
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aEKlYAp3PkXC5OsE@macbook.local \
--to=roger.pau@citrix.com \
--cc=alejandro.vallejo@cloud.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=bernhard.kaindl@cloud.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.