From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: "Orzel, Michal" <michal.orzel@amd.com>, xen-devel@lists.xenproject.org
Cc: "Romain Caritey" <Romain.Caritey@microchip.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Julien Grall" <julien@xen.org>,
"Bertrand Marquis" <bertrand.marquis@arm.com>,
"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Jan Beulich" <jbeulich@suse.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Connor Davis" <connojdavis@gmail.com>
Subject: Re: [PATCH v3 02/23] xen: arm: update p2m_set_allocation() prototype
Date: Wed, 24 Jun 2026 11:40:41 +0200 [thread overview]
Message-ID: <23ab5c24-fa7d-44ac-a7ce-199bd33ebb34@gmail.com> (raw)
In-Reply-To: <073c5ff2-5244-4e11-a9e3-e5ecd3ce31d2@amd.com>
On 6/24/26 9:32 AM, Orzel, Michal wrote:
>
>
> On 17-Jun-26 13:17, Oleksii Kurochko wrote:
>> p2m_set_allocation() signals preemption redundantly: via a bool *preempted
>> out-argument (set to true) and via -ERESTART return code, both at the same
>> time. This led to the caller-side ASSERT(preempted == (rc == -ERESTART))
>> added solely to document their agreement.
>>
>> Drop the out-argument entirely. The return code alone is sufficient to
>> distinguish preemption (-ERESTART) from success (0) or other failures.
>> Replace the pointer with a plain bool can_preempt that controls whether
>> the preemption check is performed at all, making the previous
>> NULL-to-suppress-preemption calling convention explicit and type-safe.
> As Andrew said, this paragraph contradicts the first one i.e. we still need to
> pass whether to perform the check or not, so it's not redundant.
I suggested a rewording of the commit message in reply to Andrew's
comment. Could you please review my response?
>
>>
>> Since p2m_set_allocation() is called by the common dom0less build code,
>> move its declaration from the ARM-specific asm/p2m.h to xen/p2m-common.h.
>>
>> Reported-by: Jan Beulich <jbeulich@suse.com>
>> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
>> ---
>> Changes in v3:
>> - Nothing changed. Only rebase.
>> ---
>> Changes in v2:
>> - new patch
>> ---
>> ---
>> xen/arch/arm/include/asm/p2m.h | 1 -
>> xen/arch/arm/mmu/p2m.c | 22 ++++++++--------------
>> xen/arch/riscv/include/asm/paging.h | 2 +-
>> xen/arch/riscv/p2m.c | 7 ++++---
>> xen/arch/riscv/paging.c | 7 ++-----
>> xen/common/device-tree/dom0less-build.c | 2 +-
>> xen/include/xen/p2m-common.h | 2 ++
>> 7 files changed, 18 insertions(+), 25 deletions(-)
>>
>> diff --git a/xen/arch/arm/include/asm/p2m.h b/xen/arch/arm/include/asm/p2m.h
>> index 4a4913716bdd..737da60dcf58 100644
>> --- a/xen/arch/arm/include/asm/p2m.h
>> +++ b/xen/arch/arm/include/asm/p2m.h
>> @@ -238,7 +238,6 @@ void p2m_restore_state(struct vcpu *n);
>> /* Print debugging/statistial info about a domain's p2m */
>> void p2m_dump_info(struct domain *d);
>>
>> -int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preempted);
>> int p2m_teardown_allocation(struct domain *d);
>>
>> static inline void p2m_write_lock(struct p2m_domain *p2m)
>> diff --git a/xen/arch/arm/mmu/p2m.c b/xen/arch/arm/mmu/p2m.c
>> index 51abf3504fcf..e5c6be7c0890 100644
>> --- a/xen/arch/arm/mmu/p2m.c
>> +++ b/xen/arch/arm/mmu/p2m.c
>> @@ -67,10 +67,11 @@ int arch_get_paging_mempool_size(struct domain *d, uint64_t *size)
>>
>> /*
>> * Set the pool of pages to the required number of pages.
>> - * Returns 0 for success, non-zero for failure.
>> + * Returns 0 for success, -ERESTART if preempted, or a negative error code on
> It returns -ERESTART if preempted *AND* preemption is allowed - please clarify
> in the description.
>
Agree, it should be updated. I'll apply your suggestion in the next
patch version.
>> + * failure.
>> * Call with d->arch.paging.lock held.
>> */
>> -int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preempted)
>> +int p2m_set_allocation(struct domain *d, unsigned long pages, bool can_preempt)
>> {
>> struct page_info *pg;
>>
>> @@ -112,11 +113,8 @@ int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preempted)
>> break;
>>
>> /* Check to see if we need to yield and try again */
>> - if ( preempted && general_preempt_check() )
>> - {
>> - *preempted = true;
>> + if ( can_preempt && general_preempt_check() )
>> return -ERESTART;
>> - }
>> }
>>
>> return 0;
>> @@ -125,7 +123,6 @@ int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preempted)
>> int arch_set_paging_mempool_size(struct domain *d, uint64_t size)
>> {
>> unsigned long pages = size >> PAGE_SHIFT;
>> - bool preempted = false;
>> int rc;
>>
>> if ( (size & ~PAGE_MASK) || /* Non page-sized request? */
>> @@ -133,27 +130,24 @@ int arch_set_paging_mempool_size(struct domain *d, uint64_t size)
>> return -EINVAL;
>>
>> spin_lock(&d->arch.paging.lock);
>> - rc = p2m_set_allocation(d, pages, &preempted);
>> + rc = p2m_set_allocation(d, pages, true);
>> spin_unlock(&d->arch.paging.lock);
>>
>> - ASSERT(preempted == (rc == -ERESTART));
>> -
>> return rc;
>> }
>>
>> int p2m_teardown_allocation(struct domain *d)
>> {
>> int ret = 0;
>> - bool preempted = false;
>>
>> spin_lock(&d->arch.paging.lock);
>> if ( d->arch.paging.p2m_total_pages != 0 )
>> {
>> - ret = p2m_set_allocation(d, 0, &preempted);
>> - if ( preempted )
>> + ret = p2m_set_allocation(d, 0, true);
>> + if ( ret == -ERESTART )
>> {
>> spin_unlock(&d->arch.paging.lock);
>> - return -ERESTART;
>> + return ret;
>> }
>> ASSERT(d->arch.paging.p2m_total_pages == 0);
>> }
>> diff --git a/xen/arch/riscv/include/asm/paging.h b/xen/arch/riscv/include/asm/paging.h
>> index e487c89a4ccd..103384723dc5 100644
>> --- a/xen/arch/riscv/include/asm/paging.h
>> +++ b/xen/arch/riscv/include/asm/paging.h
>> @@ -9,7 +9,7 @@ struct page_info;
>> int paging_domain_init(struct domain *d);
>>
>> int paging_freelist_adjust(struct domain *d, unsigned long pages,
>> - bool *preempted);
>> + bool can_preempt);
>>
>> int paging_ret_to_domheap(struct domain *d, unsigned int nr_pages);
>> int paging_refill_from_domheap(struct domain *d, unsigned int nr_pages);
>> diff --git a/xen/arch/riscv/p2m.c b/xen/arch/riscv/p2m.c
>> index 703b9f4d2540..41d6d3d5e699 100644
>> --- a/xen/arch/riscv/p2m.c
>> +++ b/xen/arch/riscv/p2m.c
>> @@ -430,15 +430,16 @@ int p2m_init(struct domain *d, const struct xen_domctl_createdomain *config)
>>
>> /*
>> * Set the pool of pages to the required number of pages.
>> - * Returns 0 for success, non-zero for failure.
>> + * Returns 0 for success, -ERESTART if preempted, or a negative error code on
>> + * failure.
>> * Call with d->arch.paging.lock held.
>> */
> Move the description where a prototype lives. This way you will avoid adding one
> at each definition (remove from here and Arm then).
Makes sense. Also, it will address the issue that, based on your comment
above, the comment should be updated here and before the prototype.
>
>> -int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preempted)
>> +int p2m_set_allocation(struct domain *d, unsigned long pages, bool can_preempt)
>> {
>> struct p2m_domain *p2m = p2m_get_hostp2m(d);
>> int rc;
>>
>> - if ( (rc = paging_freelist_adjust(d, pages, preempted)) )
>> + if ( (rc = paging_freelist_adjust(d, pages, can_preempt)) )
>> return rc;
>>
>> /*
>> diff --git a/xen/arch/riscv/paging.c b/xen/arch/riscv/paging.c
>> index 76a203edbb0c..35f572689a7c 100644
>> --- a/xen/arch/riscv/paging.c
>> +++ b/xen/arch/riscv/paging.c
>> @@ -47,7 +47,7 @@ static int _paging_add_to_freelist(struct domain *d)
>> }
>>
>> int paging_freelist_adjust(struct domain *d, unsigned long pages,
>> - bool *preempted)
>> + bool can_preempt)
>> {
>> ASSERT(spin_is_locked(&d->arch.paging.lock));
>>
>> @@ -66,11 +66,8 @@ int paging_freelist_adjust(struct domain *d, unsigned long pages,
>> return rc;
>>
>> /* Check to see if we need to yield and try again */
>> - if ( preempted && general_preempt_check() )
>> - {
>> - *preempted = true;
>> + if ( can_preempt && general_preempt_check() )
>> return -ERESTART;
>> - }
>> }
>>
>> return 0;
>> diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tree/dom0less-build.c
>> index eacfd93087ae..c3818ffed45f 100644
>> --- a/xen/common/device-tree/dom0less-build.c
>> +++ b/xen/common/device-tree/dom0less-build.c
>> @@ -747,7 +747,7 @@ static int __init domain_p2m_set_allocation(struct domain *d, uint64_t mem,
>> domain_p2m_pages(mem, d->max_vcpus);
>>
>> spin_lock(&d->arch.paging.lock);
>> - rc = p2m_set_allocation(d, p2m_pages, NULL);
>> + rc = p2m_set_allocation(d, p2m_pages, false);
>> spin_unlock(&d->arch.paging.lock);
>>
>> return rc;
>> diff --git a/xen/include/xen/p2m-common.h b/xen/include/xen/p2m-common.h
>> index f0bd9a6b9896..1b44ec8ce36c 100644
>> --- a/xen/include/xen/p2m-common.h
>> +++ b/xen/include/xen/p2m-common.h
>> @@ -43,5 +43,7 @@ int __must_check check_get_page_from_gfn(struct domain *d, gfn_t gfn,
>> bool readonly, p2m_type_t *p2mt_p,
>> struct page_info **page_p);
>>
>> +int p2m_set_allocation(struct domain *d, unsigned long pages,
> I think it's worth adding __must_check given that rc is now the only preemption
> status checker.
I will add __must_check.
Thanks.
~ Oleksii
next prev parent reply other threads:[~2026-06-24 9:41 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 11:17 [PATCH v3 00/23] Introduce enablemenant of dom0less Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 01/23] xen: arm: move declaration of map_device_irqs_to_domain() to common header Oleksii Kurochko
2026-06-24 7:02 ` Orzel, Michal
2026-06-24 9:00 ` Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 02/23] xen: arm: update p2m_set_allocation() prototype Oleksii Kurochko
2026-06-23 11:29 ` Andrew Cooper
2026-06-24 9:31 ` Oleksii Kurochko
2026-06-24 7:32 ` Orzel, Michal
2026-06-24 9:40 ` Oleksii Kurochko [this message]
2026-06-17 11:17 ` [PATCH v3 03/23] xen/riscv: Implement ARCH_PAGING_MEMPOOL Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 04/23] xen/riscv: Implement construct_domain() Oleksii Kurochko
2026-06-17 11:26 ` Jan Beulich
2026-06-17 11:48 ` Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 05/23] xen/riscv: implement prerequisites for domain_create() Oleksii Kurochko
2026-06-22 13:34 ` Jan Beulich
2026-06-17 11:17 ` [PATCH v3 06/23] xen/riscv: introduce guest riscv,isa string Oleksii Kurochko
2026-06-22 14:09 ` Jan Beulich
2026-06-24 10:43 ` Oleksii Kurochko
2026-06-24 12:40 ` Jan Beulich
2026-06-17 11:17 ` [PATCH v3 07/23] xen/riscv: implement make_cpus_node() Oleksii Kurochko
2026-06-22 14:23 ` Jan Beulich
2026-06-24 10:45 ` Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 08/23] xen/riscv: implement make_timer_node() Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 09/23] xen/riscv: implement make_arch_nodes() Oleksii Kurochko
2026-06-17 11:30 ` Jan Beulich
2026-06-17 11:49 ` Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 10/23] xen/riscv: introduce init interrupt controller operations Oleksii Kurochko
2026-06-22 14:30 ` Jan Beulich
2026-06-24 11:34 ` Oleksii Kurochko
2026-06-24 12:47 ` Jan Beulich
2026-06-17 11:17 ` [PATCH v3 11/23] xen/riscv: implement make_intc_domU_node() Oleksii Kurochko
2026-06-22 14:34 ` Jan Beulich
2026-06-24 11:36 ` Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 12/23] xen/riscv: introduce aia_init() and aia_usable() Oleksii Kurochko
2026-06-22 14:36 ` Jan Beulich
2026-06-17 11:17 ` [PATCH v3 13/23] xen/riscv: introduce per-vCPU IMSIC state Oleksii Kurochko
2026-06-22 14:46 ` Jan Beulich
2026-06-24 11:55 ` Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 14/23] xen/riscv: add very early virtual APLIC (vAPLIC) initialization support Oleksii Kurochko
2026-06-22 14:55 ` Jan Beulich
2026-06-24 12:33 ` Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 15/23] xen/riscv: introduce (de)initialization helpers for vINTC Oleksii Kurochko
2026-06-22 15:01 ` Jan Beulich
2026-06-24 13:19 ` Oleksii Kurochko
2026-06-24 13:27 ` Jan Beulich
2026-06-17 11:17 ` [PATCH v3 16/23] xen/riscv: generate IMSIC DT node for guest domains Oleksii Kurochko
2026-06-17 11:24 ` Oleksii Kurochko
2026-06-22 15:12 ` Jan Beulich
2026-06-24 13:25 ` Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 17/23] xen/riscv: create APLIC " Oleksii Kurochko
2026-06-17 11:24 ` Oleksii Kurochko
2026-06-22 15:23 ` Jan Beulich
2026-06-24 13:44 ` Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 18/23] xen/riscv: implement IRQ routing for device passthrough Oleksii Kurochko
2026-06-22 15:57 ` Jan Beulich
2026-06-24 15:21 ` Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 19/23] xen/riscv: implement init_intc_phandle() Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 20/23] xen/riscv: initialize RCU, scheduler, and system domains in start_xen() Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 21/23] xen/riscv: provide init_vuart() Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 22/23] xen/Kconfig: introduce HAS_STATIC_MEMORY Oleksii Kurochko
2026-06-23 8:26 ` Jan Beulich
2026-06-24 15:26 ` Oleksii Kurochko
2026-06-17 11:17 ` [PATCH v3 23/23] xen/riscv: add initial dom0less infrastructure support Oleksii Kurochko
2026-06-23 8:36 ` Jan Beulich
2026-06-24 16:04 ` Oleksii Kurochko
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=23ab5c24-fa7d-44ac-a7ce-199bd33ebb34@gmail.com \
--to=oleksii.kurochko@gmail.com \
--cc=Romain.Caritey@microchip.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=alistair.francis@wdc.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=bertrand.marquis@arm.com \
--cc=connojdavis@gmail.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger.pau@citrix.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.