From nobody Wed Sep 10 11:33:11 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=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1757261758; cv=none; d=zohomail.com; s=zohoarc; b=SU28yzGPErxATVVVtIGCaf6t8iOxFZLE/HDX4lHnqmBNd0/lyNXJAtfqKOGk1TPw0QSNYQK5FZSCDyFbHEObqGOxMTwR1CDMp1yy4PI74wTO2LvwDJ/ysSIhla+oTmLdwIs3AfNmp1HVo5BL5DPnd0FIV7+yATn94Aq4TAjJwJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757261758; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UXFQDBB6LNVrlSbSbsw2cgbvIju27z1SvRMin6hDLRc=; b=QQhEN4iFEeVBhXLFWlqHw/Vs6hdsuTZ48vn4zIHwrfUi+wBN4oYYBW4ZOhVcG7fIHUFOGHm3hcwtdLmLB8TE2dMLtR+J0QSWMCR7zaWJ5tHOWwkbjLJOz4MiCrIs4yzoolEYYXzpsOouIpD1t118h9giicg+eLh5Is7jS4VF89U= 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 1757261758286652.2725601662423; Sun, 7 Sep 2025 09:15:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1114123.1461283 (Exim 4.92) (envelope-from ) id 1uvI38-0008Pp-T4; Sun, 07 Sep 2025 16:15:30 +0000 Received: by outflank-mailman (output) from mailman id 1114123.1461283; Sun, 07 Sep 2025 16:15:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uvI38-0008Pi-Q3; Sun, 07 Sep 2025 16:15:30 +0000 Received: by outflank-mailman (input) for mailman id 1114123; Sun, 07 Sep 2025 16:15:29 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uvI37-0008Bo-Cg for xen-devel@lists.xenproject.org; Sun, 07 Sep 2025 16:15:29 +0000 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [2a00:1450:4864:20::62d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id dec10a8d-8c05-11f0-9d13-b5c5bf9af7f9; Sun, 07 Sep 2025 18:15:29 +0200 (CEST) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-afcb7a16441so539136666b.2 for ; Sun, 07 Sep 2025 09:15:29 -0700 (PDT) Received: from MinisforumBD795m.phoenix-carat.ts.net ([2a02:1748:f7df:8cb1:5474:d7c3:6edd:e683]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b047b61cf00sm908263766b.15.2025.09.07.09.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Sep 2025 09:15:27 -0700 (PDT) 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: dec10a8d-8c05-11f0-9d13-b5c5bf9af7f9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1757261728; x=1757866528; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UXFQDBB6LNVrlSbSbsw2cgbvIju27z1SvRMin6hDLRc=; b=V5OR4Hpa9L48OaH7msaicdAZ0GfBmbBpf7uQNSv4XR0OTyhF8MFSWrHcqC8f0rItdm AkllrfoAXiuidGEiHffOmxVMOFy1hZLNGT5QHUgCdjGscIlNhcDq8O+ca8B8OWy/3Aki lmkm1c9VvEqUHXjX63L+6O+Hfo+sBXFZmpuXk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757261728; x=1757866528; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UXFQDBB6LNVrlSbSbsw2cgbvIju27z1SvRMin6hDLRc=; b=jVuJd35+PRqJLKc0pdhjmFG8teZH0MGcYzYH3okqi4MfbX2Kja5yVywGqxgTKDY97x mfQ9H7Gbv6b40od/qq4XlXpxuJHnY+0opH3yzwBQ+N8rX8oBN7yvWAI8Wxk3ru5VlGHE 4pSvjFpIcZu0m8Ks3Ott3mudSM30x0zcN22J+qsFfCo3vkCSI6RCx8/G5DRWz5wcdOV6 UanCRC2YrI8ZgFLm3enrsTmRiIVrSaILo0QCjrnMBm/x7dzQIYRvG5+9EEiJeZolCEdi Jxv2rH1SQt/Np4+KJCG/BkDwYVuCrcxQOK1D/8OMVFuNmAbJB1SbpKBPVFs+kwjKuIwb iE/Q== X-Gm-Message-State: AOJu0YzE7NgBxFqrgjBQMaOPaMI3UK4W1YJ+FbLLbL3D1IEwKCllEkuP XErlwzzA8gzY4Ygk9v215yuezaELrjIoIYC+3QFBQl443e02/XVZsBtaC1z3KcGW3pbDvTtZfI8 tAay7WBo= X-Gm-Gg: ASbGncuybRQ3dlzsKy0c3rdW3UlpvvUmq/8mMKFUybXFKgMTtyXIzvWUs7/jigsWLAk JEyWeELBPaoyGjQpPQCrOnMW5/GeAkyx4qm57JbVbLL4v+adRGSuTWwGcnpFtJ7uGxS7RR9OjBH cXwgIj2W4oWps6Xsa5BnPApxjlxz7oO/LQC8ov3Y9+kQ5XOPSx8gSbLuOhe6jXgzvYwiVaKvtKQ HSSDkiJXX0u+g/bF70L9FZDbo8qK1KbdYjTEEW5qNJXHa9gYdi8WFeYa9CGc0ZWz6l5GUu9em1t i/BPFUeA/oHwNtBhv+BRJmWvrcxN+FbGAbP3mU7W1fpoBGjflTkCVF6pBUwxQcXgtSw5Jkd6riW Iydr6pt7aHVGd838R8U2X0tdUcXFsctifOt6/G0Rakj77HCQwAs6c709aJ8CdTuQvX0+vNlZPuY DrGA== X-Google-Smtp-Source: AGHT+IHuGGshBE11UswiTAVCGXRupZTuoOG9Ht4DWbahk+TZ+ISigvCdYg80rgu+VSa57mx1WUdvqg== X-Received: by 2002:a17:907:3f21:b0:afc:cc64:86da with SMTP id a640c23a62f3a-b04b14f5015mr511931166b.26.1757261728217; Sun, 07 Sep 2025 09:15:28 -0700 (PDT) From: Bernhard Kaindl To: xen-devel@lists.xenproject.org Cc: Alejandro Vallejo , Bernhard Kaindl , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v3 3/7] xen/page_alloc: Add and track per_node(avail_pages) Date: Sun, 7 Sep 2025 18:15:18 +0200 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1757261760435116600 Content-Type: text/plain; charset="utf-8" From: Alejandro Vallejo The static per-NUMA-node count of free pages is the sum of free memory in all zones of a node. It's an optimisation to avoid doing that operation frequently in the following patches that introduce per-NUMA-node claims. Signed-off-by: Alejandro Vallejo Signed-off-by: Bernhard Kaindl --- Changes in v2: - Added ASSERT(per_node(avail_pages, node) >=3D request) as requested during review by Roger: Comment by me: As we have ASSERT(avail[node][zone] >=3D request); directly before it, the request is already valid, so this checks that per_node(avail_pages, node) is not mis-accounted too low. Changes in v3: - Converted from static array to use per_node(avail_pages, node) --- xen/common/page_alloc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index e056624583..b8acb500da 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -486,6 +486,10 @@ static unsigned long node_need_scrub[MAX_NUMNODES]; static unsigned long *avail[MAX_NUMNODES]; static long total_avail_pages; =20 +/* Per-NUMA-node counts of free pages */ +DECLARE_PER_NODE(unsigned long, avail_pages); +DEFINE_PER_NODE(unsigned long, avail_pages); + static DEFINE_SPINLOCK(heap_lock); static long outstanding_claims; /* total outstanding claims by all domains= */ =20 @@ -1074,6 +1078,8 @@ static struct page_info *alloc_heap_pages( =20 ASSERT(avail[node][zone] >=3D request); avail[node][zone] -=3D request; + ASSERT(per_node(avail_pages, node) >=3D request); + per_node(avail_pages, node) -=3D request; total_avail_pages -=3D request; ASSERT(total_avail_pages >=3D 0); =20 @@ -1234,6 +1240,8 @@ static int reserve_offlined_page(struct page_info *he= ad) continue; =20 avail[node][zone]--; + ASSERT(per_node(avail_pages, node) > 0); + per_node(avail_pages, node)--; total_avail_pages--; ASSERT(total_avail_pages >=3D 0); =20 @@ -1558,6 +1566,7 @@ static void free_heap_pages( } =20 avail[node][zone] +=3D 1 << order; + per_node(avail_pages, node) +=3D 1 << order; total_avail_pages +=3D 1 << order; if ( need_scrub ) { --=20 2.43.0