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 B526D106F2EA for ; Thu, 26 Mar 2026 08:18:38 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1263442.1555366 (Exim 4.92) (envelope-from ) id 1w5fv2-0003E1-0D; Thu, 26 Mar 2026 08:18:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1263442.1555366; Thu, 26 Mar 2026 08:18:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w5fv1-0003Du-TV; Thu, 26 Mar 2026 08:18:19 +0000 Received: by outflank-mailman (input) for mailman id 1263442; Thu, 26 Mar 2026 08:18:18 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w5fv0-0003Do-47 for xen-devel@lists.xenproject.org; Thu, 26 Mar 2026 08:18:18 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1w5fuz-008a4v-13 for xen-devel@lists.xenproject.org; Thu, 26 Mar 2026 09:18:17 +0100 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69c4ebc2-2eae-0a2a0a5409dd-0a2a4501b244-34 for ; Thu, 26 Mar 2026 09:18:16 +0100 Received: from [209.85.221.51] (helo=mail-wr1-f51.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.55.2) (envelope-from ) id 69c4ebc8-6400-0a2a45010019-d155dd33bd9a-3 for ; Thu, 26 Mar 2026 09:18:16 +0100 Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-439cd6b0aedso369417f8f.1 for ; Thu, 26 Mar 2026 01:18:16 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b919cf069sm5960415f8f.22.2026.03.26.01.18.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Mar 2026 01:18:16 -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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1774513096; x=1775117896; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=j9vZF5Dz0TFARND9TH4AsgYVM6zKyc2F9Uh6URbA8pE=; b=I/l9aVMopvQujdkYUIE51iQYsD7fRS0uocYBtGF3h7t3rHUuwCizfoPoVhfD2MYNcC uRHN2vyrFXRILYexSWnULmkM+cFDCoXeatrpBx6OKqalcJgclssp8QEJDQuxU97oz0M7 nMpY+7DxDne1mpJASJE+5gzLugWnrWBnqAJr9wteUu5g6YGlbKH8OAqCHpwlYv/pfp0G 3EO3CLIleJzInRHNInOP8SzobSJEMY2zaaOFvRC9XhpREUbFexxHs5EC5D4L/DuZ67aY yCn/qX8Lb2iQsJ4sp6x28OmM8YQR9re5P3HwwuavwvVMegemt/dWYVbvlGkEJiBCi7DP 5MFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774513096; x=1775117896; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=j9vZF5Dz0TFARND9TH4AsgYVM6zKyc2F9Uh6URbA8pE=; b=Y12Vt48nhhSijIWZ8r5OC/VduYPytnhh2RtETkrsPMZLvMvon7tMxUYkcGJ0EFIoPU b381sTJQeW7DqdBajT58ln8HQonGY0CeMt5z3cEzwSPp26AgJXaqvUqD24QoYZhwNIkj 5TT/WF3ZwNfONo4XwCHH9vwoeiMZb8YWTYFmOhJNfbN8e0DVIFRI0ZtMaEZxCJP5qRra wcUKY3El8XpynPkX1ivsPr1qsZWXnMj9ZECG8Px+hlWGus8WAPgSaxxwBnHKGX5RgdkA Dmsnri/RSilTsNotCNS6fai+7wuyuavZnkaZ2vQIK7ugSgLgllZj6Mb3GwyK3P0/oflk sRJQ== X-Forwarded-Encrypted: i=1; AJvYcCWpMkFT72Mp0YcLtVIhF8JNYkaXNZ2Yh4VskuaI0RSes4BilUeubVIBq9LSXRmQ4KSn2IHVD1Odo4k=@lists.xenproject.org X-Gm-Message-State: AOJu0Ywm4dJqce1XMqm7EVRQoFiLKEuYiBhVkzqz3bmuvXkMF8IHBP8b 1vco2rVNWs4KYz50iDJR23nbGtj+yG6kA7/sxsCvG3vyq2VpUJQPCXtVswftrbFnbw== X-Gm-Gg: ATEYQzzdZMI/uaqFTy1b6m9NNaQkWa2pYj3qHjc7RuDGGZrq5JyAd35bm+B9S/MWWd4 8PGboyhvDljJ/A1pV5Rxg0c8fU1MkGPnMj4GXsGiZgTPVjCjU9F9WHLeC5WvrfS+NW+jil5f2P9 amBldW0HStFkfXSp4CU22cO7gEmMvfMYKhBWMMHg/eJb5MO8xsdH8qYgBHTf7QKlWjsq2fI/oKF 7rg5yqvp8+lI1GVAG7OTnlCeBjmi0/+Nvlh60hhNl09zSduXvDFhaomFEansDQwkTlnIu10l5KJ 7x6FDNX19Q5tBjNpXB13vJpqH1K507mX3xanIq1k+kNHNYg9nBVeVc96RrV/PcaV1uCyL+TIbfO BS0iK1LnAto870QXMVstcyB6J0wUAZcSFsAy5JsNdslY1RJGi+0L2I7xAiIafCDioNYflYV3Tgi XMEGcXFn0zI7SXozPRzhLbQTvAQ0UUk2fRwveipua59r1r2TIk46M79ST6BpkEQFSKgSIgY4kC8 bvLWwbmXZbxCXw= X-Received: by 2002:a05:6000:60f:b0:43b:5765:96a9 with SMTP id ffacd0b85a97d-43b889af1d0mr9698430f8f.24.1774513096247; Thu, 26 Mar 2026 01:18:16 -0700 (PDT) Message-ID: <9bd94a4b-6724-4978-b00f-c3fd0664814d@suse.com> Date: Thu, 26 Mar 2026 09:18:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] xen/mm: do not assign pages to a domain until they are scrubbed To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Cc: Andrew Cooper , Anthony PERARD , Michal Orzel , Julien Grall , Stefano Stabellini , xen-devel@lists.xenproject.org References: <20260325100803.6640-1-roger.pau@citrix.com> <20260325100803.6640-3-roger.pau@citrix.com> <73c705eb-95f9-456c-ba0b-c6e0f7730ef1@suse.com> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJeb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mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-purgate-ID: tlsNG-d62444/1774513096-8F0E1DF3-41F78754/0/0 X-purgate-type: clean X-purgate-size: 1778 On 25.03.2026 17:54, Roger Pau Monné wrote: > On Wed, Mar 25, 2026 at 05:26:01PM +0100, Roger Pau Monné wrote: >> On Wed, Mar 25, 2026 at 03:56:05PM +0100, Jan Beulich wrote: >>> On 25.03.2026 11:08, Roger Pau Monne wrote: >>>> * Disallow XENMEM_decrease_reservation until the domain has finished >>>> creation would fix the issue of pages being freed while pending scrub, >>>> but it's not clear there might be other usages that would be problematic, >>>> as get_page() on non-scrubbed pages would still return success. >>> >>> I agree this is of concern. >>> >>>> --- a/xen/common/memory.c >>>> +++ b/xen/common/memory.c >>>> @@ -388,6 +388,12 @@ static void populate_physmap(struct memop_args *a) >>>> goto out; >>>> } >>>> } >>>> + >>>> + if ( assign_page(page, a->extent_order, d, memflags) ) >>>> + { >>>> + free_domheap_pages(page, a->extent_order); >>> >>> The pages don't have an owner set yet, so that function will go straight >>> to free_heap_pages(), needlessly passing "true" as last argument. Correct, >>> but (for large pages, which the stashing is about) highly inefficient. >> >> My bad, I was sure I was using the same freeing function as >> alloc_domheap_pages() on failure to assign, but I clearly wasn't. I >> will switch to using free_heap_pages(). > > Coming back to this, I can export free_heap_pages(), but then the call > would also unconditionally have need_scrub == true, as the pages have > been allocated without scrubbing. But the assign_page() call is here to have the scrubbing done ahead of it, so re-scrubbing after freeing shouldn't be necessary? Jan