From nobody Fri Oct 31 16:34:13 2025 Delivered-To: importer@patchew.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; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1748423887; cv=pass; d=zohomail.com; s=zohoarc; b=kaWIa9Hks6ZYgs2Cp9viH+PTBjs6Gce1EEEsl9J0tENnro5FpMXa+Uam4fsyztnY3lHHOS8SY/Vc1qe769a1/sgnuj9rMn5QaIQdddknyO7eO4QjrIY1++dq2Ycuwo8ZXuicy46cUE1rWytx9u8YGTyIDUd800PJDK17Egi6G5w= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748423887; h=Content-Type: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=/GfDRm9JhuMPhiHwATAYzNDZZibb4ZAY1VdgVn0JUz8=; b=CTZ7zj/lpf0VMnpXkcn6Ju7chXQwjKYce99qtI00dyzTb54kyC1D9IRHoJlE8IHWk3UmU5dLFjIK2rF4yyLplwIRoJbWmurkx9TKbZILSMdyCGJE3ohXSffvEhA2XK93WRM6g14v/dveKFISkxXxgEzF1D07BZwsdkYSLsbEuic= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17484238876001000.1510966472688; Wed, 28 May 2025 02:18:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.999058.1379765 (Exim 4.92) (envelope-from ) id 1uKCv1-0001CJ-Gc; Wed, 28 May 2025 09:17:51 +0000 Received: by outflank-mailman (output) from mailman id 999058.1379765; Wed, 28 May 2025 09:17:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uKCv1-0001CC-Dp; Wed, 28 May 2025 09:17:51 +0000 Received: by outflank-mailman (input) for mailman id 999058; Wed, 28 May 2025 09:17:50 +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 1uKCv0-0000yL-9S for xen-devel@lists.xenproject.org; Wed, 28 May 2025 09:17:50 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060d.outbound.protection.outlook.com [2a01:111:f403:2418::60d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9f7c8793-3ba4-11f0-a2fe-13f23c93f187; Wed, 28 May 2025 11:17:49 +0200 (CEST) Received: from SN4PR0501CA0113.namprd05.prod.outlook.com (2603:10b6:803:42::30) by CY1PR12MB9700.namprd12.prod.outlook.com (2603:10b6:930:108::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8769.26; Wed, 28 May 2025 09:17:46 +0000 Received: from SN1PEPF00036F42.namprd05.prod.outlook.com (2603:10b6:803:42:cafe::92) by SN4PR0501CA0113.outlook.office365.com (2603:10b6:803:42::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8792.19 via Frontend Transport; Wed, 28 May 2025 09:17:46 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF00036F42.mail.protection.outlook.com (10.167.248.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8769.18 via Frontend Transport; Wed, 28 May 2025 09:17:46 +0000 Received: from penny-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 28 May 2025 04:17:43 -0500 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: 9f7c8793-3ba4-11f0-a2fe-13f23c93f187 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Xa4WyhsDYigSBWc43dWjwF+tfVdvQhmxB7TP16qn6/NXh/edWcpBYP9Two97KfEEVzf9Vdd0S4HuSqrxbFzvOB3W+D4mRHzudWwaDX5CZCGE2Gv6uz0rldlPhln0VRPEJZ+Wmzb3+4KpGIZo8loDYehqOXsKZkx2KFzFctA8UIj0feI92t5KGTWsAM6X8H8BIYLLGtkZCfnH2V9jO10iKXQ/KmHcwwsX7uXIHWE7ckyuaSVg9SAmDNCb3ys5d+EnsA7I2hQFtrxhKYehkn1CWTZ/8fLiw4ElWYG5/tk5/idr4RBIbmDiouWF+9OYwkr+if9MCJda7oG2w1UieXzDZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/GfDRm9JhuMPhiHwATAYzNDZZibb4ZAY1VdgVn0JUz8=; b=kMyJEdVYQZyYlTmiEx1g1uqD5MGXhSDga7jVV9SfchVEXB+iZF8zRijNR5eAUjeQeKVUX76+JNLdKXxVP4/+ncVXLqRAt0O0Hkme86Ck4AcRcsFpvc57mrWNX+Eo4jmZy11Sp3KqTRb6aUh2ViN7SfhKCNM+p/YWPxgg0jGXJ86v5c/sbZqUOzD+38AW0ungPSK20OoHVHG6X80Vsyjkpkaaiuq1cQbkr061XCGX1uG8ibL0OANOQuuAZ3XdDvfXWUAQuMpUkFhwkcI6MK2lGsNID2BV24YYYH8Otd7CICYkbgyIpAnvp7ph6DXkykhlBL20qmGP26RFwD70wE/oZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/GfDRm9JhuMPhiHwATAYzNDZZibb4ZAY1VdgVn0JUz8=; b=NXGgtCc9eS48V3rPYpVVKp3uhizozXIWQLNuE1VtUzGXQBpJeKdC8GHrVj9JCo18Tpq6bmBx5Kimg1yKZT8etHpHe1KbNSMDlUr4gVbcmfG+A6VmlW1wMAIMsJlyMkUWBmhiXiR6cs2KzpGJGgfmVSw6AI/9Fm9TOhgOu9YsoQ0= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; 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; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Penny Zheng To: CC: , Penny Zheng , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , "Julien Grall" , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v4 02/20] xen: make avail_domheap_pages() inlined into get_outstanding_claims() Date: Wed, 28 May 2025 17:16:50 +0800 Message-ID: <20250528091708.390767-3-Penny.Zheng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250528091708.390767-1-Penny.Zheng@amd.com> References: <20250528091708.390767-1-Penny.Zheng@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F42:EE_|CY1PR12MB9700:EE_ X-MS-Office365-Filtering-Correlation-Id: f5d71637-5c8f-4e40-1214-08dd9dc8824a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Vonb12ej2Fs1zx9gJIj0+5j1J8VgLT/WcogGN8yvGteMatyScBJPT7ppeJD6?= =?us-ascii?Q?DL7HH8yYCGB5BFvZSTOee6IbGNjllSd2JLFy5LRKqvfUHQdJ1KK0kv3U3ogW?= =?us-ascii?Q?lMCwZek4U2u+X1Zg53bbQXoNmwu95UaPNivV6k78HdnbPLr/n7IftoJxyLqK?= =?us-ascii?Q?KfNeDq4+dNCBpmWiUaVK+BjBoPY9kG4TFm7DR8YmESbeaP1PB4TetF4jeyTE?= =?us-ascii?Q?4d2epXEwb/rTDfPsfnkRDawgm8AQLSe/r8tFyYTNbErfrBgg3gv9WKiHdelJ?= =?us-ascii?Q?VWK0+0HaJue2R5tk1mChBMP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ii?Q?01HRIt47zPXgCP+Db8Bsx2l3OZOwe1asxrLyjFZz4iyr1cp8/hnh2u+cK5fd?= =?us-ascii?Q?pOtJNb3iyLlhj+XYjDCMf0fbpVHLBjihkpExRp/f/ooUNtn1T/ep7yazKvUi?= =?us-ascii?Q?SU96wvpssKEAb/Oqce3UAf0apO9yc2YWK2l2J3K+/q9EyOayHND7SB2+h9sm?= =?us-ascii?Q?GFjgGrsCHg3DkyK9cWjIIMTdc3BzsCqHq1+wJbZeK1ZaT+uy0whlGOyl9INB?= =?us-ascii?Q?CX+ngVQUg8o0jyvKp2EhHa7lY9WcwF7ceXqynPkdZkAkkqoLSs4kWzgOqk7r?= =?us-ascii?Q?szkIaTeTBBcuuKpnF9PyPr4b9eaF+DofX+rP?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2025 09:17:46.0745 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f5d71637-5c8f-4e40-1214-08dd9dc8824a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F42.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB9700 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1748423889144116600 Content-Type: text/plain; charset="utf-8" Function avail_domheap_pages() is only invoked by get_outstanding_claims(), so it could be inlined into get_outstanding_claims(). Move up avail_heap_pages() to avoid declaration before get_outstanding_claims(). Signed-off-by: Penny Zheng Reviewed-by: Stefano Stabellini --- v1 -> v2: - let avail_domheap_pages() being inlined into its sole caller - move up avail_heap_pages() --- v2 -> v3: - change the title --- v4 -> v5: - move ahead and could go in right away --- xen/common/page_alloc.c | 51 ++++++++++++++++++----------------------- xen/include/xen/mm.h | 1 - 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index e57a287133..b204f22f50 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -488,6 +488,27 @@ static long total_avail_pages; static DEFINE_SPINLOCK(heap_lock); static long outstanding_claims; /* total outstanding claims by all domains= */ =20 +static unsigned long avail_heap_pages( + unsigned int zone_lo, unsigned int zone_hi, unsigned int node) +{ + unsigned int i, zone; + unsigned long free_pages =3D 0; + + if ( zone_hi >=3D NR_ZONES ) + zone_hi =3D NR_ZONES - 1; + + for_each_online_node(i) + { + if ( !avail[i] ) + continue; + for ( zone =3D zone_lo; zone <=3D zone_hi; zone++ ) + if ( (node =3D=3D -1) || (node =3D=3D i) ) + free_pages +=3D avail[i][zone]; + } + + return free_pages; +} + unsigned long domain_adjust_tot_pages(struct domain *d, long pages) { ASSERT(rspin_is_locked(&d->page_alloc_lock)); @@ -584,7 +605,7 @@ void get_outstanding_claims(uint64_t *free_pages, uint6= 4_t *outstanding_pages) { spin_lock(&heap_lock); *outstanding_pages =3D outstanding_claims; - *free_pages =3D avail_domheap_pages(); + *free_pages =3D avail_heap_pages(MEMZONE_XEN + 1, NR_ZONES - 1, -1); spin_unlock(&heap_lock); } =20 @@ -1962,27 +1983,6 @@ static void init_heap_pages( } } =20 -static unsigned long avail_heap_pages( - unsigned int zone_lo, unsigned int zone_hi, unsigned int node) -{ - unsigned int i, zone; - unsigned long free_pages =3D 0; - - if ( zone_hi >=3D NR_ZONES ) - zone_hi =3D NR_ZONES - 1; - - for_each_online_node(i) - { - if ( !avail[i] ) - continue; - for ( zone =3D zone_lo; zone <=3D zone_hi; zone++ ) - if ( (node =3D=3D -1) || (node =3D=3D i) ) - free_pages +=3D avail[i][zone]; - } - - return free_pages; -} - /************************* * COLORED SIDE-ALLOCATOR * @@ -2796,13 +2796,6 @@ unsigned long avail_domheap_pages_region( return avail_heap_pages(zone_lo, zone_hi, node); } =20 -unsigned long avail_domheap_pages(void) -{ - return avail_heap_pages(MEMZONE_XEN + 1, - NR_ZONES - 1, - -1); -} - unsigned long avail_node_heap_pages(unsigned int nodeid) { return avail_heap_pages(MEMZONE_XEN, NR_ZONES -1, nodeid); diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index e89942b87d..93c037d618 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -141,7 +141,6 @@ struct page_info *alloc_domheap_pages( void free_domheap_pages(struct page_info *pg, unsigned int order); unsigned long avail_domheap_pages_region( unsigned int node, unsigned int min_width, unsigned int max_width); -unsigned long avail_domheap_pages(void); unsigned long avail_node_heap_pages(unsigned int nodeid); #define alloc_domheap_page(d,f) (alloc_domheap_pages(d,0,f)) #define free_domheap_page(p) (free_domheap_pages(p,0)) --=20 2.34.1