Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29B07C87FCA for ; Thu, 7 Aug 2025 15:59:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1073267.1436162 (Exim 4.92) (envelope-from ) id 1uk31d-00017t-Ak; Thu, 07 Aug 2025 15:59:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1073267.1436162; Thu, 07 Aug 2025 15:59:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uk31d-00017m-7u; Thu, 07 Aug 2025 15:59:29 +0000 Received: by outflank-mailman (input) for mailman id 1073267; Thu, 07 Aug 2025 15:59:27 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uk31b-00017c-FM for xen-devel@lists.xenproject.org; Thu, 07 Aug 2025 15:59:27 +0000 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [2a00:1450:4864:20::630]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7da6901d-73a7-11f0-b898-0df219b8e170; Thu, 07 Aug 2025 17:59:25 +0200 (CEST) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-ae6f8d3bcd4so227618266b.1 for ; Thu, 07 Aug 2025 08:59:25 -0700 (PDT) Received: from [192.168.1.17] (user-109-243-64-38.play-internet.pl. [109.243.64.38]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-af93d62bc97sm1056064666b.80.2025.08.07.08.59.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Aug 2025 08:59:24 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7da6901d-73a7-11f0-b898-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754582365; x=1755187165; darn=lists.xenproject.org; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=0wgtPBavqi4PFHyWY9Rb9EAc0CZ4jorCn0z6GQ8ZqWE=; b=RKtPQNkv97/JGpObUssHpocSl8hMwDX0AyxITsndHeDk6DD6ruWOjBvl6IlPTkJD1x owQQ6bnZve03zzQXqIyGIKcofnJmRM7ZkjQqterHoCXzRgl4weuhcOb+7WgKv3ABFkjp HYmnMsSC6IO8B+AY276xz6sfUt1lRImCoWwalUPEwNlWMToFY1Z5E2EdwJow+/FT7dVl m2/l7XXEgMq7C7YOwwfYMoWi8++4NB65ATNdX11NZd/mSOhtjFrw+syOUXi5gwpLR+IL GzBbevODLNzcu7rPZW2LMd0LYVwElUAVUgen3S2f8632uPbebKjwH5lCwXw+GQxDvICS 0uig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754582365; x=1755187165; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=0wgtPBavqi4PFHyWY9Rb9EAc0CZ4jorCn0z6GQ8ZqWE=; b=dP0gMuw0IteE18BTzJpXtla6YYiLWeWXIXtUB9eIBV5VE49iyftISqNlXBF0ZVEVdK RstcBWNpn78EviSUdVnf6QXoEUn5+nbud9TvRUBuoHVPrEanlvUD05G45KNFML7tElET 0nHAT/O6u4obQ7Tle8sJP1GCALQwcuLzdWiHRdIAXZpGczOZQCR3Sg+OFEmCfmjWza69 zC+QgMC+Fe7UFK6eU0OBDc7R2nLph+wWTsGYn+9e92u0aMOxlL0c5JdY8CDUbKNJ9vYS 2m6XBCBD+fYLJARlshluJ4QjiT/OTXj5g/U0I3vZeVOjJWEll6dbE2vfgoGuh9tON7uO ntVA== X-Forwarded-Encrypted: i=1; AJvYcCVNGlegRuVbvPWlb3TbmsPCKDjQxY1BNU5dWzUrFG18TA3PYH2TRg9jN+T5iOwZ89+WeSLwULWtpjc=@lists.xenproject.org X-Gm-Message-State: AOJu0YzgrxqlPlOOBRVFpGiUl94OChS/K3qIu+22Z3TbwuvJgJHwr/FV i7pzFGvkkkgMY5EZJqwVYaeKnYVuwOL3ecO4jkR8tkZ7YiFzKCbwvcNM X-Gm-Gg: ASbGncsDKmZjyDMCNz6PJXfAZeOvhqjZEiIvNXMPhdPyDmIapedvJ4KF3HqX3GHH2O8 ESgHYiu4zsfQtvMf/w+I+6RdjAwUTkDbDi2FYjEnaKZB3ojlWk+22kd8PcFCZJzD4ouIJTTitz8 Zz+WQ25EvuYOv6zGZUCEmBeZWJ1lgnRW0NpjqiSJqZTGvKBeUX0WwfBEQNVVcwD/1FyEm55e4kG CKgBsiGm7TeYphRXFn+/iaGScW1YI3fYKCQc4ldIqXCEe2SbGjDdvFPKKO0jJh3Ya4WUePoNdtB EaWYfqrVcj1VUsJmZmCfwfMSZZft+Z8yX0RJ8hQAxSZGMr7asRq1NBnTBMc0tsL5tJfxhqcYvVJ ujn5T+eNx+AkDmGR3KqE6TkEIOeEbsaL1J6EGgLEk7PIhJaE5lssfYN2fzWKe4smb49js43gx X-Google-Smtp-Source: AGHT+IF6JpGu0ylcGSsFXKfkBWZUNHNaQB51sxXElkBY8cIkavWQP5x60LqdH4bvjmey/yjsXPrlhg== X-Received: by 2002:a17:907:96a5:b0:ade:198c:4b6f with SMTP id a640c23a62f3a-af9c1c503ecmr42455566b.1.1754582364461; Thu, 07 Aug 2025 08:59:24 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------5KcyPkjop0awM4nKFAFs0bwU" Message-ID: <9fec023f-3b93-49a4-8ee2-ab2194951b19@gmail.com> Date: Thu, 7 Aug 2025 17:59:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 06/20] xen/riscv: add root page table allocation To: Jan Beulich Cc: Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Julien Grall , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , xen-devel@lists.xenproject.org References: <23c79f07221dee7eb782ebb160442f3a796a41b2.1753973161.git.oleksii.kurochko@gmail.com> <3c02593f-deae-4109-9334-0ac4376a9a9e@suse.com> Content-Language: en-US From: Oleksii Kurochko In-Reply-To: This is a multi-part message in MIME format. --------------5KcyPkjop0awM4nKFAFs0bwU Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 8/7/25 5:30 PM, Jan Beulich wrote: > On 07.08.2025 14:00, Oleksii Kurochko wrote: >> On 8/5/25 12:37 PM, Jan Beulich wrote: >>> On 31.07.2025 17:58, Oleksii Kurochko wrote: >>>> + /* >>>> + * Return back nr_root_pages to assure the root table memory is also >>>> + * accounted against the P2M pool of the domain. >>>> + */ >>>> + if ( !paging_ret_pages_to_domheap(d, nr_root_pages) ) >>>> + return -ENOMEM; >>>> + >>>> + page = p2m_allocate_root(d); >>>> + if ( !page ) >>>> + return -ENOMEM; >>> Hmm, and the pool is then left shrunk by 4 pages? >> Yes until they are used for root table it shouldn't be in p2m pool (freelist), >> when root table will be freed then it makes sense to return them back. >> Am I missing something? > I'm commenting specifically on the error path here. Ohh, got it. In this case, should we really care about this 4 pages as a domain can't be ran without allocated page root table and a panic() will be occured anyway according to the create_domUs() common code (construct_domU() -> domain_p2m_set_allocation() -> p2m_set_allocation() -> p2m_alloc_root_table()): ... rc = construct_domU(&ki, node); if ( rc ) panic("Could not set up domain %s (rc = %d)\n", dt_node_name(node), rc); ... (Note: I missed to return a value returned by p2m_alloc_root_table() in p2m_set_allocation() so it isn't really propagated, at the moment, but I will fix that in the next patch version) ... >> Probably, you meant that it is needed to update p2m->pages? > That (I think) I commented on elsewhere, yes. ... if it is needed really to update p2m->pages when a page is allocated, I think it will be better to in p2m_allocate_root() immediately after alloc_domheap_pages() is called in p2m_allocate_root(). ~ Oleksii --------------5KcyPkjop0awM4nKFAFs0bwU Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit


On 8/7/25 5:30 PM, Jan Beulich wrote:
On 07.08.2025 14:00, Oleksii Kurochko wrote:
On 8/5/25 12:37 PM, Jan Beulich wrote:
On 31.07.2025 17:58, Oleksii Kurochko wrote:
+    /*
+     * Return back nr_root_pages to assure the root table memory is also
+     * accounted against the P2M pool of the domain.
+     */
+    if ( !paging_ret_pages_to_domheap(d, nr_root_pages) )
+        return -ENOMEM;
+
+    page = p2m_allocate_root(d);
+    if ( !page )
+        return -ENOMEM;
Hmm, and the pool is then left shrunk by 4 pages?
Yes until they are used for root table it shouldn't be in p2m pool (freelist),
when root table will be freed then it makes sense to return them back.
Am I missing something?
I'm commenting specifically on the error path here.
Ohh, got it.

In this case, should we really care about this 4 pages as a domain can't be ran
without allocated page root table and a panic() will be occured anyway according
to the create_domUs() common code (construct_domU() -> domain_p2m_set_allocation()
-> p2m_set_allocation() -> p2m_alloc_root_table()):
...
        rc = construct_domU(&ki, node);
        if ( rc )
            panic("Could not set up domain %s (rc = %d)\n",
                  dt_node_name(node), rc);
...
(Note: I missed to return a value returned by p2m_alloc_root_table() in p2m_set_allocation()
so it isn't really propagated, at the moment, but I will fix that in the next patch
version) ...


      
Probably, you meant that it is needed to update p2m->pages?
That (I think) I commented on elsewhere, yes.
...
if it is needed really to update p2m->pages when a page is allocated, I think
it will be better to in p2m_allocate_root() immediately after alloc_domheap_pages()
is called in p2m_allocate_root().

~ Oleksii

--------------5KcyPkjop0awM4nKFAFs0bwU--