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 0457AF9EDC0 for ; Wed, 22 Apr 2026 12:33:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1290464.1570045 (Exim 4.92) (envelope-from ) id 1wFWlT-0005tO-Es; Wed, 22 Apr 2026 12:33:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1290464.1570045; Wed, 22 Apr 2026 12:33:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wFWlT-0005tH-CN; Wed, 22 Apr 2026 12:33:11 +0000 Received: by outflank-mailman (input) for mailman id 1290464; Wed, 22 Apr 2026 12:33:09 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wFWlR-0005t8-Ir for xen-devel@lists.xenproject.org; Wed, 22 Apr 2026 12:33:09 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wFWlQ-00B3a9-LA for xen-devel@lists.xenproject.org; Wed, 22 Apr 2026 14:33:08 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69e8bff8-bab6-0a2a0a5309dd-0a2a45039e06-32 for ; Wed, 22 Apr 2026 14:33:08 +0200 Received: from [209.85.128.44] (helo=mail-wm1-f44.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69e8c004-672d-0a2a45030019-d155802cace9-3 for ; Wed, 22 Apr 2026 14:33:08 +0200 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-488a14c31eeso42416665e9.0 for ; Wed, 22 Apr 2026 05:33:08 -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 5b1f17b1804b1-488fc14a61asm413757565e9.15.2026.04.22.05.33.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Apr 2026 05:33:07 -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=1776861188; x=1777465988; 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=UMY5gm1Nj4tlgzffEyXZ3vdWRk8gGg5mqTSMtNw0cCQ=; b=b79K/nDa5DG5bcOAJ8PFLw2+WdqVg6z+82SltxP0UvfHrpZN+xvmunf9xYJ+pw6QTh fj0iXLVApiUZp+zHL+IBi3QIKxF4yePQ8ZQbIh/VBzng42qD0PEQUlKKwhTEshHb0a/Z CeyptANj23a28hs1ACUnz67GUr4Enl67FlJ1xy8UPCBQpnB9wPCT94fF8qa0zH7R5h1Y rETm7V6Q6cguo6C1i9pxcMA6k/5t/rtC9B7WGi0KYA1izgMy00OrHIe/8OXYvhbO5MM+ gDMYPmRKGAQStXKl/D+vyCzGWBhe6AJSYQEGZWBtoKJGuZGnhuFYerZLtICm/tCcyvNw XokQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776861188; x=1777465988; 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=UMY5gm1Nj4tlgzffEyXZ3vdWRk8gGg5mqTSMtNw0cCQ=; b=k2oLbYl1yFODsAhmyoRCeAqjDkU5UJ+kB4FRTT/yjfmoj3McCc8ONUSf5LqtqcaIhV +oo9CnocGhP1qVmG+euFg4iplioUfyb15UxJ2UnaOIZd5J1SxIT/MBKpRcGB3EB/Sy0Q zBtCXbw4ADf7Mk0/hwyX7K3p29C8vkiJReM6mKSYOI0WYwpj5IyXewdG3lKNdpxW+9SI g7y6hE+snANvppjTIfX4V2JA+VTz2pFeMs5DKHJHDyvFwInDwz16La9bKX6eA3XX26uh Sx/HJ8rSObvecRXEZiR8EmEVASOlOidc6bu5G6jLT97L/Qfnsh+GFpRzQQEQ7ciakdGR tFVA== X-Forwarded-Encrypted: i=1; AFNElJ+E+IlNFvj73OZ7oZtu1Lkcg3FsJhSCjhFrkzI9acd8xAv+NwnVOYGCZ9wzjbr0Af7jGnbMOyERWYw=@lists.xenproject.org X-Gm-Message-State: AOJu0Yy4ot6Jx9jVuHk/LFsdclUdJ/EOxxS+U4YsBevSwZni16NIr+m0 SSs2aiQaKl6lewgLZq65mtJ2pnJLeGMEKHo8FGWmAoZocIELIFgxUsxki5/ZxWfh5A== X-Gm-Gg: AeBDieu+hdkTlmGXWYdl9TR+u3Jp1IO2axqRbsbHL/WlWGvfRusSA6IpIqSRyCzCNIB XyoN0+i5GXPwqjSWz3QL7mA2zJv1nLVgRf0Kzn9nDbBA4xJYNpr3veHhCnAITW/paky+sfrXatM F6eEi4v7cIwa5aeHyjuz3a1dWzl0BlHuDQH7Tlc2rOkWstXexgqd6egDGq2xye1xjF7mKkBlomr l5HqkNq5aXSKDakUS22hUoFvT8ipLUcZyykIrMlfEeprs8NPWu/tqQvvINDe9z0bWDa1PyKrVBy ipEQW82Dp4nFxFcYq3eVOUky1lA9reoqRLXQe/UjBu8nHZQOTZAQvjJ3wXYhokDNljXjhWwQJNj TLTRbtrCyAgIqZ0RmBBdp9k7u08cXqawRm/xaj+g2bpOjh+VLG2lMejr8apJ9KUPEnsjh1VtfEr Smg8esgot8jUGs/Aw9AgRiwQbFQOZl3IHrh6CVeY7kIqi+bpBPsxnf6gaXPvRTK9SrEekbfygi+ V+3Mbh+lsFIPkreGVjoQETAUg== X-Received: by 2002:a05:600c:c177:b0:486:fb0b:ad79 with SMTP id 5b1f17b1804b1-488fb78129emr290350715e9.20.1776861187802; Wed, 22 Apr 2026 05:33:07 -0700 (PDT) Message-ID: <081743b1-e57b-4e06-9cc9-20f1ee01afe9@suse.com> Date: Wed, 22 Apr 2026 14:33:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 2/7] xen/mm: Allow free pages to cover a claims shortfall To: Bernhard Kaindl Cc: Andrew Cooper , Anthony PERARD , Michal Orzel , Julien Grall , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , xen-devel@lists.xenproject.org References: <5d1e06a0fcaee4520bf79d58199e447194f84fe8.1776172526.git.bernhard.kaindl@citrix.com> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32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OxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <5d1e06a0fcaee4520bf79d58199e447194f84fe8.1776172526.git.bernhard.kaindl@citrix.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-purgate-ID: tlsNG-33051d/1776861188-2AD63938-3B0C9AC6/0/0 X-purgate-type: clean X-purgate-size: 2360 On 14.04.2026 15:22, Bernhard Kaindl wrote: > Allow an allocation to proceed when free, unclaimed memory can cover a > claims shortfall. > > In preparation for NUMA-aware claims, refactor this check into a > reusable helper so the same logic can be applied to NUMA nodes. > > Suggested-by: Jan Beulich > Signed-off-by: Bernhard Kaindl > > --- > > Changes since v4: Extracted into a dedicated patch and merged the > formerly separate functions into one, as suggested by Jan Beulich. I did ask for the splitting out, no question. I can't find anything towards the functional change though in my v4 replies, and with that being the main aspect here I think Suggested-by: would credit me for something I didn't do or say. > --- a/xen/common/page_alloc.c > +++ b/xen/common/page_alloc.c > @@ -868,6 +868,42 @@ static void check_and_stop_scrub(struct page_info *head) > } > } > > +/* > + * Allow the request when unclaimed pages suffice, or when a refcounted > + * domain's outstanding claims cover the shortfall. Nit: It's not the domain which is refcounted here (the refcounting there is something entirely different), but the allocation. > + */ > +static bool claims_permit_request(const struct domain *d, > + unsigned long avail_pages, > + unsigned long competing_claims, > + unsigned int memflags, > + unsigned long requested_pages) I think it is good practice to have the main input parameter(s) first. That would be "requested_pages" here plus perhaps "memflags". The rest is auxiliary data to perform the needed calculation. May I further suggest to drop _pages everywhere? I'm further not happy about "competing" in the parameter name: This includes claims for this very domain as well, and if there's no other claim then there's nothing "competing" at all. > +{ > + unsigned long unclaimed_pages; > + > + ASSERT(spin_is_locked(&heap_lock)); > + ASSERT(avail_pages >= competing_claims); > + > + /* Start from the free pages not already claimed by other domains. */ > + unclaimed_pages = avail_pages - competing_claims; This could easily be the initializer of the variable. Jan