From nobody Sun Dec 14 06:20:03 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1764670256; cv=none; d=zohomail.com; s=zohoarc; b=XUIt2Oy27RfrjWUM9AT16QqQWlLFGBzfHMVJGnrRFU1V4wmNTD/aaVGUXVm6X9i9r2+KNJCrGZSv2DqGix4gzQuwQvUrsKf0495MUjN/DQiRXKa38TzVNwgynUhnXjGw5PJDxspFsi4xPeluNNsKa/d+jv5GMXjSOriC22dp07g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764670256; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sRghr6u8t7LZWLGIMGwRWafYIQtc04eqnIv5UNUe8E8=; b=b+4e4ti2aeKggj1ckhntzobyDXj91GD4L6YG7B63xCpjqGSVd3CsryeNjcqXdGY/8jxWgeOicQNurUqHsXQqCKeVbwZWqcAiSb8ipcGB9JS/Kp6tw9RmHFx5AeRXnqhinQxql+Vj9VZ8M+DocMrnpmqKGBHOcQmjYq/+ByhF3Io= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1764670256349646.407836119153; Tue, 2 Dec 2025 02:10:56 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1176056.1500605 (Exim 4.92) (envelope-from ) id 1vQNKy-0001mn-MM; Tue, 02 Dec 2025 10:10:24 +0000 Received: by outflank-mailman (output) from mailman id 1176056.1500605; Tue, 02 Dec 2025 10:10:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vQNKy-0001mg-JA; Tue, 02 Dec 2025 10:10:24 +0000 Received: by outflank-mailman (input) for mailman id 1176056; Tue, 02 Dec 2025 10:04:37 +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 1vQNFN-0000il-0U for xen-devel@lists.xenproject.org; Tue, 02 Dec 2025 10:04:37 +0000 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [2a00:1450:4864:20::641]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4bcb8017-cf66-11f0-980a-7dc792cee155; Tue, 02 Dec 2025 11:04:31 +0100 (CET) Received: by mail-ej1-x641.google.com with SMTP id a640c23a62f3a-b79af62d36bso316036766b.3 for ; Tue, 02 Dec 2025 02:04:31 -0800 (PST) Received: from tbernhardk-x-u.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b76f5a4a652sm1501590066b.65.2025.12.02.02.04.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Dec 2025 02:04:29 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 4bcb8017-cf66-11f0-980a-7dc792cee155 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1764669871; x=1765274671; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=sRghr6u8t7LZWLGIMGwRWafYIQtc04eqnIv5UNUe8E8=; b=J06P0CO88RCodqVp0/JcrupaoYSjqN9CTK254RaL7+s5lo0JCLSJItEyo7duEaJXte RdC9R9dMOpFPXU/BgMZpRVWPQzSM1iGunos1vw7E1+zgLsQ0rmGfeV0bPTEWM2iFjHNg zh/dwP6a3Lxiu2SoqEBpoFHjXt05eOA1NVKPM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764669871; x=1765274671; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=sRghr6u8t7LZWLGIMGwRWafYIQtc04eqnIv5UNUe8E8=; b=jnpzug0lDU2zcULXb3YayWUsCEk0ApDLWpY7mnq5pZgjvis+GNhB6xzSvageYoUEXT 2IwAslUGQsYE7T7ipEyal6VWn1D64/sP5UkVkdSIqvARFZSTdYWkdCBYrJ813XiZf63B 8/EwxpWyUO6Da9PpvxUHWRSlMHbEIL/lDQ3cA9xw4CwwP809giLM4698ewsUEtoy2XI/ c04cb19kuLkDp787qcatQybaxHp9JdJNhYQHba3q6LMjTv21DRKsz5Bhet6UDdTB3L8M xLH3DvfluMd6D7Hq5ZdTfzm0jTNz+Gve7l98GA8tnsx6f8BluQg2il19oPLp9TBEtIiL EjXg== X-Gm-Message-State: AOJu0YyCOjjf8Fd0Ph29SYeb4j6cPIzKBxuagblW0FyhMVbQ+79OGoR8 uh7u5/1OWFN7v0GF9GLHF3hTesMaQY0NkZmq3U8kVlQvu7yJbwMNOaia/SYB9q7NwcLBGoGE2Pu Go77bFNy2Wr8JbqE= X-Gm-Gg: ASbGncuoHLNkwwQCqx5V+a5xDZqu2p1OmkQ/sbO/lWhi6+8cOQl79q0bIPtfNBm9Rw1 LdsE9Zq+IEWjaHGl3Ncr20lxxAGoTBDwP788Nemg8NKuuquiaIheRVl3suQgFFz+acoSFxhHXj+ uLlEWeDKSwLckNSHBGRtDmvS31RmGWPFjJFoJ4rQzBYTENQBE/dR1GwdmZOhA6wd9GkjenODyCn 9SDlFfqxL7MewO5hlYIxs5rwOssdRnO4znJY4qta7MYH9CJPXzBMApyJNA9bIpndfFHVaxljlUF Ea+e9CoZkEpPjCiDqOMUmWXZ3CGNE9WffpVNlXjtKXd4ReYril5483w+UdxjEFQEBFt9YNZhmtm T+gSdYmDZ0JyXldSYxeaCpkYUSW7I6LiEOFIai1vrHF7iEQ8bCjgM/qJaMfTXMY08u5mPd/I9/7 Tqbj7G0IUEV7VnKIywA8Ky40rrOTGEB9te+zS8 X-Google-Smtp-Source: AGHT+IGot6vEvPPguBDxq3OYexLjA9/V/O8mWyyrxOAKqk22OTHGJdJCH5E0zXvXsB1ELOPdaHJPyg== X-Received: by 2002:a17:907:c09:b0:b79:cb08:30e with SMTP id a640c23a62f3a-b79cb0803b6mr10985066b.58.1764669870711; Tue, 02 Dec 2025 02:04:30 -0800 (PST) From: Bernhard Kaindl X-Google-Original-From: Bernhard Kaindl To: xen-devel@lists.xenproject.org Cc: Bernhard Kaindl , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH] xen/page_alloc: Much more concise domain_adjust_tot_pages() Date: Tue, 2 Dec 2025 11:02:37 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1764670261911019200 Non-functional change to make consuming claims more concise: When we limit the consumption of claims to the remaining claims of the domain, we can make the code more concise by limiting the adjustment to it instead of carrying a special case for it. Signed-off-by: Bernhard Kaindl Co-authored-by: Roger Pau Monn=C3=A9 --- Changes - Use min_t(unsigned long, a, b) as the tool of the trade (Roger Pau Monn= =C3=A9) - Reviewed by Andrew Cooper and Roger Pau Monn=C3=A9(Excluding comments, co= mmit message) - Regression-tested and included as part of te NUMA work for XenServer 9 - Improved comments and the commit message (non-functional change, comment = cleanup) Previous reviews ---------------- Review with the requested changes to the commit message: - https://patchew.org/Xen/cover.1757261045.git.bernhard.kaindl@cloud.com/15= ae395c6933e74da0cdd8f9d71d349a7bfad3f3.1757261045.git.bernhard.kaindl@cloud= .com/ Obsoleted review: - https://patchew.org/Xen/cover.1755341947.git.bernhard.kaindl@cloud.com/5f= 417fea5ca8e4da0d4b9679103c3eff4bc92900.1755341947.git.bernhard.kaindl@cloud= .com/ --- xen/common/page_alloc.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 1f67b88a89..ae2a560e0a 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -510,8 +510,11 @@ static unsigned long avail_heap_pages( return free_pages; } =20 +/* Adjust the tot_pages and remaining outstanding claims of the domain. */ unsigned long domain_adjust_tot_pages(struct domain *d, long pages) { + unsigned long adjustment; + ASSERT(rspin_is_locked(&d->page_alloc_lock)); d->tot_pages +=3D pages; =20 @@ -519,23 +522,19 @@ unsigned long domain_adjust_tot_pages(struct domain *= d, long pages) * can test d->outstanding_pages race-free because it can only change * if d->page_alloc_lock and heap_lock are both held, see also * domain_set_outstanding_pages below + * + * skip claims adjustment when the domain has no outstanding claims + * or we unassigned pages from it. */ if ( !d->outstanding_pages || pages <=3D 0 ) goto out; =20 spin_lock(&heap_lock); BUG_ON(outstanding_claims < d->outstanding_pages); - if ( d->outstanding_pages < pages ) - { - /* `pages` exceeds the domain's outstanding count. Zero it out. */ - outstanding_claims -=3D d->outstanding_pages; - d->outstanding_pages =3D 0; - } - else - { - outstanding_claims -=3D pages; - d->outstanding_pages -=3D pages; - } + /* consume claims until the domain's outstanding_claims are exhausted = */ + adjustment =3D min_t(unsigned long, d->outstanding_pages, pages); + d->outstanding_pages -=3D adjustment; + outstanding_claims -=3D adjustment; spin_unlock(&heap_lock); =20 out: --=20 2.34.1