From nobody Fri May 17 01:43:39 2024 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=2 dmarc=pass fromdomain=arm.com); dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=3; a=rsa-sha256; t=1662089537; cv=pass; d=zohomail.com; s=zohoarc; b=WPX+8oHsfJR8i6mzAjMlItpOqrFrRWjoHtXtaKoOdpFlB5i/ni8QV7KQu/nT6vqm787uO181VSEi3ubSKmzzZ+BFFxiV85pOQabsjm5XLSuVseqP1w7cM+4lcX0wytpR0OW5PiEHNpHehmJ4RZvh6a85/fML8Xn6bpHWb2ieAHE= ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662089537; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WNPp3mJZEp8qgDxT7NNCkedF3iq87kU7+nkKCUJRg9E=; b=BT9gmiBh1wUooHukXhhvmtpR3sQ0cSS3ltomEWXIpH6dVJl+JcqgtX6pBKzP73UULnKHqWKYdZsXmDrAulCcq7Gk204WW5MFzAC6f5HqlZC+4ulPO4kFjnycULYkDYqadhPsTgVsYRfEw7CvtPLoLJZvhXToIs5qe6Op9gCCOHo= ARC-Authentication-Results: i=3; 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=2 dmarc=pass fromdomain=arm.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1662089537981580.0124458251429; Thu, 1 Sep 2022 20:32:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.397240.637743 (Exim 4.92) (envelope-from ) id 1oTxPR-0004aZ-B2; Fri, 02 Sep 2022 03:31:57 +0000 Received: by outflank-mailman (output) from mailman id 397240.637743; Fri, 02 Sep 2022 03:31:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTxPR-0004aS-7F; Fri, 02 Sep 2022 03:31:57 +0000 Received: by outflank-mailman (input) for mailman id 397240; Fri, 02 Sep 2022 03:31:56 +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 1oTxPP-0004PQ-T4 for xen-devel@lists.xenproject.org; Fri, 02 Sep 2022 03:31:56 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2055.outbound.protection.outlook.com [40.107.104.55]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ca575257-2a6f-11ed-82f2-63bd783d45fa; Fri, 02 Sep 2022 05:31:54 +0200 (CEST) Received: from AS9PR06CA0590.eurprd06.prod.outlook.com (2603:10a6:20b:486::14) by DU0PR08MB7836.eurprd08.prod.outlook.com (2603:10a6:10:3b3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.11; Fri, 2 Sep 2022 03:31:52 +0000 Received: from AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:486:cafe::3e) by AS9PR06CA0590.outlook.office365.com (2603:10a6:20b:486::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:31:51 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT004.mail.protection.outlook.com (100.127.140.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:31:51 +0000 Received: ("Tessian outbound cc6a8ab50b6b:v123"); Fri, 02 Sep 2022 03:31:51 +0000 Received: from 82be5ef6c966.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F5C52205-6D88-4297-B9DA-50E11D1A7228.1; Fri, 02 Sep 2022 03:31:44 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 82be5ef6c966.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 02 Sep 2022 03:31:44 +0000 Received: from DB6PR0301CA0062.eurprd03.prod.outlook.com (2603:10a6:4:54::30) by GVXPR08MB7824.eurprd08.prod.outlook.com (2603:10a6:150:1::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.14; Fri, 2 Sep 2022 03:31:41 +0000 Received: from DBAEUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:54:cafe::3a) by DB6PR0301CA0062.outlook.office365.com (2603:10a6:4:54::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.14 via Frontend Transport; Fri, 2 Sep 2022 03:31:41 +0000 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT034.mail.protection.outlook.com (100.127.142.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:31:41 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.9; Fri, 2 Sep 2022 03:31:40 +0000 Received: from ais-wip-ds.shanghai.arm.com (10.169.190.86) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.9 via Frontend Transport; Fri, 2 Sep 2022 03:31:37 +0000 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: ca575257-2a6f-11ed-82f2-63bd783d45fa ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=agV1RI+rH3UnYlnMqnFXqyiD/9Dxl8dDNni85XJOm/OWtF1LndI4VhYxmScicb4yLG/j3n/8QZNK2hDjoPV+p/33QvhYGN/rfnOoRG0dfkCQ626zr1B60bCTwDN2pr2zhruYgu6zZKH1gQ6UT8Lpc7FfqcOdC/xw3OynFVMttTi/YAJ7c49LhVFveLT5l7U9fhRd+mAAB5oBJU/5/f5w5cas3R8PYKd6F/IeYWBqtHiWPuBrB2lkLNugc07Hw6vhKYEkQpcBF+Nk9I9vlP30i5GiUo/D5rfdGYh8oZiyhKIMrmeTauXWH9r2gUmiXgEpfsc8m5Av0xf0e+3ESIbSRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=WNPp3mJZEp8qgDxT7NNCkedF3iq87kU7+nkKCUJRg9E=; b=d5NZzwk4A4OPfW4NaV+AWFrALwYBnYDbxNJstk7CgHSbcQXeg/nQ0wBpkrH4zr7JXOspQak0+N1ZmzbB1yXxg5elGs/qJ8sjYvNFJkLm5eGldldKx5mfh8lVECYRLHLY9vqaMITCFGOOs5YRezKfA6h8NP7HfK/iwNroqdMIr9g9nfarrKtQeF8Z1M/W7RbVmjpMbEZ1GcnRbZUw0DbA9frkSjLVaB3JRLJ+NUBbi2BXRoDTFD4PKBbI/VQjfbwFTkL5FS35FwneeAe/L11iuTJgpSu20RX3JBo6Jsg4a9/hFHIFc+WU+T+wN/48xIDiIHP9O1xoNPH6bXF2+TvGAw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WNPp3mJZEp8qgDxT7NNCkedF3iq87kU7+nkKCUJRg9E=; b=0MfFbPHdHJjrt/xT6qIRxyWCB8b47MycbH4BKMhmU4oI24yXvECilqzXvcplyWrr7gjP20bk4yw/LX98D7B+qBJg+7jXpSEHbAav5hduxuLBgNsUryv1gDrciOYhpPMTQODm1eZ63onqxNwX8UIimIXgElRiQgRkpzDZtejtbq4= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.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 arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C X-CheckRecipientChecked: true X-CR-MTA-CID: 0c5eb577714c7dcb X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GEuhdfV/wTOdEh0vI0nbjuCPzZgQ6qAYQXXh+JErdB1G2ggqmk7fvDi5eeGbCseJk45llG0RolrRoRR6K+tZFOgT+j2qurJgvH6lWR85QOCiGGTVWlNBOmnKAA7z9NoVmbzg8a/Gko+C92ddcmRRUKmODSgb07+hFuUEoCI/SuRJvo+PdmUTVENaqsJO941bBVb401Mx8DRe6tmy0i6ZegH1IrFqy1BZpbhW2R7/azWNOJ1PRwmHCcGMmHPHpxWki3sc/xOuKY0Mcs6nemW4SCQ27YLMl76oefDwDVuy3if9JfZgzShODhBGZtV8PhVNSgNAELwAuXa7fglXjbVRhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=WNPp3mJZEp8qgDxT7NNCkedF3iq87kU7+nkKCUJRg9E=; b=Hd6NQa4aMB1TyrnTx6hq/0G89++DybxwM4DWF7qyc8Rxh8pgNTpVQ2WW85A9irueldnadGzYcxuwCw+BBdZK4wOjeDwwu0xVxhK1bc4IFQtWKr+teiGJQPEgZQVtSi66Ug/YyB6SBOWtwJfrmyYSYCGXsaYZa2pGkYSrMjVTTjP0LEHIc18wXrzJYndU99GvFY9OSydcamq33VXrcmGyOLQoIhGFCRMEX19GO1L7Yzy9ytW+GspkeK04f1VnhFJpuCmu0HetGHrtkVxiyHRm5A0oAjxU4fsUy6F5x9fxLD6B1YRbrZB+5Sl3A0j7IHiQ8Oc0t7ysgEF4MExBv9jTPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WNPp3mJZEp8qgDxT7NNCkedF3iq87kU7+nkKCUJRg9E=; b=0MfFbPHdHJjrt/xT6qIRxyWCB8b47MycbH4BKMhmU4oI24yXvECilqzXvcplyWrr7gjP20bk4yw/LX98D7B+qBJg+7jXpSEHbAav5hduxuLBgNsUryv1gDrciOYhpPMTQODm1eZ63onqxNwX8UIimIXgElRiQgRkpzDZtejtbq4= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C From: Wei Chen To: CC: , Wei Chen , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v4 1/6] xen/x86: Provide helpers for common code to access acpi_numa Date: Fri, 2 Sep 2022 11:31:16 +0800 Message-ID: <20220902033121.540328-2-wei.chen@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902033121.540328-1-wei.chen@arm.com> References: <20220902033121.540328-1-wei.chen@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 189b2cfa-822f-46c9-b182-08da8c93acf6 X-MS-TrafficTypeDiagnostic: GVXPR08MB7824:EE_|AM7EUR03FT004:EE_|DU0PR08MB7836:EE_ x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: u1KYr7qybhylkmenMlr/aA9ZI4QLFrCAVgvmQ0EaKKDDNV3eBnG4jrH0t9cG74bZSRQ4SY1y/LEhWCAXl/LWoWuTEjt8h3VZx/6JeSkVk3r8ylNxor0fkWCNnYJ4gBFfFJzYuKVOZvwb/oUvHnQDZgAFG2Cq1awzF6DhEtmX+O3osk9QZX1uxuWe409LsUPJphBUmWHiAuRKJWdfuivRwe/TB3XPcrFD//ghzh4VqfYv5xe96ChNlk4VGmypsQuy2uUbLRbKJT+fP0K5V3eYhwNqfQkBHLtaB2BYtVHnoCOXqrSeLO4Ra7R1x+o0WrXiPWZN3gSUaclBfwwnHQ3zzGneIgrXi+uI5aINXKt6ryZ2S+lK3aeRj3Itp4m3GpJuEDy6rsbjwxnqE047dT8Z63miLVMqD5GUMmN6RjEKzn/u8POvPP8vdWhMnKFRHF002S7rpilQ15aYzajVKjE25b+bK4HWnPZm9Wg1IkPEHzi1yMmV+aatK9SrhRR5Ajpn5UEKeDqZaMcdP0BapR34rBHvt6LkgXD7lTfb5LmdSwd2FT95JCzkMMG1ZrZ1arQ66d6prNRhnDB+fqKBQLfbUXuwiai0njkGk5KrBhOeFiKwSd4b2xx/uhwnjRBQrUWikITVxfhEAfJYI5EkIDQdHoJAxUm8BDkzM9QBiq2QJ3Ztr4uyMUyH73oG0Hb0FJeBwAkHl6tBcP+gE60Rps5UCOlcb2b+nh1wj0GdmWOv8O6UR1Z5m6PrUxR3pVilATQHaT9ZVLKC+qgA/JTcYIHkjvfotZemzGBJMNMPhaZSUQ9LVR6xF6vgBQtEEaMLE7EG X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(39860400002)(346002)(376002)(136003)(396003)(40470700004)(46966006)(36840700001)(36860700001)(6666004)(82310400005)(36756003)(8676002)(5660300002)(44832011)(2906002)(4326008)(83380400001)(8936002)(70206006)(70586007)(40460700003)(356005)(54906003)(6916009)(316002)(478600001)(41300700001)(40480700001)(81166007)(2616005)(26005)(186003)(1076003)(7696005)(82740400003)(426003)(47076005)(336012)(86362001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB7824 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: cbdb8ee2-262e-4894-7b45-08da8c93a6bc X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t3QbMjI06yOZjneEKCU9tzb5ER4JNv1EdB3zcE8PxLDgFNmfF00y0Mxbc/KHS5d8goHSx+7iOxiQVPugiVEWjy0LjOkZFmMPla2LndhKZVjIQiZ2kWOA3B8n8ejORTyr/ALG+2H9q9fxCbk4+Tjhl1fTHSsgmsfZTDtMyZwwOyLXcW0s+tdUfdZ8K3R7El6x9td3R64teFXkWqwzN9qdiXNaImnjFdAk8cm14+Ay21/tMmd0h4o21nWl51Bf5PZS6LtvVCCNNT7PllH81/Epzz7+axTaSt6KKyLZNJarEtqYljTzzzUlZEJpV3ayWzcM8Syc2l8gNLvvHcJDu9uRG3uTEUDwGdvceUZNRNQTr300zuRySIEV4CE3E+r6bgtBAED7lMB3weesOmk3RglS5vFIFE+TuGToYu6a0JgmFlg8fGC/ygO1RLHCv9GJqwKrQQlVqI4bN8kub82p+ajrs9ns0w+GMCj7upG2KhOWjjzmhzyfUXzRBfiIS/SAlL4FxhQ3lwrX+cgkCzHrxKIcuDOCwPXFkzC4/G97AmWZRDVXQaJcFwGRZ6mHHlZZ5uxz9ubo6ufgwqn+dSQBbLlkfjvvyZkeq/u9vjfjr+BwtPiWS059kCIQiZq17GubVUYsbW3izGJhvw7SchUQ1KzhtTqd/6SBLYcsYNZFAQSU10pupWoOCm7EHSt50Bk/WCr/EgetgbfeQhlxz51fFPeob0SntKH3DAUidWNMVWh4vTuvuJrzgU2/MMffZqz0avg/8FVg7c1DlR+gHSXPAfITfw== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230016)(4636009)(346002)(39860400002)(396003)(376002)(136003)(36840700001)(46966006)(40470700004)(1076003)(426003)(47076005)(6666004)(2616005)(41300700001)(26005)(81166007)(86362001)(7696005)(40460700003)(36860700001)(83380400001)(336012)(186003)(82740400003)(40480700001)(36756003)(8936002)(5660300002)(4326008)(70206006)(70586007)(8676002)(2906002)(44832011)(478600001)(82310400005)(54906003)(6916009)(316002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2022 03:31:51.5807 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 189b2cfa-822f-46c9-b182-08da8c93acf6 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7836 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1662089539942100001 Content-Type: text/plain; charset="utf-8" acpi_numa is a specific NUMA switch for ACPI NUMA implementation. Other NUMA implementation may not need this switch. But this switch is not only used by ACPI code, it is also used directly in some general NUMA logic code. So far this hasn't caused any problem because Xen only has x86 implementing ACPI NUMA, but now Arm is implementing device tree based NUMA. Accesssing acpi_numa directly in some functions will be a block of reusing NUMA common code. It is also difficult for us to replace it with a new generic switch, because it is hard to prove that the new switch states can guarantee the original code will work correctly. So in this patch, we provide two helpers for common code to update and get states of acpi_numa. And other new NUMA implementations just need to provide the same helpers for common code. In this case, the generic NUMA logic code can be reused by all NUMA implementations. Signed-off-by: Wei Chen Reviewed-by: Jan Beulich --- v3 -> v4: 1. Drop parameter from arch_numa_disabled, the parameter will be introduced in later patch where use it. 2. Drop unnecessary "else" from arch_numa_setup, and fix its indentation. v2 -> v3: 1. Drop enumeration of numa status. 2. Use helpers to get/update acpi_numa. 3. Insert spaces among parameters of strncmp in numa_setup. v1 -> v2: 1. Remove fw_numa. 2. Use enumeration to replace numa_off and acpi_numa. 3. Correct return value of srat_disabled. 4. Introduce numa_enabled_with_firmware. --- xen/arch/x86/include/asm/numa.h | 5 +++-- xen/arch/x86/numa.c | 38 ++++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/include/asm/numa.h b/xen/arch/x86/include/asm/num= a.h index c32ccffde3..237f2c6dbf 100644 --- a/xen/arch/x86/include/asm/numa.h +++ b/xen/arch/x86/include/asm/numa.h @@ -32,8 +32,9 @@ extern void numa_add_cpu(int cpu); extern void numa_init_array(void); extern bool numa_off; =20 - -extern int srat_disabled(void); +extern int arch_numa_setup(const char *opt); +extern bool arch_numa_disabled(void); +extern bool srat_disabled(void); extern void numa_set_node(int cpu, nodeid_t node); extern nodeid_t setup_node(unsigned int pxm); extern void srat_detect_node(int cpu); diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c index 627ae8aa95..a5bc7a78c9 100644 --- a/xen/arch/x86/numa.c +++ b/xen/arch/x86/numa.c @@ -50,9 +50,28 @@ nodemask_t __read_mostly node_online_map =3D { { [0] =3D= 1UL } }; bool numa_off; s8 acpi_numa =3D 0; =20 -int srat_disabled(void) +int __init arch_numa_setup(const char *opt) { - return numa_off || acpi_numa < 0; +#ifdef CONFIG_ACPI_NUMA + if ( !strncmp(opt, "noacpi", 6) ) + { + numa_off =3D false; + acpi_numa =3D -1; + return 0; + } +#endif + + return -EINVAL; +} + +bool arch_numa_disabled(void) +{ + return acpi_numa < 0; +} + +bool srat_disabled(void) +{ + return numa_off || arch_numa_disabled(); } =20 /* @@ -291,28 +310,21 @@ void numa_set_node(int cpu, nodeid_t node) /* [numa=3Doff] */ static int __init cf_check numa_setup(const char *opt) { - if ( !strncmp(opt,"off",3) ) + if ( !strncmp(opt, "off", 3) ) numa_off =3D true; - else if ( !strncmp(opt,"on",2) ) + else if ( !strncmp(opt, "on", 2) ) numa_off =3D false; #ifdef CONFIG_NUMA_EMU else if ( !strncmp(opt, "fake=3D", 5) ) { numa_off =3D false; - numa_fake =3D simple_strtoul(opt+5,NULL,0); + numa_fake =3D simple_strtoul(opt + 5, NULL, 0); if ( numa_fake >=3D MAX_NUMNODES ) numa_fake =3D MAX_NUMNODES; } -#endif -#ifdef CONFIG_ACPI_NUMA - else if ( !strncmp(opt,"noacpi",6) ) - { - numa_off =3D false; - acpi_numa =3D -1; - } #endif else - return -EINVAL; + return arch_numa_setup(opt); =20 return 0; }=20 --=20 2.25.1 From nobody Fri May 17 01:43:39 2024 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=2 dmarc=pass fromdomain=arm.com); dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=3; a=rsa-sha256; t=1662089546; cv=pass; d=zohomail.com; s=zohoarc; b=W5AA4eTyIKWBB07i+OxMWhrZDJC/OaQ6KEsSANH9q45TcA/zLp2BnsuyfGUVOFJbFh/oKFY2K1LbJxR/YHtWFtVuPR25p6cr3zxKGP430y229ULsO/ezZJsfNt8RzRXcwiSrY/J0SEc2RPsC79pGIVG/7H77aByGhPqvs/VXJnc= ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662089546; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=u3JxDfGTgCwV+3K/QsVhEvgokhqhriH7vz3pd5PWXsY=; b=LfSFxIcqnss03wN4/M/spjtaE4QYsevrRY8BSDNbbyMLb/D3IngzuQU7UzpTimC6ms2Uqp/Q+wq/cqVCN7M9S/TBzlmd8/yBAmKk8D4Mzu6JLFTu1mMnrZQziGpzu02aBwMTp0JXXmyd9M+faxsYoPQFUlyAnp0dHJMQan30J3A= ARC-Authentication-Results: i=3; 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=2 dmarc=pass fromdomain=arm.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1662089546195124.17062157083376; Thu, 1 Sep 2022 20:32:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.397241.637754 (Exim 4.92) (envelope-from ) id 1oTxPY-0004tD-IN; Fri, 02 Sep 2022 03:32:04 +0000 Received: by outflank-mailman (output) from mailman id 397241.637754; Fri, 02 Sep 2022 03:32:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTxPY-0004t6-FO; Fri, 02 Sep 2022 03:32:04 +0000 Received: by outflank-mailman (input) for mailman id 397241; Fri, 02 Sep 2022 03:32:02 +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 1oTxPV-0004Wz-Vf for xen-devel@lists.xenproject.org; Fri, 02 Sep 2022 03:32:02 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80052.outbound.protection.outlook.com [40.107.8.52]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cd047b2f-2a6f-11ed-934f-f50d60e1c1bd; Fri, 02 Sep 2022 05:31:59 +0200 (CEST) Received: from AS9PR06CA0574.eurprd06.prod.outlook.com (2603:10a6:20b:486::12) by DB4PR08MB9310.eurprd08.prod.outlook.com (2603:10a6:10:3f6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Fri, 2 Sep 2022 03:31:55 +0000 Received: from AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:486:cafe::c3) by AS9PR06CA0574.outlook.office365.com (2603:10a6:20b:486::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.12 via Frontend Transport; Fri, 2 Sep 2022 03:31:55 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT004.mail.protection.outlook.com (100.127.140.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:31:55 +0000 Received: ("Tessian outbound cc6a8ab50b6b:v123"); Fri, 02 Sep 2022 03:31:55 +0000 Received: from 141fe9bc610f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B76D6802-23C4-43D7-917F-32D5CBFEFB05.1; Fri, 02 Sep 2022 03:31:49 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 141fe9bc610f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 02 Sep 2022 03:31:49 +0000 Received: from DU2PR04CA0172.eurprd04.prod.outlook.com (2603:10a6:10:2b0::27) by GV1PR08MB8154.eurprd08.prod.outlook.com (2603:10a6:150:92::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.14; Fri, 2 Sep 2022 03:31:46 +0000 Received: from DBAEUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2b0:cafe::d4) by DU2PR04CA0172.outlook.office365.com (2603:10a6:10:2b0::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.14 via Frontend Transport; Fri, 2 Sep 2022 03:31:45 +0000 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT023.mail.protection.outlook.com (100.127.142.253) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:31:45 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.9; Fri, 2 Sep 2022 03:31:44 +0000 Received: from ais-wip-ds.shanghai.arm.com (10.169.190.86) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.9 via Frontend Transport; Fri, 2 Sep 2022 03:31:40 +0000 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: cd047b2f-2a6f-11ed-934f-f50d60e1c1bd ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Ay7mTJE10ZArryG2jdemEo1OTQBY9AiGecZlPT6Xqy5FCzQLXiE/0fEsYgOeMESJ61zuempf8B+sAdrAVVolL2fyKiXr5nLS4jvSeOqXt9FBNj/HJYWZ51BEDB9jt7hJZeB8hoceOGXbNPZN74eMkyfKUcBw857iUI6jz5S135MM5PYBA9pWGSRqxUQXqVcDrYwpPifiT7QXXnW5R4ysPvQi/bsxqD01w685T/hVnLJF8DDZRsuITzDUrjTY6Qqga5neJPB3PtBm4T8w5dxMj+p11Aa8jx2uhtAGOxRSd3sV3SM+uiwnpymL7IBuc0k5YgZik7q4hSa5DRXWdlRaUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=u3JxDfGTgCwV+3K/QsVhEvgokhqhriH7vz3pd5PWXsY=; b=WODcaVs7iMD5MbekUnN198T5u+wSLjx+g+iNE5FXYJluM4/oA47oLo3dkkW5zAobGFpt2t5X4PTA2zDMchpiZzLL6J0pa6GAlR8M98LwFbtV9hB0gp5KwhSHAzWwfxvl8t1/bk+usRASkF7wvabRdVF5joIObcZKPRO1PM3KrXrJLKYx4uzSgM7iQdg2ohfH6bgKHjmv6oeaHOItjFxITFGg9UsEFBjav0kctlXLr7s2wLzdhWjdC6yaePGqc5at+0hUozChCToLem4f7vJQY8bYTR/Q/uoPEFXhHm7pgrEvWaZtYmfY378jxcH0KN/e901jUxnOjggCgnANlpqq/g== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u3JxDfGTgCwV+3K/QsVhEvgokhqhriH7vz3pd5PWXsY=; b=554UaewuSmuIxEp0HIv9AjKr40PioAVIbIFXBsnOgC4pN1wC5K61fRtoSExGNu3KheHwwuj9u5LNbu1GkPaSbOnv4t4M0zRuuQK/tb4aEbf4PYgP6Uil6czNXzdPyLX1gsYCQZWIz9DBEuMPF19GFZEIq6a+NaCYX4ZbWOmLYGY= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.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 arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C X-CheckRecipientChecked: true X-CR-MTA-CID: ae6dbf44dc684e6f X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JAqTYvORQPcMS+aug8+UfSzgOk7894pX0Z8816twi3u7ngi6/CsxVkT6TNBAqIctCnGf4NOpBUqiWDOe7vmKO0dJCqk7oke7Cakf6r3x6Wg0LAAJBkkQGsWkyJH9pezfy+uf1iVKKEOSu3SAVuySymSYX60Klgz/CSOCS1p+PPMayC8kOdX/NmZCLEgj0PRLj5qvyYzWXj5GshQNPFWtZCEbXNqXQHS5D1AcJZolw36Qycm7rUavu5HOL7R9S/tIayPHJW8AY+ycQM5jIWWBncj3VaSuTfehuq9MC4jGM0GaR7oy0G2qOXdTK3pYrhcFZ+gfsCWe48VLpaBeGuxwfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=u3JxDfGTgCwV+3K/QsVhEvgokhqhriH7vz3pd5PWXsY=; b=ZsY+s+9H1kyBGQ20WsTLy9LYJrakHh/MWi62FzKuoxltv2GejK4c80BvHmXnQ3bvtJ4d5OIuTD3e5aw/Qno0+p0cWivi1Sv6446YzDgzH2zeaGCpmMLFLm2OsFmE+UqCG1KgsBRBCk5bYZRiBO9xiaxnoAmXTS03xqiT/BIyrkt4vW5YjaquTqbsDAuHB9PFEVRvYAMS2RBosY9YorHAKY7pN2W7OCpX9DZJ9pqymRuaaSCIS82RykhUuue739G6gqGOwJmWADNF6wfDLXCXP5TcnvTKmKMo4jlB8UX55Tz9P0PQoqXquvwnQyZ/bLYZmdYAET6WnilNPmypGU2wYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u3JxDfGTgCwV+3K/QsVhEvgokhqhriH7vz3pd5PWXsY=; b=554UaewuSmuIxEp0HIv9AjKr40PioAVIbIFXBsnOgC4pN1wC5K61fRtoSExGNu3KheHwwuj9u5LNbu1GkPaSbOnv4t4M0zRuuQK/tb4aEbf4PYgP6Uil6czNXzdPyLX1gsYCQZWIz9DBEuMPF19GFZEIq6a+NaCYX4ZbWOmLYGY= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C From: Wei Chen To: CC: , Wei Chen , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini Subject: [PATCH v4 2/6] xen/x86: move generically usable NUMA code from x86 to common Date: Fri, 2 Sep 2022 11:31:17 +0800 Message-ID: <20220902033121.540328-3-wei.chen@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902033121.540328-1-wei.chen@arm.com> References: <20220902033121.540328-1-wei.chen@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 7346aa42-52b8-4192-9fab-08da8c93af56 X-MS-TrafficTypeDiagnostic: GV1PR08MB8154:EE_|AM7EUR03FT004:EE_|DB4PR08MB9310:EE_ x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 1z27gsK03g+NldG0H/II4d3ALIarp7U4GThMCpbRm1XUkaiNZ50ua5w2aZARF6jq06OE81zuLSYkTEkUM1ny4Ar1hfsR6on4qTvawnU/wSziapbigHlDhbgdoNAehO+MGvOyuu0Gy4smyNdA0caIn/dCsDgj5EJjs42f1FgxL4Son8L9pzUC9PpwxGZiXk7izcYK2k4u1RJOLUw0tE1FTUa6YeLEQSv6CYI/Rfd9j8LjyKytY9JZD1XRyTxTb0IOYdAAun/IM+lxJILjBIh6W9JLshQw9+ZqNedUkQXBU9BC+8x7wfu5Yz/8o4TNRihBHdxiKWL15RRutRo/filGwHLDY5RBV/xCh3qUxvVzeqo213ZkeT3IHi91Fw4xdRot2n3q4kEnrsc4N2G8emTBvqBpf8EEgpi8vX1gplepV8WjnkFvonISwJr8T8vY61I7bMTEcVNz5WbFZNv3vxBgWPGYNTVN6Mi/0yKjmh0A5nCGSllygpyhGyMn1XlD3VH3600r8LsT3Z+Yhftu9CSZmy1q7baIC+x6z7nquBaWTUDs12OaT3+r2mAh1wVVemxgy7pu9xwOU8xNcfoWYg68CnUNw2/UeYgpMseBIplnq8Q97Qbq6CRpqv25iatDKLYJxmWakn0iZF92XGi1XMFPP7Hqz3aRPTHyMb4KCULW4Gr8nI8mljh/BcpDdhBxE9wTciawaV3qD2y0SLyY+pOlAqKVJeW0u4J4wLP+4tWWsfjyStECDfTasQMbseWo56h28e9NNTAG5ZrEtiWLD+czHXl4raHI26mi6OyaUctcAwTcf5vWenP6IE6BTOJf1r/DTnISY3x6fDGk8eRCGsafMg== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(39860400002)(346002)(376002)(136003)(396003)(40470700004)(46966006)(36840700001)(36860700001)(6666004)(82310400005)(36756003)(8676002)(5660300002)(44832011)(30864003)(2906002)(4326008)(83380400001)(8936002)(70206006)(70586007)(40460700003)(356005)(54906003)(6916009)(316002)(478600001)(41300700001)(40480700001)(81166007)(2616005)(26005)(186003)(1076003)(7696005)(82740400003)(426003)(47076005)(336012)(86362001)(21314003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8154 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: dd7ebdfe-e9ff-48ca-4ef8-08da8c93a988 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GTZWJUVJc68JJUS5hKDoVBbldyuSdEfDPCwg4i+QOlOnOSuwYBu6/j06e0J7dC0N9DLnxVHO0YA7FPIM9m2D2HjGA1je14WfVsPH6FP/jUOxv5Za0woUfOqE2rsD+WhDZiINByYPPVBWsOX8LghESqD/9CzUbcQKxFyQHs2HF6UCFt/cG0LibRnKJMsCrmZTgIrOoZ9yybBXlqptwflzTls9QOJLLDqwitM/Nb0P0B2vwuk+Q4FNQX6ySgXiGGab0h5csWIYgirKbJG5ht9tHx8ZJFiGffEsrPlTHSwcWhzLma9f9o+S63p+ZHi7vrHm0Oqh97PqPpsVWK6jlM5lwu2cBX+/QqVHLraZsl0d5yTrgkS9d9iYw2Hbx9dU3ucRnDuIlGjT+2NY8TWAj//mGKF5hHXYHkz2NfGHxxm3Ewe3pYxrv1j5koVXwcfskPWiCeWcfaCnHC9wtYzWlfoal2gRhDxp/6m869QnePoPiXKG1V1wiElvxlmiOJakj/HBdtdXnt7JaqVVfTb09G8/lV9BHBrdMFqmiDgjxJdyfU79QC9eVS1V6ntA41sAN6TmMWs8xtDepBnyrzjs0o02WRiEOCSSZTmMCn8lKwosODciyY9AVZ/QvDkwl0wcR9YRNRWgQX8P4eYEgl0Pq3rS2FAyK+3ie2lzWr0yeB0V66r8HBbEMDykhDrOCdMcG07s3U13UXTH6fKvsOFiVwmcQiey+Y7zDSRhHJIvRc27Sov/2EII5abLBjfo4UplFdfmvW81oq/fLIBnk3aPmpbXjgPZrk+qG65e1IpIc+6NRMc= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230016)(4636009)(39860400002)(376002)(346002)(396003)(136003)(36840700001)(46966006)(40470700004)(26005)(186003)(7696005)(83380400001)(2616005)(81166007)(336012)(4326008)(70586007)(70206006)(8676002)(40460700003)(1076003)(478600001)(86362001)(6916009)(82310400005)(2906002)(5660300002)(47076005)(44832011)(6666004)(30864003)(426003)(107886003)(8936002)(36860700001)(36756003)(54906003)(316002)(82740400003)(41300700001)(40480700001)(21314003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2022 03:31:55.5336 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7346aa42-52b8-4192-9fab-08da8c93af56 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB9310 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1662089548254100001 Content-Type: text/plain; charset="utf-8" There are some codes in x86/numa.c can be shared by common architectures to implememnt NUMA support. Just like some variables and functions to check and store NUMA memory map. And some variables and functions to do NUMA initialization. In this patch, we move them to common/numa.c and xen/numa.h and use the CONFIG_NUMA to gate them for non-NUMA supported architectures. As the target header file is Xen-style, so we trim some spaces and replace tabs for the codes that has been moved to xen/numa.h at the same time. As acpi_scan_nodes has been used in a common function, it doesn't make sense to use acpi_xxx in common code, so we rename it to numa_scan_nodes in this patch too. After that if we still use CONFIG_ACPI_NUMA in to gate numa_scan_nodes in numa_initmem_init, that doesn't make sense. As CONFIG_NUMA will be selected by CONFIG_ACPI_NUMA for x86. So, we replace CONFIG_ACPI_NUMA by CONFIG_NUMA to gate numa_scan_nodes. As arch_numa_disabled has been implememnted for ACPI NUMA, we can rename srat_disabled to numa_disabled and move it to common code as well. Signed-off-by: Wei Chen --- v3 -> v4: 1. Restore compute_hash_shift's return value to int. 2. Remove unnecessary parentheses for macros. 3. Use unsigned int for proper variables. 4. Fix some code-style. v2 -> v3: 1. Remove acpi.h from common/numa.c. 2. Rename acpi_scan_nodes to numa_scan_nodes. 3. Replace u8 by uint8_t for memnodemap. 4. Use unsigned int for memnode_shift and adjust related functions (compute_hash_shift, populate_memnodemap) to use correct types for return values or parameters. 5. Use nodeid_t for nodeid and node numbers. 6. Use __read_mostly and __ro_after_init for appropriate variables. 7. Adjust the __read_mostly and __initdata location for some variables. 8. convert from plain int to unsigned for cpuid and other proper variables. 9. Use __attribute_pure__ instead of __attribute__((pure)). 10. Replace CONFIG_ACPI_NUMA by CONFIG_NUMA in numa_initmem_init. 11. Add const for some functions' parameters. 12. Move srat_disabled to common code with new name numa_disabled. 13. Fix some spaces code-style for numa_emulation. 14. Change from int to unsigned int for numa_fake. v1 -> v2: 1. New patch in v2. --- xen/arch/x86/include/asm/acpi.h | 1 - xen/arch/x86/include/asm/numa.h | 57 +--- xen/arch/x86/include/asm/setup.h | 1 - xen/arch/x86/numa.c | 430 +----------------------------- xen/arch/x86/smpboot.c | 2 +- xen/arch/x86/srat.c | 8 +- xen/common/Makefile | 1 + xen/common/numa.c | 442 +++++++++++++++++++++++++++++++ xen/include/xen/numa.h | 67 +++++ 9 files changed, 517 insertions(+), 492 deletions(-) create mode 100644 xen/common/numa.c diff --git a/xen/arch/x86/include/asm/acpi.h b/xen/arch/x86/include/asm/acp= i.h index 9a9cc4c240..5c2dd5da2d 100644 --- a/xen/arch/x86/include/asm/acpi.h +++ b/xen/arch/x86/include/asm/acpi.h @@ -102,7 +102,6 @@ extern unsigned long acpi_wakeup_address; #define ARCH_HAS_POWER_INIT 1 =20 extern s8 acpi_numa; -extern int acpi_scan_nodes(u64 start, u64 end); #define NR_NODE_MEMBLKS (MAX_NUMNODES*2) =20 extern struct acpi_sleep_info acpi_sinfo; diff --git a/xen/arch/x86/include/asm/numa.h b/xen/arch/x86/include/asm/num= a.h index 237f2c6dbf..6c87942d43 100644 --- a/xen/arch/x86/include/asm/numa.h +++ b/xen/arch/x86/include/asm/numa.h @@ -9,72 +9,17 @@ typedef u8 nodeid_t; =20 extern int srat_rev; =20 -extern nodeid_t cpu_to_node[NR_CPUS]; -extern cpumask_t node_to_cpumask[]; - -#define cpu_to_node(cpu) (cpu_to_node[cpu]) -#define parent_node(node) (node) -#define node_to_first_cpu(node) (__ffs(node_to_cpumask[node])) -#define node_to_cpumask(node) (node_to_cpumask[node]) - -struct node {=20 - paddr_t start, end; -}; - -extern int compute_hash_shift(struct node *nodes, int numnodes, - nodeid_t *nodeids); extern nodeid_t pxm_to_node(unsigned int pxm); =20 #define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT)) -#define VIRTUAL_BUG_ON(x)=20 =20 -extern void numa_add_cpu(int cpu); -extern void numa_init_array(void); -extern bool numa_off; - -extern int arch_numa_setup(const char *opt); -extern bool arch_numa_disabled(void); -extern bool srat_disabled(void); -extern void numa_set_node(int cpu, nodeid_t node); +extern bool numa_disabled(void); extern nodeid_t setup_node(unsigned int pxm); extern void srat_detect_node(int cpu); =20 -extern void setup_node_bootmem(nodeid_t nodeid, paddr_t start, paddr_t end= ); extern nodeid_t apicid_to_node[]; extern void init_cpu_to_node(void); =20 -static inline void clear_node_cpumask(int cpu) -{ - cpumask_clear_cpu(cpu, &node_to_cpumask[cpu_to_node(cpu)]); -} - -/* Simple perfect hash to map pdx to node numbers */ -extern int memnode_shift;=20 -extern unsigned long memnodemapsize; -extern u8 *memnodemap; - -struct node_data { - unsigned long node_start_pfn; - unsigned long node_spanned_pages; -}; - -extern struct node_data node_data[]; - -static inline __attribute__((pure)) nodeid_t phys_to_nid(paddr_t addr) -{=20 - nodeid_t nid; - VIRTUAL_BUG_ON((paddr_to_pdx(addr) >> memnode_shift) >=3D memnodemapsize); - nid =3D memnodemap[paddr_to_pdx(addr) >> memnode_shift];=20 - VIRTUAL_BUG_ON(nid >=3D MAX_NUMNODES || !node_data[nid]);=20 - return nid;=20 -}=20 - -#define NODE_DATA(nid) (&(node_data[nid])) - -#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) -#define node_spanned_pages(nid) (NODE_DATA(nid)->node_spanned_pages) -#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \ - NODE_DATA(nid)->node_spanned_pages) #define arch_want_default_dmazone() (num_online_nodes() > 1) =20 extern int valid_numa_range(paddr_t start, paddr_t end, nodeid_t node); diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index 21037b7f31..ae470ea12f 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -20,7 +20,6 @@ void early_time_init(void); =20 void set_nr_cpu_ids(unsigned int max_cpus); =20 -void numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn); void arch_init_memory(void); void subarch_init_memory(void); =20 diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c index a5bc7a78c9..90b2a22591 100644 --- a/xen/arch/x86/numa.c +++ b/xen/arch/x86/numa.c @@ -4,20 +4,11 @@ * Adapted for Xen: Ryan Harper */=20 =20 -#include -#include #include -#include +#include #include #include -#include -#include -#include -#include -#include #include -#include -#include =20 #ifndef Dprintk #define Dprintk(x...) @@ -26,28 +17,13 @@ /* from proto.h */ #define round_up(x,y) ((((x)+(y))-1) & (~((y)-1))) =20 -struct node_data node_data[MAX_NUMNODES]; - -/* Mapping from pdx to node id */ -int memnode_shift; -static typeof(*memnodemap) _memnodemap[64]; -unsigned long memnodemapsize; -u8 *memnodemap; - -nodeid_t cpu_to_node[NR_CPUS] __read_mostly =3D { - [0 ... NR_CPUS-1] =3D NUMA_NO_NODE -}; /* * Keep BIOS's CPU2node information, should not be used for memory allocai= on */ nodeid_t apicid_to_node[MAX_LOCAL_APIC] =3D { [0 ... MAX_LOCAL_APIC-1] =3D NUMA_NO_NODE }; -cpumask_t node_to_cpumask[MAX_NUMNODES] __read_mostly; =20 -nodemask_t __read_mostly node_online_map =3D { { [0] =3D 1UL } }; - -bool numa_off; s8 acpi_numa =3D 0; =20 int __init arch_numa_setup(const char *opt) @@ -69,267 +45,6 @@ bool arch_numa_disabled(void) return acpi_numa < 0; } =20 -bool srat_disabled(void) -{ - return numa_off || arch_numa_disabled(); -} - -/* - * Given a shift value, try to populate memnodemap[] - * Returns : - * 1 if OK - * 0 if memnodmap[] too small (of shift too small) - * -1 if node overlap or lost ram (shift too big) - */ -static int __init populate_memnodemap(const struct node *nodes, - int numnodes, int shift, nodeid_t *n= odeids) -{ - unsigned long spdx, epdx; - int i, res =3D -1; - - memset(memnodemap, NUMA_NO_NODE, memnodemapsize * sizeof(*memnodemap)); - for ( i =3D 0; i < numnodes; i++ ) - { - spdx =3D paddr_to_pdx(nodes[i].start); - epdx =3D paddr_to_pdx(nodes[i].end - 1) + 1; - if ( spdx >=3D epdx ) - continue; - if ( (epdx >> shift) >=3D memnodemapsize ) - return 0; - do { - if ( memnodemap[spdx >> shift] !=3D NUMA_NO_NODE ) - return -1; - - if ( !nodeids ) - memnodemap[spdx >> shift] =3D i; - else - memnodemap[spdx >> shift] =3D nodeids[i]; - - spdx +=3D (1UL << shift); - } while ( spdx < epdx ); - res =3D 1; - } - - return res; -} - -static int __init allocate_cachealigned_memnodemap(void) -{ - unsigned long size =3D PFN_UP(memnodemapsize * sizeof(*memnodemap)); - unsigned long mfn =3D mfn_x(alloc_boot_pages(size, 1)); - - memnodemap =3D mfn_to_virt(mfn); - mfn <<=3D PAGE_SHIFT; - size <<=3D PAGE_SHIFT; - printk(KERN_DEBUG "NUMA: Allocated memnodemap from %lx - %lx\n", - mfn, mfn + size); - memnodemapsize =3D size / sizeof(*memnodemap); - - return 0; -} - -/* - * The LSB of all start and end addresses in the node map is the value of = the - * maximum possible shift. - */ -static int __init extract_lsb_from_nodes(const struct node *nodes, - int numnodes) -{ - int i, nodes_used =3D 0; - unsigned long spdx, epdx; - unsigned long bitfield =3D 0, memtop =3D 0; - - for ( i =3D 0; i < numnodes; i++ ) - { - spdx =3D paddr_to_pdx(nodes[i].start); - epdx =3D paddr_to_pdx(nodes[i].end - 1) + 1; - if ( spdx >=3D epdx ) - continue; - bitfield |=3D spdx; - nodes_used++; - if ( epdx > memtop ) - memtop =3D epdx; - } - if ( nodes_used <=3D 1 ) - i =3D BITS_PER_LONG - 1; - else - i =3D find_first_bit(&bitfield, sizeof(unsigned long)*8); - memnodemapsize =3D (memtop >> i) + 1; - return i; -} - -int __init compute_hash_shift(struct node *nodes, int numnodes, - nodeid_t *nodeids) -{ - int shift; - - shift =3D extract_lsb_from_nodes(nodes, numnodes); - if ( memnodemapsize <=3D ARRAY_SIZE(_memnodemap) ) - memnodemap =3D _memnodemap; - else if ( allocate_cachealigned_memnodemap() ) - return -1; - printk(KERN_DEBUG "NUMA: Using %d for the hash shift.\n", shift); - - if ( populate_memnodemap(nodes, numnodes, shift, nodeids) !=3D 1 ) - { - printk(KERN_INFO "Your memory is not aligned you need to " - "rebuild your hypervisor with a bigger NODEMAPSIZE " - "shift=3D%d\n", shift); - return -1; - } - - return shift; -} -/* initialize NODE_DATA given nodeid and start/end */ -void __init setup_node_bootmem(nodeid_t nodeid, paddr_t start, paddr_t end) -{ - unsigned long start_pfn =3D paddr_to_pfn(start); - unsigned long end_pfn =3D paddr_to_pfn(end); - - NODE_DATA(nodeid)->node_start_pfn =3D start_pfn; - NODE_DATA(nodeid)->node_spanned_pages =3D end_pfn - start_pfn; - - node_set_online(nodeid); -}=20 - -void __init numa_init_array(void) -{ - int rr, i; - - /* There are unfortunately some poorly designed mainboards around - that only connect memory to a single CPU. This breaks the 1:1 cpu->= node - mapping. To avoid this fill in the mapping for all possible - CPUs, as the number of CPUs is not known yet. - We round robin the existing nodes. */ - rr =3D first_node(node_online_map); - for ( i =3D 0; i < nr_cpu_ids; i++ ) - { - if ( cpu_to_node[i] !=3D NUMA_NO_NODE ) - continue; - numa_set_node(i, rr); - rr =3D cycle_node(rr, node_online_map); - } -} - -#ifdef CONFIG_NUMA_EMU -static int numa_fake __initdata =3D 0; - -/* Numa emulation */ -static int __init numa_emulation(unsigned long start_pfn, - unsigned long end_pfn) -{ - int i; - struct node nodes[MAX_NUMNODES]; - uint64_t sz =3D pfn_to_paddr(end_pfn - start_pfn) / numa_fake; - - /* Kludge needed for the hash function */ - if ( hweight64(sz) > 1 ) - { - u64 x =3D 1; - while ( (x << 1) < sz ) - x <<=3D 1; - if ( x < sz/2 ) - printk(KERN_ERR "Numa emulation unbalanced. Complain to mainta= iner\n"); - sz =3D x; - } - - memset(&nodes,0,sizeof(nodes)); - for ( i =3D 0; i < numa_fake; i++ ) - { - nodes[i].start =3D pfn_to_paddr(start_pfn) + i * sz; - if ( i =3D=3D numa_fake - 1 ) - sz =3D pfn_to_paddr(end_pfn) - nodes[i].start; - nodes[i].end =3D nodes[i].start + sz; - printk(KERN_INFO "Faking node %d at %"PRIx64"-%"PRIx64" (%"PRIu64"= MB)\n", - i, - nodes[i].start, nodes[i].end, - (nodes[i].end - nodes[i].start) >> 20); - node_set_online(i); - } - memnode_shift =3D compute_hash_shift(nodes, numa_fake, NULL); - if ( memnode_shift < 0 ) - { - memnode_shift =3D 0; - printk(KERN_ERR "No NUMA hash function found. Emulation disabled.\= n"); - return -1; - } - for_each_online_node ( i ) - setup_node_bootmem(i, nodes[i].start, nodes[i].end); - numa_init_array(); - - return 0; -} -#endif - -void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_p= fn) -{=20 - int i; - paddr_t start =3D pfn_to_paddr(start_pfn); - paddr_t end =3D pfn_to_paddr(end_pfn); - -#ifdef CONFIG_NUMA_EMU - if ( numa_fake && !numa_emulation(start_pfn, end_pfn) ) - return; -#endif - -#ifdef CONFIG_ACPI_NUMA - if ( !numa_off && !acpi_scan_nodes(start, end) ) - return; -#endif - - printk(KERN_INFO "%s\n", - numa_off ? "NUMA turned off" : "No NUMA configuration found"); - - printk(KERN_INFO "Faking a node at %"PRIpaddr"-%"PRIpaddr"\n", - start, end); - /* setup dummy node covering all memory */ - memnode_shift =3D BITS_PER_LONG - 1; - memnodemap =3D _memnodemap; - /* Dummy node only uses 1 slot in reality */ - memnodemap[0] =3D 0; - memnodemapsize =3D 1; - - nodes_clear(node_online_map); - node_set_online(0); - for ( i =3D 0; i < nr_cpu_ids; i++ ) - numa_set_node(i, 0); - cpumask_copy(&node_to_cpumask[0], cpumask_of(0)); - setup_node_bootmem(0, start, end); -} - -void numa_add_cpu(int cpu) -{ - cpumask_set_cpu(cpu, &node_to_cpumask[cpu_to_node(cpu)]); -}=20 - -void numa_set_node(int cpu, nodeid_t node) -{ - cpu_to_node[cpu] =3D node; -} - -/* [numa=3Doff] */ -static int __init cf_check numa_setup(const char *opt) -{ - if ( !strncmp(opt, "off", 3) ) - numa_off =3D true; - else if ( !strncmp(opt, "on", 2) ) - numa_off =3D false; -#ifdef CONFIG_NUMA_EMU - else if ( !strncmp(opt, "fake=3D", 5) ) - { - numa_off =3D false; - numa_fake =3D simple_strtoul(opt + 5, NULL, 0); - if ( numa_fake >=3D MAX_NUMNODES ) - numa_fake =3D MAX_NUMNODES; - } -#endif - else - return arch_numa_setup(opt); - - return 0; -}=20 -custom_param("numa", numa_setup); - /* * Setup early cpu_to_node. * @@ -378,146 +93,3 @@ unsigned int __init arch_get_dma_bitsize(void) flsl(node_start_pfn(node) + node_spanned_pages(node) / 4 = - 1) + PAGE_SHIFT, 32); } - -static void cf_check dump_numa(unsigned char key) -{ - s_time_t now =3D NOW(); - unsigned int i, j, n; - struct domain *d; - struct page_info *page; - unsigned int page_num_node[MAX_NUMNODES]; - const struct vnuma_info *vnuma; - - printk("'%c' pressed -> dumping numa info (now =3D %"PRI_stime")\n", k= ey, - now); - - for_each_online_node ( i ) - { - paddr_t pa =3D pfn_to_paddr(node_start_pfn(i) + 1); - - printk("NODE%u start->%lu size->%lu free->%lu\n", - i, node_start_pfn(i), node_spanned_pages(i), - avail_node_heap_pages(i)); - /* sanity check phys_to_nid() */ - if ( phys_to_nid(pa) !=3D i ) - printk("phys_to_nid(%"PRIpaddr") -> %d should be %u\n", - pa, phys_to_nid(pa), i); - } - - j =3D cpumask_first(&cpu_online_map); - n =3D 0; - for_each_online_cpu ( i ) - { - if ( i !=3D j + n || cpu_to_node[j] !=3D cpu_to_node[i] ) - { - if ( n > 1 ) - printk("CPU%u...%u -> NODE%d\n", j, j + n - 1, cpu_to_node= [j]); - else - printk("CPU%u -> NODE%d\n", j, cpu_to_node[j]); - j =3D i; - n =3D 1; - } - else - ++n; - } - if ( n > 1 ) - printk("CPU%u...%u -> NODE%d\n", j, j + n - 1, cpu_to_node[j]); - else - printk("CPU%u -> NODE%d\n", j, cpu_to_node[j]); - - rcu_read_lock(&domlist_read_lock); - - printk("Memory location of each domain:\n"); - for_each_domain ( d ) - { - process_pending_softirqs(); - - printk("Domain %u (total: %u):\n", d->domain_id, domain_tot_pages(= d)); - - for_each_online_node ( i ) - page_num_node[i] =3D 0; - - spin_lock(&d->page_alloc_lock); - page_list_for_each(page, &d->page_list) - { - i =3D phys_to_nid(page_to_maddr(page)); - page_num_node[i]++; - } - spin_unlock(&d->page_alloc_lock); - - for_each_online_node ( i ) - printk(" Node %u: %u\n", i, page_num_node[i]); - - if ( !read_trylock(&d->vnuma_rwlock) ) - continue; - - if ( !d->vnuma ) - { - read_unlock(&d->vnuma_rwlock); - continue; - } - - vnuma =3D d->vnuma; - printk(" %u vnodes, %u vcpus, guest physical layout:\n", - vnuma->nr_vnodes, d->max_vcpus); - for ( i =3D 0; i < vnuma->nr_vnodes; i++ ) - { - unsigned int start_cpu =3D ~0U; - - if ( vnuma->vnode_to_pnode[i] =3D=3D NUMA_NO_NODE ) - printk(" %3u: pnode ???,", i); - else - printk(" %3u: pnode %3u,", i, vnuma->vnode_to_pnode[= i]); - - printk(" vcpus "); - - for ( j =3D 0; j < d->max_vcpus; j++ ) - { - if ( !(j & 0x3f) ) - process_pending_softirqs(); - - if ( vnuma->vcpu_to_vnode[j] =3D=3D i ) - { - if ( start_cpu =3D=3D ~0U ) - { - printk("%d", j); - start_cpu =3D j; - } - } - else if ( start_cpu !=3D ~0U ) - { - if ( j - 1 !=3D start_cpu ) - printk("-%d ", j - 1); - else - printk(" "); - start_cpu =3D ~0U; - } - } - - if ( start_cpu !=3D ~0U && start_cpu !=3D j - 1 ) - printk("-%d", j - 1); - - printk("\n"); - - for ( j =3D 0; j < vnuma->nr_vmemranges; j++ ) - { - if ( vnuma->vmemrange[j].nid =3D=3D i ) - printk(" %016"PRIx64" - %016"PRIx64"\n", - vnuma->vmemrange[j].start, - vnuma->vmemrange[j].end); - } - } - - read_unlock(&d->vnuma_rwlock); - } - - rcu_read_unlock(&domlist_read_lock); -} - -static int __init cf_check register_numa_trigger(void) -{ - register_keyhandler('u', dump_numa, "dump NUMA info", 1); - return 0; -} -__initcall(register_numa_trigger); - diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index b46fd9ab18..9df08e9366 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -1350,7 +1350,7 @@ int cpu_add(uint32_t apic_id, uint32_t acpi_id, uint3= 2_t pxm) =20 x86_acpiid_to_apicid[acpi_id] =3D apic_id; =20 - if ( !srat_disabled() ) + if ( !numa_disabled() ) { nodeid_t node =3D setup_node(pxm); =20 diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c index b62a152911..4c7f0c547e 100644 --- a/xen/arch/x86/srat.c +++ b/xen/arch/x86/srat.c @@ -238,7 +238,7 @@ acpi_numa_x2apic_affinity_init(const struct acpi_srat_x= 2apic_cpu_affinity *pa) unsigned pxm; nodeid_t node; =20 - if (srat_disabled()) + if (numa_disabled()) return; if (pa->header.length < sizeof(struct acpi_srat_x2apic_cpu_affinity)) { bad_srat(); @@ -274,7 +274,7 @@ acpi_numa_processor_affinity_init(const struct acpi_sra= t_cpu_affinity *pa) unsigned pxm; nodeid_t node; =20 - if (srat_disabled()) + if (numa_disabled()) return; if (pa->header.length !=3D sizeof(struct acpi_srat_cpu_affinity)) { bad_srat(); @@ -313,7 +313,7 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_m= em_affinity *ma) nodeid_t node; unsigned int i; =20 - if (srat_disabled()) + if (numa_disabled()) return; if (ma->header.length !=3D sizeof(struct acpi_srat_mem_affinity)) { bad_srat(); @@ -520,7 +520,7 @@ void __init srat_parse_regions(paddr_t addr) } =20 /* Use the information discovered above to actually set up the nodes. */ -int __init acpi_scan_nodes(paddr_t start, paddr_t end) +int __init numa_scan_nodes(paddr_t start, paddr_t end) { int i; nodemask_t all_nodes_parsed; diff --git a/xen/common/Makefile b/xen/common/Makefile index 3baf83d527..9a3a12b12d 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -26,6 +26,7 @@ obj-$(CONFIG_MEM_ACCESS) +=3D mem_access.o obj-y +=3D memory.o obj-y +=3D multicall.o obj-y +=3D notifier.o +obj-$(CONFIG_NUMA) +=3D numa.o obj-y +=3D page_alloc.o obj-$(CONFIG_HAS_PDX) +=3D pdx.o obj-$(CONFIG_PERF_COUNTERS) +=3D perfc.o diff --git a/xen/common/numa.c b/xen/common/numa.c new file mode 100644 index 0000000000..03e7318d72 --- /dev/null +++ b/xen/common/numa.c @@ -0,0 +1,442 @@ +/* + * Generic VM initialization for NUMA setups. + * Copyright 2002,2003 Andi Kleen, SuSE Labs. + * Adapted for Xen: Ryan Harper + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +struct node_data __ro_after_init node_data[MAX_NUMNODES]; + +/* Mapping from pdx to node id */ +unsigned int __ro_after_init memnode_shift; +unsigned long __ro_after_init memnodemapsize; +uint8_t *__ro_after_init memnodemap; +static uint8_t __ro_after_init _memnodemap[64]; + +nodeid_t __read_mostly cpu_to_node[NR_CPUS] =3D { + [0 ... NR_CPUS-1] =3D NUMA_NO_NODE +}; + +cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES]; + +nodemask_t __read_mostly node_online_map =3D { { [0] =3D 1UL } }; + +bool __read_mostly numa_off; + +bool numa_disabled(void) +{ + return numa_off || arch_numa_disabled(); +} + +/* + * Given a shift value, try to populate memnodemap[] + * Returns : + * 1 if OK + * 0 if memnodmap[] too small (of shift too small) + * -1 if node overlap or lost ram (shift too big) + */ +static int __init populate_memnodemap(const struct node *nodes, + unsigned int numnodes, unsigned int = shift, + nodeid_t *nodeids) +{ + unsigned long spdx, epdx; + unsigned int i; + int res =3D -1; + + memset(memnodemap, NUMA_NO_NODE, memnodemapsize * sizeof(*memnodemap)); + for ( i =3D 0; i < numnodes; i++ ) + { + spdx =3D paddr_to_pdx(nodes[i].start); + epdx =3D paddr_to_pdx(nodes[i].end - 1) + 1; + if ( spdx >=3D epdx ) + continue; + if ( (epdx >> shift) >=3D memnodemapsize ) + return 0; + do { + if ( memnodemap[spdx >> shift] !=3D NUMA_NO_NODE ) + return -1; + + if ( !nodeids ) + memnodemap[spdx >> shift] =3D i; + else + memnodemap[spdx >> shift] =3D nodeids[i]; + + spdx +=3D (1UL << shift); + } while ( spdx < epdx ); + res =3D 1; + } + + return res; +} + +static int __init allocate_cachealigned_memnodemap(void) +{ + unsigned long size =3D PFN_UP(memnodemapsize * sizeof(*memnodemap)); + unsigned long mfn =3D mfn_x(alloc_boot_pages(size, 1)); + + memnodemap =3D mfn_to_virt(mfn); + mfn <<=3D PAGE_SHIFT; + size <<=3D PAGE_SHIFT; + printk(KERN_DEBUG "NUMA: Allocated memnodemap from %lx - %lx\n", + mfn, mfn + size); + memnodemapsize =3D size / sizeof(*memnodemap); + + return 0; +} + +/* + * The LSB of all start and end addresses in the node map is the value of = the + * maximum possible shift. + */ +static unsigned int __init extract_lsb_from_nodes(const struct node *nodes, + nodeid_t numnodes) +{ + unsigned int i; + nodeid_t nodes_used =3D 0; + unsigned long spdx, epdx; + unsigned long bitfield =3D 0, memtop =3D 0; + + for ( i =3D 0; i < numnodes; i++ ) + { + spdx =3D paddr_to_pdx(nodes[i].start); + epdx =3D paddr_to_pdx(nodes[i].end - 1) + 1; + if ( spdx >=3D epdx ) + continue; + bitfield |=3D spdx; + nodes_used++; + if ( epdx > memtop ) + memtop =3D epdx; + } + if ( nodes_used <=3D 1 ) + i =3D BITS_PER_LONG - 1; + else + i =3D find_first_bit(&bitfield, sizeof(unsigned long)*8); + memnodemapsize =3D (memtop >> i) + 1; + return i; +} + +int __init compute_hash_shift(const struct node *nodes, + nodeid_t numnodes, nodeid_t *nodeids) +{ + unsigned int shift; + + shift =3D extract_lsb_from_nodes(nodes, numnodes); + if ( memnodemapsize <=3D ARRAY_SIZE(_memnodemap) ) + memnodemap =3D _memnodemap; + else if ( allocate_cachealigned_memnodemap() ) + return -1; + printk(KERN_DEBUG "NUMA: Using %d for the hash shift.\n", shift); + + if ( populate_memnodemap(nodes, numnodes, shift, nodeids) !=3D 1 ) + { + printk(KERN_INFO "Your memory is not aligned you need to " + "rebuild your hypervisor with a bigger NODEMAPSIZE " + "shift=3D%d\n", shift); + return -1; + } + + return shift; +} + +/* initialize NODE_DATA given nodeid and start/end */ +void __init setup_node_bootmem(nodeid_t nodeid, paddr_t start, paddr_t end) +{ + unsigned long start_pfn =3D paddr_to_pfn(start); + unsigned long end_pfn =3D paddr_to_pfn(end); + + NODE_DATA(nodeid)->node_start_pfn =3D start_pfn; + NODE_DATA(nodeid)->node_spanned_pages =3D end_pfn - start_pfn; + + node_set_online(nodeid); +} + +void __init numa_init_array(void) +{ + unsigned int i; + nodeid_t rr; + + /* + * There are unfortunately some poorly designed mainboards around + * that only connect memory to a single CPU. This breaks the 1:1 cpu->= node + * mapping. To avoid this fill in the mapping for all possible + * CPUs, as the number of CPUs is not known yet. + * We round robin the existing nodes. + */ + rr =3D first_node(node_online_map); + for ( i =3D 0; i < nr_cpu_ids; i++ ) + { + if ( cpu_to_node[i] !=3D NUMA_NO_NODE ) + continue; + numa_set_node(i, rr); + rr =3D cycle_node(rr, node_online_map); + } +} + +#ifdef CONFIG_NUMA_EMU +static unsigned int __initdata numa_fake; + +/* Numa emulation */ +static int __init numa_emulation(unsigned long start_pfn, + unsigned long end_pfn) +{ + unsigned int i; + struct node nodes[MAX_NUMNODES]; + uint64_t sz =3D pfn_to_paddr(end_pfn - start_pfn) / numa_fake; + + /* Kludge needed for the hash function */ + if ( hweight64(sz) > 1 ) + { + uint64_t x =3D 1; + + while ( (x << 1) < sz ) + x <<=3D 1; + if ( x < sz / 2 ) + printk(KERN_ERR "Numa emulation unbalanced. Complain to mainta= iner\n"); + sz =3D x; + } + + memset(&nodes, 0, sizeof(nodes)); + for ( i =3D 0; i < numa_fake; i++ ) + { + nodes[i].start =3D pfn_to_paddr(start_pfn) + i * sz; + if ( i =3D=3D numa_fake - 1 ) + sz =3D pfn_to_paddr(end_pfn) - nodes[i].start; + nodes[i].end =3D nodes[i].start + sz; + printk(KERN_INFO "Faking node %u at %"PRIx64"-%"PRIx64" (%"PRIu64"= MB)\n", + i, nodes[i].start, nodes[i].end, + (nodes[i].end - nodes[i].start) >> 20); + node_set_online(i); + } + memnode_shift =3D compute_hash_shift(nodes, numa_fake, NULL); + if ( memnode_shift < 0 ) + { + memnode_shift =3D 0; + printk(KERN_ERR "No NUMA hash function found. Emulation disabled.\= n"); + return -1; + } + for_each_online_node ( i ) + setup_node_bootmem(i, nodes[i].start, nodes[i].end); + numa_init_array(); + + return 0; +} +#endif + +void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_p= fn) +{ + unsigned int i; + paddr_t start =3D pfn_to_paddr(start_pfn); + paddr_t end =3D pfn_to_paddr(end_pfn); + +#ifdef CONFIG_NUMA_EMU + if ( numa_fake && !numa_emulation(start_pfn, end_pfn) ) + return; +#endif + +#ifdef CONFIG_NUMA + if ( !numa_off && !numa_scan_nodes(start, end) ) + return; +#endif + + printk(KERN_INFO "%s\n", + numa_off ? "NUMA turned off" : "No NUMA configuration found"); + + printk(KERN_INFO "Faking a node at %"PRIpaddr"-%"PRIpaddr"\n", + start, end); + /* setup dummy node covering all memory */ + memnode_shift =3D BITS_PER_LONG - 1; + memnodemap =3D _memnodemap; + /* Dummy node only uses 1 slot in reality */ + memnodemap[0] =3D 0; + memnodemapsize =3D 1; + + nodes_clear(node_online_map); + node_set_online(0); + for ( i =3D 0; i < nr_cpu_ids; i++ ) + numa_set_node(i, 0); + cpumask_copy(&node_to_cpumask[0], cpumask_of(0)); + setup_node_bootmem(0, start, end); +} + +void numa_add_cpu(unsigned int cpu) +{ + cpumask_set_cpu(cpu, &node_to_cpumask[cpu_to_node(cpu)]); +} + +void numa_set_node(unsigned int cpu, nodeid_t node) +{ + cpu_to_node[cpu] =3D node; +} + +/* [numa=3Doff] */ +static int __init cf_check numa_setup(const char *opt) +{ + if ( !strncmp(opt, "off", 3) ) + numa_off =3D true; + else if ( !strncmp(opt, "on", 2) ) + numa_off =3D false; +#ifdef CONFIG_NUMA_EMU + else if ( !strncmp(opt, "fake=3D", 5) ) + { + numa_off =3D false; + numa_fake =3D simple_strtoul(opt + 5, NULL, 0); + if ( numa_fake >=3D MAX_NUMNODES ) + numa_fake =3D MAX_NUMNODES; + } +#endif + else + return arch_numa_setup(opt); + + return 0; +} +custom_param("numa", numa_setup); + +static void cf_check dump_numa(unsigned char key) +{ + s_time_t now =3D NOW(); + unsigned int i, j, n; + struct domain *d; + struct page_info *page; + unsigned int page_num_node[MAX_NUMNODES]; + const struct vnuma_info *vnuma; + + printk("'%c' pressed -> dumping numa info (now =3D %"PRI_stime")\n", k= ey, + now); + + for_each_online_node ( i ) + { + paddr_t pa =3D pfn_to_paddr(node_start_pfn(i) + 1); + + printk("NODE%u start->%lu size->%lu free->%lu\n", + i, node_start_pfn(i), node_spanned_pages(i), + avail_node_heap_pages(i)); + /* sanity check phys_to_nid() */ + if ( phys_to_nid(pa) !=3D i ) + printk("phys_to_nid(%"PRIpaddr") -> %d should be %u\n", + pa, phys_to_nid(pa), i); + } + + j =3D cpumask_first(&cpu_online_map); + n =3D 0; + for_each_online_cpu ( i ) + { + if ( i !=3D j + n || cpu_to_node[j] !=3D cpu_to_node[i] ) + { + if ( n > 1 ) + printk("CPU%u...%u -> NODE%d\n", j, j + n - 1, cpu_to_node= [j]); + else + printk("CPU%u -> NODE%d\n", j, cpu_to_node[j]); + j =3D i; + n =3D 1; + } + else + ++n; + } + if ( n > 1 ) + printk("CPU%u...%u -> NODE%d\n", j, j + n - 1, cpu_to_node[j]); + else + printk("CPU%u -> NODE%d\n", j, cpu_to_node[j]); + + rcu_read_lock(&domlist_read_lock); + + printk("Memory location of each domain:\n"); + for_each_domain ( d ) + { + process_pending_softirqs(); + + printk("Domain %u (total: %u):\n", d->domain_id, domain_tot_pages(= d)); + + for_each_online_node ( i ) + page_num_node[i] =3D 0; + + spin_lock(&d->page_alloc_lock); + page_list_for_each(page, &d->page_list) + { + i =3D phys_to_nid(page_to_maddr(page)); + page_num_node[i]++; + } + spin_unlock(&d->page_alloc_lock); + + for_each_online_node ( i ) + printk(" Node %u: %u\n", i, page_num_node[i]); + + if ( !read_trylock(&d->vnuma_rwlock) ) + continue; + + if ( !d->vnuma ) + { + read_unlock(&d->vnuma_rwlock); + continue; + } + + vnuma =3D d->vnuma; + printk(" %u vnodes, %u vcpus, guest physical layout:\n", + vnuma->nr_vnodes, d->max_vcpus); + for ( i =3D 0; i < vnuma->nr_vnodes; i++ ) + { + unsigned int start_cpu =3D ~0U; + + if ( vnuma->vnode_to_pnode[i] =3D=3D NUMA_NO_NODE ) + printk(" %3u: pnode ???,", i); + else + printk(" %3u: pnode %3u,", i, vnuma->vnode_to_pnode[= i]); + + printk(" vcpus "); + + for ( j =3D 0; j < d->max_vcpus; j++ ) + { + if ( !(j & 0x3f) ) + process_pending_softirqs(); + + if ( vnuma->vcpu_to_vnode[j] =3D=3D i ) + { + if ( start_cpu =3D=3D ~0U ) + { + printk("%d", j); + start_cpu =3D j; + } + } + else if ( start_cpu !=3D ~0U ) + { + if ( j - 1 !=3D start_cpu ) + printk("-%d ", j - 1); + else + printk(" "); + start_cpu =3D ~0U; + } + } + + if ( start_cpu !=3D ~0U && start_cpu !=3D j - 1 ) + printk("-%d", j - 1); + + printk("\n"); + + for ( j =3D 0; j < vnuma->nr_vmemranges; j++ ) + { + if ( vnuma->vmemrange[j].nid =3D=3D i ) + printk(" %016"PRIx64" - %016"PRIx64"\n", + vnuma->vmemrange[j].start, + vnuma->vmemrange[j].end); + } + } + + read_unlock(&d->vnuma_rwlock); + } + + rcu_read_unlock(&domlist_read_lock); +} + +static int __init cf_check register_numa_trigger(void) +{ + register_keyhandler('u', dump_numa, "dump NUMA info", 1); + return 0; +} +__initcall(register_numa_trigger); diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h index 7aef1a88dc..baef4cd553 100644 --- a/xen/include/xen/numa.h +++ b/xen/include/xen/numa.h @@ -18,4 +18,71 @@ (((d)->vcpu !=3D NULL && (d)->vcpu[0] !=3D NULL) \ ? vcpu_to_node((d)->vcpu[0]) : NUMA_NO_NODE) =20 +/* The following content can be used when NUMA feature is enabled */ +#ifdef CONFIG_NUMA + +extern nodeid_t cpu_to_node[NR_CPUS]; +extern cpumask_t node_to_cpumask[]; + +#define cpu_to_node(cpu) cpu_to_node[cpu] +#define parent_node(node) (node) +#define node_to_first_cpu(node) __ffs(node_to_cpumask[node]) +#define node_to_cpumask(node) node_to_cpumask[node] + +struct node { + paddr_t start, end; +}; + +extern int compute_hash_shift(const struct node *nodes, + nodeid_t numnodes, nodeid_t *nodeids); + +#define VIRTUAL_BUG_ON(x) + +extern bool numa_off; + +extern void numa_add_cpu(unsigned int cpu); +extern void numa_init_array(void); +extern void numa_set_node(unsigned int cpu, nodeid_t node); +extern void numa_initmem_init(unsigned long start_pfn, unsigned long end_p= fn); +extern int numa_scan_nodes(paddr_t start, paddr_t end); + +extern int arch_numa_setup(const char *opt); +extern bool arch_numa_disabled(void); +extern void setup_node_bootmem(nodeid_t nodeid, paddr_t start, paddr_t end= ); + +static inline void clear_node_cpumask(unsigned int cpu) +{ + cpumask_clear_cpu(cpu, &node_to_cpumask[cpu_to_node(cpu)]); +} + +/* Simple perfect hash to map pdx to node numbers */ +extern unsigned int memnode_shift; +extern unsigned long memnodemapsize; +extern uint8_t *memnodemap; + +struct node_data { + unsigned long node_start_pfn; + unsigned long node_spanned_pages; +}; + +extern struct node_data node_data[]; + +static inline nodeid_t __attribute_pure__ phys_to_nid(paddr_t addr) +{ + nodeid_t nid; + VIRTUAL_BUG_ON((paddr_to_pdx(addr) >> memnode_shift) >=3D memnodemapsi= ze); + nid =3D memnodemap[paddr_to_pdx(addr) >> memnode_shift]; + VIRTUAL_BUG_ON(nid >=3D MAX_NUMNODES || !node_data[nid]); + return nid; +} + +#define NODE_DATA(nid) (&node_data[nid]) + +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) +#define node_spanned_pages(nid) (NODE_DATA(nid)->node_spanned_pages) +#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \ + NODE_DATA(nid)->node_spanned_pages) + +#endif + #endif /* _XEN_NUMA_H */ --=20 2.25.1 From nobody Fri May 17 01:43:39 2024 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=2 dmarc=pass fromdomain=arm.com); dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=3; a=rsa-sha256; t=1662089542; cv=pass; d=zohomail.com; s=zohoarc; b=fHXjwaKeL51Y0mA0T0E+z1ChEDESWOnc0xFZkC3h51tDYWJIrEfBbiuBOPexKLPAp20DvDMtd5iSXEK+k1B+n/U+lrTjBqfNyimhE8dw7tKeWfiunhqWEd+1OJooBgd0WZiviW3vxiqq+EnjEUW+ey4vJOOHKzaZtxZBBR1WXdo= ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662089542; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p8Uwp6+nNlC0JAJBM8aB8Lyt4DmvZi8C88afoGTR6cA=; b=TrZCxIMPbHf+YYDvD8NGHRcUZkKF59g6gdO17PmgmOJHmlutQIaFD6WvLHW4B+jwkIy474xfn1Z63AUVPX5hIspqsAxlkRUPmBkw0axsMilmCYsqvesexFb5zTtEDnSWBoxz1p6GinhOMIXcPogZ0BrLyoXTATgnsNeahXTiCTE= ARC-Authentication-Results: i=3; 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=2 dmarc=pass fromdomain=arm.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1662089542876985.2609393209624; Thu, 1 Sep 2022 20:32:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.397242.637760 (Exim 4.92) (envelope-from ) id 1oTxPZ-00050U-5E; Fri, 02 Sep 2022 03:32:05 +0000 Received: by outflank-mailman (output) from mailman id 397242.637760; Fri, 02 Sep 2022 03:32:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTxPY-0004y0-WD; Fri, 02 Sep 2022 03:32:05 +0000 Received: by outflank-mailman (input) for mailman id 397242; Fri, 02 Sep 2022 03:32:03 +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 1oTxPX-0004Wz-BY for xen-devel@lists.xenproject.org; Fri, 02 Sep 2022 03:32:03 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70078.outbound.protection.outlook.com [40.107.7.78]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cf29d2fd-2a6f-11ed-934f-f50d60e1c1bd; Fri, 02 Sep 2022 05:32:02 +0200 (CEST) Received: from DB6PR0201CA0026.eurprd02.prod.outlook.com (2603:10a6:4:3f::36) by AM9PR08MB6642.eurprd08.prod.outlook.com (2603:10a6:20b:2ff::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Fri, 2 Sep 2022 03:31:59 +0000 Received: from DBAEUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:3f:cafe::b0) by DB6PR0201CA0026.outlook.office365.com (2603:10a6:4:3f::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.14 via Frontend Transport; Fri, 2 Sep 2022 03:31:59 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT025.mail.protection.outlook.com (100.127.142.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:31:59 +0000 Received: ("Tessian outbound 63c09d5d38ac:v123"); Fri, 02 Sep 2022 03:31:59 +0000 Received: from 02871d7c7b46.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 205AAEA6-0047-483B-B2A4-59D5C8FBA078.1; Fri, 02 Sep 2022 03:31:53 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 02871d7c7b46.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 02 Sep 2022 03:31:53 +0000 Received: from DB6PR07CA0052.eurprd07.prod.outlook.com (2603:10a6:6:2a::14) by AS8PR08MB8490.eurprd08.prod.outlook.com (2603:10a6:20b:567::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Fri, 2 Sep 2022 03:31:50 +0000 Received: from DBAEUR03FT043.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2a:cafe::d2) by DB6PR07CA0052.outlook.office365.com (2603:10a6:6:2a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.5 via Frontend Transport; Fri, 2 Sep 2022 03:31:50 +0000 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT043.mail.protection.outlook.com (100.127.143.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:31:50 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2507.9; Fri, 2 Sep 2022 03:31:50 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.9; Fri, 2 Sep 2022 03:31:49 +0000 Received: from ais-wip-ds.shanghai.arm.com (10.169.190.86) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.9 via Frontend Transport; Fri, 2 Sep 2022 03:31:45 +0000 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: cf29d2fd-2a6f-11ed-934f-f50d60e1c1bd ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=ShlnwG+b8zbpZNncZipqcLCfRgqI5XneJ5iEtA5TLwtZhXMMyJipbAPaMZy10JG+JKyFywBqq66cx1/rrHw0GhP5MJQ+1Q3R6AF0Fl3Yto/GtCMeiNrhT4mtCz/+z3r2Y9UR2N4JUsOzYLIjtUh3fgtNMxKTIAG0bL06bu+RX0RD0oMDiIHuuUU7q339YJ4g9aFfDEGGdJ79TLWYa1CK2ryIRzsmYC8vU4peq337XGBAKovOXIT64ErR4qRQRaVRuz5JrLgZWAoByxueOHhArL74Y1DbTAnf4qyzg8EYpKSkthvz6e/UVOvtJxMhNUPqOQgWevU4VgcVKwm7jcl3Tw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=p8Uwp6+nNlC0JAJBM8aB8Lyt4DmvZi8C88afoGTR6cA=; b=Nm8RkcidI6bOg5wy+UIdGvM5kyKStFNXPFVZBjYb4NJlmyVvEmN00YOIiKmxTmEwvPquJDsF8nIv+4iCqUbDFNuESNQivCQHt4H+oiOAsPBG1RJQe4QASIJ7Xviaew1LSXb2U5gsdk0oPa1jmMKmQzFyPFSXw2YfcPk5x4qBZSgdVXPMalkEz9DrhAsWCK/JIS0rbYwSE4mn9hrIq0jVph5+nr+0YaCvwqGgrSHi3hHzChNqqrHEYsiWoffqUwiee5Q3XN+3jRRQwj92wcQgblb1z3pk5hXvbj4vVUvEM0bUmYxXwXVsBm3SYvU/jHYBeELVYZwfOMA1oI1nTF2kVw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p8Uwp6+nNlC0JAJBM8aB8Lyt4DmvZi8C88afoGTR6cA=; b=a5X29prkA/1jpbKfEoe/jDTxx4tq4pdxInUzmpjU/HdQVzvzEjKxb2xy5R1BDNXKxlUs++HJhyw67f4kOFMsAKR0QtmU8XNLCsvqW1lxIrrsQc8pypWAPKMvuUiRksNe3EPakcufZi7hEH523F0WH7b/wioaF0C59pLG6AicZtk= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.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 arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C X-CheckRecipientChecked: true X-CR-MTA-CID: f1890f22cd6330db X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RJEylBXXaGPmRlgU+fDnPbI5sGLGlqiY66gCfMAbxQxtZa/E/0pgpqm0vnOuT5G+JYnZeYDcREvrYB2wvIdEftbaUuZMbv3DcCilVqPQEqALS1bQXxHGqjnPj/XdWtEgLc9FamDEzj4bjdDuPyDQRv9AJ1Mpqvsh/uxEejkPqCp441I3Q0+9+PIAbpSwf/YGV7lkSnwlQRNYaIrnvXJMVsVC/cGJRBh8THeghEUcQqBNFYB0TCozlnK121XlXXisJiNkQb5MQcnAYxHDyOSXjW9uzXMzIyIeKodCfOD0tJK/VCsWLJdo7rAtMI3n7Of4aAqzzzgp7pOdfaZjW77+xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=p8Uwp6+nNlC0JAJBM8aB8Lyt4DmvZi8C88afoGTR6cA=; b=J86Tu2GnjgXH2HWIQj5B6Bq4D8n5hwFxYayq6DdqxeyHAyYijn3o4BqSkNEOriaPmiUu6+0G1HlcGRNR4cGvm0/+Y/8VQ5x/FHdsBa041vXaNju86DmzbmDU/oDRZKQNReQ092JLZYJJ+S6iZnzTfMPk01Bf6ak7evfezpJ3VWeggo6rmInNmVxu2470SDE+oZqNVgCgl2y7WZ6sqLODavC6guUxrosWXLn8QM9BNbXc+8n7+a8Rz9AXPWHomExEajq/W/zzWLGlJc+/olrh24sn2zJeV6V5b6Zj/RPtkJtYWwSPhwF0Jhw+3QlhvICdtdJhXj6HdlUv5G/U/ZpS2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p8Uwp6+nNlC0JAJBM8aB8Lyt4DmvZi8C88afoGTR6cA=; b=a5X29prkA/1jpbKfEoe/jDTxx4tq4pdxInUzmpjU/HdQVzvzEjKxb2xy5R1BDNXKxlUs++HJhyw67f4kOFMsAKR0QtmU8XNLCsvqW1lxIrrsQc8pypWAPKMvuUiRksNe3EPakcufZi7hEH523F0WH7b/wioaF0C59pLG6AicZtk= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C From: Wei Chen To: CC: , Wei Chen , Andrew Cooper , George Dunlap , "Jan Beulich" , Julien Grall , "Stefano Stabellini" , Wei Liu , Jiamei Xie Subject: [PATCH v4 3/6] xen/x86: Use ASSERT instead of VIRTUAL_BUG_ON for phys_to_nid Date: Fri, 2 Sep 2022 11:31:18 +0800 Message-ID: <20220902033121.540328-4-wei.chen@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902033121.540328-1-wei.chen@arm.com> References: <20220902033121.540328-1-wei.chen@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 2ab30867-705c-4176-f435-08da8c93b1b6 X-MS-TrafficTypeDiagnostic: AS8PR08MB8490:EE_|DBAEUR03FT025:EE_|AM9PR08MB6642:EE_ x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: T3PBpuTx8nk8FTkjrCL5aA8JMO5gHizsOhGLk0weIMimA8O1/hBKxAYDVtug+HfRa2+1p9JEIYXnKQcbdXjofLSVFivqVK3eJpxACgX+fz5STyfww9/QbIJyYE4eEIqH71/UlTQwcwsnMmE68BFzdLpsmK+9x1qzZFdcqGCDwUYo5iOuqo50fA1T+bdmTVf4hmi/JpnFhqZ2dgPjmnlCWWBbKAdeEmRtT/UOASHi4ERG95wf9vTQY3TyURR4A7GNllzgyM5caZB9XAYi4QO3CeydLMAc2mQIiEn+d/ugjUxZ+1IfU6FQK1zCcJwZGY129YUiCpvN4hNxYd8KmG9aG9WD8wh1L9W9GWSxR87xnGo7r0kM6qxK+4xMfz1MWbMB2EiNobv6OSoRGlnT1nLuqqRzsqTj+0qztTHdcbDBEYF+rgku+Yi0z7N7lGI/Ub52ymbPUA0B2G5r0CcD6voJwg8gtevHEcHRSePZNO3uiPR7LnI9wCBkk5R5UHEvkBPWcuZttSMPDWRgHHVJ+RFxDoKjzLDlrtjPQAV/5sdbRWvYOGerpYZMe8rFamNq9/uVxzzWlH17jF+oCPlApO7okxSRiCOpyLPKzE775svq2zx/LWVQJTZDTr0jAs6OvkzIn4zglVN4GcOBIKMenuTbJRx/6zHhO7tCxiuPOrbufJNOzM/o8Z5tUEfNinR+4/i/h+3FSj+1ZsgUd7FznbPHT5dHPmBheEuFIaiAYFxW7mMbu/ZEmCg4wjwp3OlKE9VJYm1g9lONsUYwgU4ZNourarGvsZtQRpiYWQ2JOU0bhp19ApydEt+HtmKXbkPp7RoI X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(346002)(396003)(136003)(39860400002)(376002)(40470700004)(36840700001)(46966006)(86362001)(26005)(426003)(8936002)(1076003)(40480700001)(7696005)(2906002)(44832011)(5660300002)(47076005)(186003)(36756003)(41300700001)(6666004)(2616005)(478600001)(336012)(356005)(8676002)(81166007)(83380400001)(82310400005)(36860700001)(54906003)(4326008)(70586007)(6916009)(40460700003)(70206006)(82740400003)(316002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8490 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2ef1b529-e9bd-4c8f-a242-08da8c93ac47 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +YlNvsYQ3cIlGUPp/braoFVDdcuWvSrGfQZp4EJLml8psDOPmXtBTm1tEUlyj6Gf8aV0WUF+D1J8hW82Hcj0eTEUjIh7tR2rL7joHkNnAlEPi73lmc+vK+6q6FmGkxmLpRXLGUF0nd6vR9rHZIE2LNwZd6bzMS0oI6AEOPjEwOLUwFv3fNmAOIYw15o5uFlAvV4ULcgXHc6UeXDoFRGzMZ7M2D7HuT1ZtpVtGgb6mKgPqeDkb8fhR4PTxupZ8nfNk5LcNHzAgzW6XMYwv561KqxsL+r4XeCJIxjYQybR3cjv8EFFByRsBn0tmCjF6r4nKVeuWuaFmNl7aRvH2HPflv14Nfvc81yxG19qXlCrNppY5bDA0m5JB5Em9lqRT7CA9q2JxvXPHK1VBX23rCMsedsmontHfrf44iR3dg9p4EPmrb81n2+CA4AS74vvUZ0JPBimP4OcVX5K/+MnmvqQr4/oHV9jrxADXfBJYb9UWbGvssGhil9ZsUe2NCEzjtXAIglwjd15BUK+ocioOc+tJVIgurgomkgiiRMgHYZd8qihc+km2ym7G/+QNBf+WoixturODuVRU9BvPGj1IVo9GsFWr5RkoY/PadCQXQD/gzmIdsjH6LLTOwVo7e8HfpKspQeEhBW1/kpFtu4H1G6MU/P3DSsDxPQJeSeEBfbwe1RsJEFRcjnsNsMdRQUxAM/3FpJtt3OVlQ0VP1XHt2IG+QDfX8epd10Y4/PFn7qktGwTKq+DD3fyZm7JSlPxZ38pPFFEW57iPtbb+1Z/CSJ2zA== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230016)(4636009)(376002)(136003)(39860400002)(396003)(346002)(46966006)(36840700001)(40470700004)(54906003)(6916009)(26005)(2906002)(44832011)(40460700003)(36860700001)(82310400005)(36756003)(316002)(478600001)(70206006)(70586007)(5660300002)(82740400003)(81166007)(41300700001)(40480700001)(86362001)(1076003)(426003)(336012)(47076005)(7696005)(2616005)(83380400001)(4326008)(186003)(8936002)(6666004)(8676002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2022 03:31:59.5828 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2ab30867-705c-4176-f435-08da8c93b1b6 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6642 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1662089543946100001 Content-Type: text/plain; charset="utf-8" VIRTUAL_BUG_ON is an empty macro used in phys_to_nid. This results in two lines of error-checking code in phys_to_nid that is not actually working and causing two compilation errors: 1. error: "MAX_NUMNODES" undeclared (first use in this function). This is because in the common header file, "MAX_NUMNODES" is defined after the common header file includes the ARCH header file, where phys_to_nid has attempted to use "MAX_NUMNODES". This error was resolved after we moved the phys_to_nid from x86 ARCH header file to common header file. 2. error: wrong type argument to unary exclamation mark. This is because, the error-checking code contains !node_data[nid]. But node_data is a data structure variable, it's not a pointer. So, in this patch, we use ASSERT instead of VIRTUAL_BUG_ON to enable the two lines of error-checking code. And fix the left compilation errors by replacing !node_data[nid] to !node_data[nid].node_spanned_pages. Although NUMA allows one node can only have CPUs but without any memory. And node with 0 bytes of memory might have an entry in memnodemap[] theoretically. But that doesn't mean phys_to_nid can find any valid address from a node with 0 bytes memory. Signed-off-by: Wei Chen Tested-by: Jiamei Xie Acked-by: Jan Beulich --- v3 -> v4: no change. v2 -> v3: 1. Remove unnecessary change items in history. 2. Add Acked-by. v1 -> v2: 1. Use ASSERT to replace VIRTUAL_BUG_ON in phys_to_nid. 2. Adjust the conditional express for ASSERT. 3. Refine the justification of using !node_data[nid].node_spanned_pages. --- xen/include/xen/numa.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h index baef4cd553..af0abfc8cf 100644 --- a/xen/include/xen/numa.h +++ b/xen/include/xen/numa.h @@ -36,8 +36,6 @@ struct node { extern int compute_hash_shift(const struct node *nodes, nodeid_t numnodes, nodeid_t *nodeids); =20 -#define VIRTUAL_BUG_ON(x) - extern bool numa_off; =20 extern void numa_add_cpu(unsigned int cpu); @@ -70,9 +68,9 @@ extern struct node_data node_data[]; static inline nodeid_t __attribute_pure__ phys_to_nid(paddr_t addr) { nodeid_t nid; - VIRTUAL_BUG_ON((paddr_to_pdx(addr) >> memnode_shift) >=3D memnodemapsi= ze); + ASSERT((paddr_to_pdx(addr) >> memnode_shift) < memnodemapsize); nid =3D memnodemap[paddr_to_pdx(addr) >> memnode_shift]; - VIRTUAL_BUG_ON(nid >=3D MAX_NUMNODES || !node_data[nid]); + ASSERT(nid < MAX_NUMNODES && node_data[nid].node_spanned_pages); return nid; } =20 --=20 2.25.1 From nobody Fri May 17 01:43:39 2024 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=2 dmarc=pass fromdomain=arm.com); dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=3; a=rsa-sha256; t=1662089550; cv=pass; d=zohomail.com; s=zohoarc; b=YiL90QRTw/ewDAbGUgXm1lDf4vgeBJZdGBfTuyN0smZ85SUdItsyWWDsPe3Nhr//c4vDWRYMBAIpyRA/UEZpSZhOA8XDkBpoTkbpyHBtyCOZrk+kF84UAzzjY4sxjDApptLXoBiyKqcCL7J2WoVCdGMjUvloaTWTQnJOZQ+xVdk= ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662089550; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3rJl4bvG5P28lwjcobHRthLqJO4TGcF+IiJpvc5pSCc=; b=OXysu3YETqZ0PWluePww3HlCbnXH1Bcxsf40yvDOhQaWXt7iNftPVpRXHKfSz8uREYLqZ27qL0Cdu3M74OCl3yyS2gKxq/gZgMjaK9hZOpyr198uappEsBhyjbNspU8Xa6d70FZKV6njg7rogEaPkeChRvviAan+IOEaBHgWdWE= ARC-Authentication-Results: i=3; 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=2 dmarc=pass fromdomain=arm.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1662089550005456.2276816013747; Thu, 1 Sep 2022 20:32:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.397243.637776 (Exim 4.92) (envelope-from ) id 1oTxPf-0005Yr-Cu; Fri, 02 Sep 2022 03:32:11 +0000 Received: by outflank-mailman (output) from mailman id 397243.637776; Fri, 02 Sep 2022 03:32: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 1oTxPf-0005Ye-9R; Fri, 02 Sep 2022 03:32:11 +0000 Received: by outflank-mailman (input) for mailman id 397243; Fri, 02 Sep 2022 03:32:09 +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 1oTxPd-0004Wz-C7 for xen-devel@lists.xenproject.org; Fri, 02 Sep 2022 03:32:09 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60048.outbound.protection.outlook.com [40.107.6.48]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d266de92-2a6f-11ed-934f-f50d60e1c1bd; Fri, 02 Sep 2022 05:32:08 +0200 (CEST) Received: from AM7PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:20b:110::28) by GV2PR08MB8654.eurprd08.prod.outlook.com (2603:10a6:150:b6::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Fri, 2 Sep 2022 03:32:04 +0000 Received: from AM7EUR03FT042.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:110:cafe::f2) by AM7PR04CA0018.outlook.office365.com (2603:10a6:20b:110::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.14 via Frontend Transport; Fri, 2 Sep 2022 03:32:04 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT042.mail.protection.outlook.com (100.127.140.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:32:03 +0000 Received: ("Tessian outbound fa99bf31ee7d:v123"); Fri, 02 Sep 2022 03:32:03 +0000 Received: from 8e115e350a08.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7C8400A7-3BB1-4017-8661-2C108810F8C9.1; Fri, 02 Sep 2022 03:31:56 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 8e115e350a08.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 02 Sep 2022 03:31:56 +0000 Received: from DB6PR0601CA0042.eurprd06.prod.outlook.com (2603:10a6:4:17::28) by AS8PR08MB6408.eurprd08.prod.outlook.com (2603:10a6:20b:33a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.11; Fri, 2 Sep 2022 03:31:55 +0000 Received: from DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:17:cafe::77) by DB6PR0601CA0042.outlook.office365.com (2603:10a6:4:17::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:31:55 +0000 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT040.mail.protection.outlook.com (100.127.142.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:31:54 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.9; Fri, 2 Sep 2022 03:31:53 +0000 Received: from ais-wip-ds.shanghai.arm.com (10.169.190.86) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.9 via Frontend Transport; Fri, 2 Sep 2022 03:31:50 +0000 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: d266de92-2a6f-11ed-934f-f50d60e1c1bd ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=CPEs1MKbh+DII0mmCVBppGkLwQBgm2/lNzzemOeMh9zte5bUZnBfAToU4pyVyHT5k8MoXFDwtpjTFCLElKx00Lqr3tmxvJxd7AlcrvTZMMKopc2yOutCbTe0L6QMgGoIUQtSeI/Fu0K8o4hqJNI7soBj+lU2Zd2SgHnMewbjsc++dfHwplTQHa1B3QblSkO/YC+f/rSKjVCXEtoWtjzY+ddJ8ZwCW5wQdGTfvF5SjTtQx20757MbjwIWbP4cHD+rmse+TAJrxLMSiCoNpRbv56Yp/Cuq1ywQ4Z0WazgbfnB6f1URkufo6gLzs7X8LelxCprtcMRRY9d/as2eIf3MRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=3rJl4bvG5P28lwjcobHRthLqJO4TGcF+IiJpvc5pSCc=; b=KjS+Y4JBXjVMR+zj4B8apvGn2LM9O0df2zZ24bubCg7+BRdtqNTlS+WfsWkIPfIAbTPpGdLjTqWxM0nClU7yMOT8/H7o5JWC0IUOYxLQvL917/uaLQetqxFTVZQq3FgR3Po7aXfykw+SlBkCnVHRjCzi9ZtH5fJSpU1JV2mhyHYuvug3cddCITuhIEDHFXcqeribfEneAz0Pu7D95wW8R2Sq+t9PFh/64owa82mWAJ/IRpno3vzWNXXvvVkS1LDzv6F4cMvqS2XfHAetQQ/niXVGGW5SXoDYA1hIadFhvxRGJERGqz2CDzMz+0cCoSDGPXIHhaVuTzDxLhF/ALZGog== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3rJl4bvG5P28lwjcobHRthLqJO4TGcF+IiJpvc5pSCc=; b=pFsHmGgXz70xM0s3NjthVPY4iEMALG6drVaeHkyBCJxRn6ULtHl7DgSIy2tNP7/5/Jb2eMSCxTfL7WnWH4r/WlFTacSiw7ebJn6RkmV9jFzYeiasBCnXQUmJFquG8Kdtkxbi+IArLB8AIaqApNE5G5OInI02sUjfrd1JBxm7C5Y= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.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 arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C X-CheckRecipientChecked: true X-CR-MTA-CID: 64f1dc2d78702d66 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bSb16J0qk+WGanEemGGPWMJwfm7bqVKfU2TWwMSGwQGeBgJr5Q9rrAtDJ/nGiJIPtWRoiWTWUBG4htrMlU6LXnhrGuq5V4jq/9NjBsWQDLZlnykYTFDgbfiOCgz1Dg2l4nCY8rO/tGl7T+XhwhKb9z2K8UGL9VEs8tPyY8uVckd7WOwpTYleWXUs2vI1wBOJUWYOXDCeEoUfsO/glaN93cRcT9EanLzQXf2MSvEgsknzQmMMUKWCZa2ZvmHNJFarewCNIrYZEisGGk3tcpdStTmEC+PnkRd2KsLG00F23H5gJLvApUUH0ixE3/i0Cb7u5vdBxu0djf0nfNUk0gZ4AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=3rJl4bvG5P28lwjcobHRthLqJO4TGcF+IiJpvc5pSCc=; b=BErJhvOWOIxxJqIugDufA+2j01Opx7TVqeMRS+xrwVykWgHWRWW1Ht1Hwp9vUN9y50y12M/W6Oe04ffj7aeBdDE3wRfC2/sZZSlqiRCu5lB6h5wZoKJLw1dK/X6TBGMxohcqksn+QuooLbGtYtN0VFUtct4nDP9wfHC6WW3ulcPD21l9iA/L5AHlGajK28iW1qlcs8GEuvIZnXwUKbryhLYqJa2Odi4T3r+xWf1LMWMcRsQRxwxqO3fydPPyO/RdUs5+Tv2jXMn8+hfQG6qqcZ1xJHbKOZ5zNZHb45oYVWJxbmBXmr4Dvm55xMw0XCDLtPUu7m7nMoCmwIWKUxORSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3rJl4bvG5P28lwjcobHRthLqJO4TGcF+IiJpvc5pSCc=; b=pFsHmGgXz70xM0s3NjthVPY4iEMALG6drVaeHkyBCJxRn6ULtHl7DgSIy2tNP7/5/Jb2eMSCxTfL7WnWH4r/WlFTacSiw7ebJn6RkmV9jFzYeiasBCnXQUmJFquG8Kdtkxbi+IArLB8AIaqApNE5G5OInI02sUjfrd1JBxm7C5Y= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C From: Wei Chen To: CC: , Wei Chen , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini Subject: [PATCH v4 4/6] xen/x86: use arch_get_ram_range to get information from E820 map Date: Fri, 2 Sep 2022 11:31:19 +0800 Message-ID: <20220902033121.540328-5-wei.chen@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902033121.540328-1-wei.chen@arm.com> References: <20220902033121.540328-1-wei.chen@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 134fc4bf-528a-49ae-cf80-08da8c93b430 X-MS-TrafficTypeDiagnostic: AS8PR08MB6408:EE_|AM7EUR03FT042:EE_|GV2PR08MB8654:EE_ x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: dc2gxTi0hNBktT0/Xs1KZ1DqFMpyt5bEu2ey2GWmgx2bUlD5TUw50p1U5dSWXXIaxZVZoQ9hN2kwtqGqDmAaIXtSLthm/uNJA3YAFWBi4vHbePv0rZPfh4HFOsnwbgV/2h0DVbsUi730KousR/rJln2rvWaqSozRkp5XGdsq60Kyb/HdmLeu4Fqx4lpzmpafiT4vF/HEoGTCgggAH6p4eZT3PS7sEhpzJ1v5qgp8TCNPD6RWU3HJrlm8ftLs/YL2gUfqOvQuGvXIDAVJYa/gdqstveJnTLPIT54/f3d/Na5ghfaBCilbY94v9xBCdqi3ELyQ5u6gW0uhq2o1zwo9I58cg3+iMWtQpCIB/TC8LEeC6TLKTdLUGcNQJPGs9Atrc1+aAIjbsKY0gFh7RrEK7DkhPuUT3gu7a8eeAN9O6HBPo7wTxchzX9peeURa/MoU38fO0I0ZOH/2VYClF8RHrQt+Oez2eUEO5p5X5/YEQwf2C9Sk+NIwwFSe+6Rpnp2OJ0CyvlVmhf3EnCEdqCYB8O8Hjq2PKVk15i18rfkrFB5AG1W3k9gkM2TWeFU8EGshZ1CoHYrPERC9zleG9C1FW1Tfjzsa/tlTdG37gIU5iO1jM5aGoGT3LjrzKI1IBIsBX7sDa4TE1Ncp3FiL59pt4+M75HuNQDCt+gChN6nA8/PJ9jqb64yvaGFkh9PUETQOmLbcWvNBfrTPUMQLWA+1Q926KXvMgq3y09E92sQ7zTAwNvyyuZoXqV6zh7r57U6JBowZHFNvGOy79vWxqdHYEkiAADAQ2KwtaqiiIuY9zPzsDFDN9bYcpY6429opIkxE X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(376002)(396003)(39860400002)(346002)(136003)(40470700004)(46966006)(36840700001)(8936002)(81166007)(83380400001)(5660300002)(54906003)(86362001)(6916009)(36756003)(2616005)(316002)(186003)(1076003)(336012)(82310400005)(82740400003)(47076005)(36860700001)(70586007)(478600001)(40460700003)(26005)(426003)(41300700001)(8676002)(70206006)(40480700001)(7696005)(2906002)(44832011)(4326008)(356005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6408 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 98dfe6f1-1628-4130-e3b8-08da8c93aeee X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1WxNT/DJCfJMK/orD/kszvu/Pkvd9JhI0xj0JLvHPW2Ahd52oRnSJNIANq+s0jeRYSTkYSPE/ackDbAn1PWzz3+3RJoRpbmHdzxZ81DVkWXAlWyn606q5smLc+Gw1cWvCUCK52eQ8ThXOf6AZTbw/8BjOiLZV4NxOFDuTcQKu5IO60YYYIevSD6PpegOwe0s0uJp2H2qqMVmFS6x/ermw4BRkI84McK7C9m65L74gnxljqrblyHvUAXZy0qYE0H/TdXkukOB8uFSdqOH9fdxtz5ZhNpF/NLLJEVx0X1zaOAadNydK9cv4WFM/GcTM4stRx39RT0ih1TepEj/uhGwIkPvAa1C+89xVTplXYDH0Lwmh5+kWz9iV19gDbpzUYEVvhH4rfzQ8tz89ZBgl1UNlyhM3dwuL1txcyVpimjiKGsXGInAhrCQYmnQ7cvRO/BMmwAhfiWzj93IXUa2yh6DSw1opeHK4gQgMQ+DP8VkpY/iHsrJiAaQ2DCmF+Z/BXvVAmEuspDm+/Eywz7w/jgkWPy01AF1R5x8dYnnRbPQggxDb9ua2oQ1ZQTcaWFDo4JkdXh4PTmgr00hmJqvHiNSo3xH9HNzzMFhG3rBe8WvcCRsOp2GQX4VIXl+7khQ4j60LxbdbLNK18z40kxUCIQfU3oxmKouP896xbQFPv8qb238PMe7v+GYRxXfGgeHOEjsbeSTq5ewE0IsGmzID5tvN8H/8+tAB30pDuJrnDe9cBKCvaJImLVDjOKJmT1dUdpoFdDxINCBINpjl/lTbu38Sg== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(376002)(39860400002)(396003)(36840700001)(40470700004)(46966006)(186003)(2906002)(2616005)(36756003)(44832011)(83380400001)(82740400003)(336012)(47076005)(82310400005)(1076003)(5660300002)(426003)(8936002)(316002)(36860700001)(70206006)(70586007)(4326008)(8676002)(107886003)(7696005)(6666004)(6916009)(81166007)(41300700001)(86362001)(54906003)(40480700001)(26005)(40460700003)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2022 03:32:03.6900 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 134fc4bf-528a-49ae-cf80-08da8c93b430 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8654 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1662089551941100001 Content-Type: text/plain; charset="utf-8" The sanity check of nodes_cover_memory is also a requirement of other architectures that support NUMA. But now, the code of nodes_cover_memory is tied to the x86 E820. In this case, we introduce arch_get_ram_range to decouple architecture specific memory map from this function. This means, other architectures like Arm can also use it to check its node and memory coverage from bootmem info. Depends arch_get_ram_range, we make nodes_cover_memory become architecture independent. We also use neutral words to replace SRAT and E820 in the print message of this function. This will to make the massage seems more common. As arch_get_ram_range use unsigned int for index, we also adjust the index in nodes_cover_memory from int to unsigned int. Signed-off-by: Wei Chen Reviewed-by: Jan Beulich --- v3 -> v4: 1. Move function comment to header file. 2. Use bool for found, and add a new "err" for the return value of arch_get_ram_range. 3. Use -ENODATA instead of -EINVAL for non-RAM type ranges. v2 -> v3: 1. Rename arch_get_memory_map to arch_get_ram_range. 2. Use -ENOENT instead of -ENODEV to indicate end of memory map. 3. Add description to code comment that arch_get_ram_range returns RAM range in [start, end) format. v1 -> v2: 1. Use arch_get_memory_map to replace arch_get_memory_bank_range and arch_get_memory_bank_number. 2. Remove the !start || !end check, because caller guarantee these two pointers will not be NULL. --- xen/arch/x86/numa.c | 15 +++++++++++++++ xen/arch/x86/srat.c | 30 ++++++++++++++++++------------ xen/include/xen/numa.h | 13 +++++++++++++ 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c index 90b2a22591..fa8caaa084 100644 --- a/xen/arch/x86/numa.c +++ b/xen/arch/x86/numa.c @@ -9,6 +9,7 @@ #include #include #include +#include =20 #ifndef Dprintk #define Dprintk(x...) @@ -93,3 +94,17 @@ unsigned int __init arch_get_dma_bitsize(void) flsl(node_start_pfn(node) + node_spanned_pages(node) / 4 = - 1) + PAGE_SHIFT, 32); } + +int __init arch_get_ram_range(unsigned int idx, paddr_t *start, paddr_t *e= nd) +{ + if ( idx >=3D e820.nr_map ) + return -ENOENT; + + if ( e820.map[idx].type !=3D E820_RAM ) + return -ENODATA; + + *start =3D e820.map[idx].addr; + *end =3D *start + e820.map[idx].size; + + return 0; +} diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c index 4c7f0c547e..bd9694db24 100644 --- a/xen/arch/x86/srat.c +++ b/xen/arch/x86/srat.c @@ -428,37 +428,43 @@ acpi_numa_memory_affinity_init(const struct acpi_srat= _mem_affinity *ma) Make sure the PXMs cover all memory. */ static int __init nodes_cover_memory(void) { - int i; + unsigned int i; =20 - for (i =3D 0; i < e820.nr_map; i++) { - int j, found; + for (i =3D 0; ; i++) { + int err; + unsigned int j; + bool found; paddr_t start, end; =20 - if (e820.map[i].type !=3D E820_RAM) { - continue; - } + /* Try to loop memory map from index 0 to end to get RAM ranges. */ + err =3D arch_get_ram_range(i, &start, &end); =20 - start =3D e820.map[i].addr; - end =3D e820.map[i].addr + e820.map[i].size; + /* Reach the end of arch's memory map */ + if (err =3D=3D -ENOENT) + break; + + /* Index relate entry is not RAM, skip it. */ + if (err) + continue; =20 do { - found =3D 0; + found =3D false; for_each_node_mask(j, memory_nodes_parsed) if (start < nodes[j].end && end > nodes[j].start) { if (start >=3D nodes[j].start) { start =3D nodes[j].end; - found =3D 1; + found =3D true; } if (end <=3D nodes[j].end) { end =3D nodes[j].start; - found =3D 1; + found =3D true; } } } while (found && start < end); =20 if (start < end) { - printk(KERN_ERR "SRAT: No PXM for e820 range: " + printk(KERN_ERR "NUMA: No NODE for RAM range: " "[%"PRIpaddr", %"PRIpaddr"]\n", start, end - 1); return 0; } diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h index af0abfc8cf..38be7db960 100644 --- a/xen/include/xen/numa.h +++ b/xen/include/xen/numa.h @@ -81,6 +81,19 @@ static inline nodeid_t __attribute_pure__ phys_to_nid(pa= ddr_t addr) #define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \ NODE_DATA(nid)->node_spanned_pages) =20 +/* + * This function provides the ability for caller to get one RAM entry + * from architectural memory map by index. + * + * This function will return zero if it can return a proper RAM entry. + * otherwise it will return -ENOENT for out of scope index, or return + * -ENODATA for non-RAM type memory entry. + * + * Note: the range is exclusive at the end, e.g. [start, end). + */ +extern int arch_get_ram_range(unsigned int idx, + paddr_t *start, paddr_t *end); + #endif =20 #endif /* _XEN_NUMA_H */ --=20 2.25.1 From nobody Fri May 17 01:43:39 2024 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=2 dmarc=pass fromdomain=arm.com); dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=3; a=rsa-sha256; t=1662089562; cv=pass; d=zohomail.com; s=zohoarc; b=gw2i/2iSObSKoyU1O3N/hU0Cw7Ix2s2bKJCIdTTAJALV6FeSbo9BAhMFA7r0b9sMVklOrjsewYMzCkTdVbacp99oa7CEY+WTJ0UTGaIBxhelCVfkafx1cBYplxfsAGesIuQbUVYdF6tc8sGXQZpCFQGAAiUjs/gKzKpJXhutLBg= ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662089562; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lfSjviedwydQI2bCgX6A66sdP/EsoIsoIF3RlFpRa0g=; b=JDobaqy5Cpqk28fA84Ktur4zNVw9kndYMFukUQ4dq+ySoO1H1NUdA2UketDuxmCS8RwG10XqmV8US2xyPHgvzFEA4dpNJpWJ9r2KJpukxwHik6X3Qyl2rTmE4L/hRiKVqEcFzRHuW3ENjUzQtiFNmYC+KHnWtHudLA492y9Yz7U= ARC-Authentication-Results: i=3; 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=2 dmarc=pass fromdomain=arm.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1662089562180143.82036146683458; Thu, 1 Sep 2022 20:32:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.397249.637787 (Exim 4.92) (envelope-from ) id 1oTxPp-0006JP-Sf; Fri, 02 Sep 2022 03:32:21 +0000 Received: by outflank-mailman (output) from mailman id 397249.637787; Fri, 02 Sep 2022 03:32:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTxPp-0006JB-OK; Fri, 02 Sep 2022 03:32:21 +0000 Received: by outflank-mailman (input) for mailman id 397249; Fri, 02 Sep 2022 03:32:19 +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 1oTxPn-0004Wz-G3 for xen-devel@lists.xenproject.org; Fri, 02 Sep 2022 03:32:19 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70057.outbound.protection.outlook.com [40.107.7.57]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d7ef4871-2a6f-11ed-934f-f50d60e1c1bd; Fri, 02 Sep 2022 05:32:17 +0200 (CEST) Received: from DB6PR07CA0172.eurprd07.prod.outlook.com (2603:10a6:6:43::26) by AS2PR08MB9500.eurprd08.prod.outlook.com (2603:10a6:20b:60c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.11; Fri, 2 Sep 2022 03:32:13 +0000 Received: from DBAEUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:43:cafe::90) by DB6PR07CA0172.outlook.office365.com (2603:10a6:6:43::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.6 via Frontend Transport; Fri, 2 Sep 2022 03:32:13 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT033.mail.protection.outlook.com (100.127.142.251) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:32:13 +0000 Received: ("Tessian outbound c883b5ba7b70:v123"); Fri, 02 Sep 2022 03:32:13 +0000 Received: from 84a4feb24c14.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F41608C2-F044-4E42-86CF-FFE7CC9B61D1.1; Fri, 02 Sep 2022 03:32:07 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 84a4feb24c14.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 02 Sep 2022 03:32:07 +0000 Received: from DB8P191CA0011.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:130::21) by AS8PR08MB9573.eurprd08.prod.outlook.com (2603:10a6:20b:61b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Fri, 2 Sep 2022 03:32:02 +0000 Received: from DBAEUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:130:cafe::25) by DB8P191CA0011.outlook.office365.com (2603:10a6:10:130::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.12 via Frontend Transport; Fri, 2 Sep 2022 03:32:02 +0000 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT012.mail.protection.outlook.com (100.127.142.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:32:01 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2507.9; Fri, 2 Sep 2022 03:31:59 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.9; Fri, 2 Sep 2022 03:31:58 +0000 Received: from ais-wip-ds.shanghai.arm.com (10.169.190.86) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.9 via Frontend Transport; Fri, 2 Sep 2022 03:31:54 +0000 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: d7ef4871-2a6f-11ed-934f-f50d60e1c1bd ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=SieV/NNbADK7PX3lbkaS5+U4k1E/eD8+Ikt23Qy9l+o5P8Rveh501H5QTJZ/NYkZ4igD2c+ddh/O96Z43SdzgEVZMQQW+EPIvGSDJSqTL2ox/CPaiwGiHzTs7LyOlrz0LymAkc8Q3mrf3ngD1rVKYztzDaDQet08aSkctVkiAytZKXAUw1sNZ3y7HahuPsDSqFFU4J/FP5MEAXkkLW/jQmQtLHygyl0V4p3gBwpcNv0EBIcIe+4dEJeY7CQZN//xrCI7Y3To3QXPHnMfEDsyTGRFBECRLCCoa8F/C18tFhL97vW3RYdev7JjLfNjWGB2x7SUHKRK5raO8KoUA+O2ig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=lfSjviedwydQI2bCgX6A66sdP/EsoIsoIF3RlFpRa0g=; b=gsLV3743baK1rIkfAhW2LH0q8DTnNmwKA/CHYCg7VpyhZ2GO8d1VpAsRmabWTOqzeOOU53oezPNixme0XiKoKdSh1iT8bMvP6o+Gi0EmbCUeujIfrly9WZyFSLyaSeu4pWCjnkrhhE2Hzmlc8+OjQHjFgh8Tv6Sn2ectIwIVUCU5hnnO+YLJ02N7wznqKo8zFwgv+xO5T7u8WsIzIvnl3FHHP4Ss5l7eFMe4KjpK6HHEMBsZHVxPT0zHcRtOGi8UUDe6b6+8nOOmXYCxMnKJLlnOVwewT3C3tNACOdjK4RsxBkkJRSDDm1s3yasWx9XiSyVuDWM91pakxqNGrROlPg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lfSjviedwydQI2bCgX6A66sdP/EsoIsoIF3RlFpRa0g=; b=NinzuUHC9sxeXoGMociqzoWVX11fNnfxSxrIryTLrn4jbFyG35WdRuDuhiuVK01ZS9EIIsdn8V58NrbNhmdqnknQHLVl2NZ+JCLAJ0V6gTCKskz46fGd/cX/8DvMT+mvwu7BCwPMCwlQgiyvKi4GTRT8HgbWhd54t3StrB6RQiI= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.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 arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C X-CheckRecipientChecked: true X-CR-MTA-CID: 53b8b6652d082267 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VdGtVitsJpsZbgY8QkdW7GtaWh72m0aP1UhuphU9TF142OLcfH99sok5Mo1dFjRfiwXwCg6aek6ogULXChB/mPGrcICnFH3DVrkphOHCI8KKn3ZqpTvh5jiqwY29Wba+1Je0jj/qszUX+ISsAh7Y8Ip+qzblLm8rjwtrqm8SUSDFM/A8EShl6kadXhNvJCGI1T3dgN45Jg5Wos4T2Ddqmw/FNUy6F5xQisaOBRU7bAYlbZ4EirtdL1wkcmMTvJM1BiZo0xAK0Eq2XuUdrCWgdNzHaFjXOtofHp6UPcXLemn6CXpuNyBLv6ignpfuA1WMH/cPIbOGLiBWqhPQbmUSvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=lfSjviedwydQI2bCgX6A66sdP/EsoIsoIF3RlFpRa0g=; b=V4I6STe/OFejiryIewBq9WmTg46+j7W2q81h895oGZ1x1vUs7NTVWsCDm6CjR8e/TIPVSiBNafsHb1JtjFbj/2HidhBaGXhft1tCaITC4y0WN0rsEXFv7NrX5/d9/wLd9q6V2clpGiaH1c86pMGNtzpP0ie19ifVA9m8QyLY4Qsemp9/PhoZldiMSDTkU7YoKeJ/Zyh/0XSKNgUG4VuUovpgoQs/ReBG4R65wJ959v15/xARzbhBb1kQMhz85mcOmRgFjAY/YTXt74UHU4ezhC/ZRz3msLb1wOPGGOsaGT96igIIB79XceTWYb6S/yHpmAB0i4cx6FF1wewW/OR0Sw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lfSjviedwydQI2bCgX6A66sdP/EsoIsoIF3RlFpRa0g=; b=NinzuUHC9sxeXoGMociqzoWVX11fNnfxSxrIryTLrn4jbFyG35WdRuDuhiuVK01ZS9EIIsdn8V58NrbNhmdqnknQHLVl2NZ+JCLAJ0V6gTCKskz46fGd/cX/8DvMT+mvwu7BCwPMCwlQgiyvKi4GTRT8HgbWhd54t3StrB6RQiI= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C From: Wei Chen To: CC: , Wei Chen , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini Subject: [PATCH v4 5/6] xen/x86: move NUMA scan nodes codes from x86 to common Date: Fri, 2 Sep 2022 11:31:20 +0800 Message-ID: <20220902033121.540328-6-wei.chen@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902033121.540328-1-wei.chen@arm.com> References: <20220902033121.540328-1-wei.chen@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: b5e62c34-bdf8-4adb-f570-08da8c93ba20 X-MS-TrafficTypeDiagnostic: AS8PR08MB9573:EE_|DBAEUR03FT033:EE_|AS2PR08MB9500:EE_ x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: p/tSO5tBxJdEeD6tsVuaTWavthIVwj2OC4InpAmhPcu+Az8qBgME+zt6hH0aO6JDNP0s7LfohUJynUry3ipBIW018/HSYO4g3iG0sb/Ja06QrQbJ0eSmvji424YNvyIKQDcYM+fzk8pWIS5C01Npkwubz7DIiBykyQcbVhxUnQmm6DWysb8/+b8zWZY1jyIaKfT+/9Vk+w/Lzy6WnI1Cs5Bf7hvPYer85vyOS2WZOWyk8j6an8SagbFOh5StfPZbF8Ejarq8j2SvsjHyunGQOfw+0ek58uJVVRoGIJdVAsuIPsYeTtyqTzhuMigeDneCq2cUHGArU7W344YaE/sDiX6wZ/Pzjs7CZNPK30glcA7cBkJ8eOlnaxxkKB+opXSeYbEX9Z4BlTRVQ4FiSfc7RjR8qXVAkINVoGPy5ObqAYaDmBYpAYzSiguLYPmLze67iYaU/yyaylztO6gxeNan6gUbE8gbXFk30p3vsxNpFSs2sDBYTmAbEgreUdjYHGP/0CORlnAizBpMt3xPnaHcEuzXfz42FOskxpoIqzQBB3NSGlGMeC43xLCp1LzFfXVN7TN1hQ4nbsU2LKY1cB9z7lUDRtwL+fo4VOBkl+gpCgjXhkO+zcW3CrYe495yahjQcJOqRTvpcDPwntc6qgP6671mwVXx1iS6FsA48+JBFzyQiQjGm0JCREHciJgLUdwZB0MR+vsm3rylrVtfjPpSkmA7GWQ296l3HSIvD6cLwjErq2hzu9Xu0WvIE/l8GIhqKB1Q4Xp01S5mKCjLa8K8DreSdZpkJ2RAxLlqTBi4BRJ8E7HmpW0G5k3Aa6+x99m+ X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(346002)(376002)(136003)(39860400002)(396003)(46966006)(40470700004)(36840700001)(356005)(86362001)(36756003)(36860700001)(83380400001)(47076005)(426003)(7696005)(2616005)(1076003)(186003)(26005)(6666004)(336012)(41300700001)(316002)(82310400005)(40480700001)(4326008)(70586007)(8676002)(478600001)(54906003)(2906002)(82740400003)(5660300002)(70206006)(6916009)(81166007)(44832011)(30864003)(40460700003)(8936002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9573 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 8b80815d-6faa-4aef-e9ca-08da8c93b2f6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xuNmryb7W3Pk04e3z49enxlOsftrDW+ppKPfIHiY2c/j9IlNK93XGxcG2TxDJOjbkEjlB0GYGZc1vVL2jNh4AwZj75mUjBCqs92Kam1+7l3tB2GhhThcJRekpynwsn/ndZYJn8Y694lMDvjyXgF0JIBQWyKqC37SmeYxLlxBunWdRC/T0s/hscasgmXIYErOaJq9851ytr81OFSkVOYgwuNZd74V2uDXYC6g+fVaYNJWfRKcaX0tz3ONLmxoU/Z8kmc84Mn/4j5xM6wSlC56xWDsOWG+T1e+rgJqimQCeuv+A53tB0AN5q+LHkab81Xavg1HV+9Vo8Yo4AEYAgRK8fB/wcy0XS0t5ibu/UMug8A8hOuvYUhX9zVKsKZCZo7mXoI8PMTccjLhHeqVVca89dKacvSvHO9ICsoEgG29AjTHnSBtP0pRmNQIDU9hfZs2pTQpsNaBiL2szMocA+5xLt5dJEefQ+BPBAo1E8SNdq9xitO/qGzMgk3qSZ3qekdkCwk/MSIWWg3BZK+ekbvHOIlWKF5MhiM48jnKEK+kvfHUrwTzG3GNdJcdjtrSLy3dope/jiYcGmCTD/ev+lhKZwVc24uerKqIEevotfxC+abR5EpNX32k+zsgVhSbMc9yniEL2DCX+o7v+/IhBrxxsI7DhmsONXeopIOy4qIYypcBVCAz0jg54DrLvIXTGlgSni1IPCGzY5qeYkQrHTGt6IulA+idk7IUn23oF5R3Aa9FudhoZE0gmDARm82EPLfxK28SGVYK9r4rQpMgo5bk4A== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230016)(4636009)(136003)(396003)(346002)(39860400002)(376002)(36840700001)(40470700004)(46966006)(82740400003)(5660300002)(41300700001)(8936002)(40460700003)(26005)(2906002)(107886003)(7696005)(86362001)(6666004)(30864003)(36860700001)(44832011)(40480700001)(82310400005)(1076003)(336012)(47076005)(81166007)(83380400001)(70586007)(426003)(186003)(2616005)(54906003)(70206006)(6916009)(478600001)(4326008)(316002)(36756003)(8676002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2022 03:32:13.6993 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5e62c34-bdf8-4adb-f570-08da8c93ba20 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9500 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1662089564131100001 x86 has implemented a set of codes to scan NUMA nodes. These codes will parse NUMA memory and processor information from ACPI SRAT table. But except some ACPI specific codes, most of the scan codes like memory blocks validation, node memory range updates and some sanity check can be reused by other NUMA implementation. So in this patch, we move some variables and related functions for NUMA memory and processor to common as library. At the same time, numa_set_processor_nodes_parsed has been introduced for ACPI specific code to update processor parsing results. With this helper, we can reuse most of NUMA memory affinity init code from ACPI. As bad_srat and node_to_pxm functions have been used in common code to do architectural fallback and node to architectural node info translation. But it doesn't make sense to reuse the functions names in common code, we have rename them to neutral names as well. PXM is an ACPI specific item, we can't use it in common code directly. As an alternative, we extend the parameters of numa_update_node_memblks. The caller can pass the PXM as print messages' prefix or as architectural node id. And we introduced a CONFIG_HAS_NUMA_NODE_FWID to prevent print the mapping between node id and architectural node id for those architectures do not have architectural node id. In this case, we do not need to retain a lot of per-arch code but still can print architectural log messages for different NUMA implementations. mem_hotplug also has been accessing by common code, except x86, other architectures like Arm will also want to implement memory hotplug in future. We export mem_hotplug to common will not bring any harm for Arm and we also can reduce some per-arch helpers to access mem_hotplug. As asm/acpi.h has been removed from common/numa.c, we have to move NR_NODE_MEMBLKS from asm/acpi.h to xen/numa.h in this patch as well. Signed-off-by: Wei Chen --- v3 -> v4: 1. Use bool as return value for functions that only return 0/1 or 0/-EINVAL. 2. Move mem_hotplug to a proper place in mm.h 3. Remove useless "size" in numa_scan_nodes. 4. Use unsigned int or const for proper variables. 5. Fix code-style. 6. Add init_as_disable as arch_numa_disabled parameter. 7. Add CONFIG_HAS_NUMA_NODE_FWID to gate print the mapping between node id and architectural node id (fw node id). v2 -> v3: 1. Add __ro_after_init to proper variables. 2. Rename bad_srat to numa_fw_bad. 3. Rename node_to_pxm to numa_node_to_arch_nid. 4. Merge patch#7 and #8 into this patch. 5. Correct int to unsigned int in proper places. 6. Move NR_NODE_MEMBLKS from x86/acpi.h to common/numa.h 7. Drop helpers to access mem_hotplug, we export mem_hotplug from x86/mm.c to common/page_alloc.c v1 -> v2: 1. Add code comment for numa_update_node_memblks to explain: Assumes all memory regions belonging to a single node are in one chunk. Holes between them will be included in the node. 2. Merge this single patch instead of serval patches to move x86 SRAT code to common. 3. Export node_to_pxm to keep pxm information in NUMA scan nodes error messages. 4. Change the code style to target file's Xen code-style. 5. Adjust some __init and __initdata for some functions and variables. 6. Merge two patches into this patch: 1. replace CONFIG_ACPI_NUMA by CONFIG_NUMA. 2. replace "SRAT" texts. 7. Turn numa_scan_nodes to static. --- xen/arch/x86/include/asm/acpi.h | 1 - xen/arch/x86/include/asm/mm.h | 2 - xen/arch/x86/include/asm/numa.h | 3 +- xen/arch/x86/mm.c | 2 - xen/arch/x86/numa.c | 7 +- xen/arch/x86/srat.c | 311 +++---------------------------- xen/common/numa.c | 321 +++++++++++++++++++++++++++++++- xen/common/page_alloc.c | 2 + xen/drivers/acpi/Kconfig | 1 + xen/include/xen/mm.h | 2 + xen/include/xen/numa.h | 12 +- 11 files changed, 363 insertions(+), 301 deletions(-) diff --git a/xen/arch/x86/include/asm/acpi.h b/xen/arch/x86/include/asm/acp= i.h index 5c2dd5da2d..c453450a74 100644 --- a/xen/arch/x86/include/asm/acpi.h +++ b/xen/arch/x86/include/asm/acpi.h @@ -102,7 +102,6 @@ extern unsigned long acpi_wakeup_address; #define ARCH_HAS_POWER_INIT 1 =20 extern s8 acpi_numa; -#define NR_NODE_MEMBLKS (MAX_NUMNODES*2) =20 extern struct acpi_sleep_info acpi_sinfo; #define acpi_video_flags bootsym(video_flags) diff --git a/xen/arch/x86/include/asm/mm.h b/xen/arch/x86/include/asm/mm.h index 0fc826de46..95ff71a83a 100644 --- a/xen/arch/x86/include/asm/mm.h +++ b/xen/arch/x86/include/asm/mm.h @@ -474,8 +474,6 @@ static inline int get_page_and_type(struct page_info *p= age, ASSERT(((_p)->count_info & PGC_count_mask) !=3D 0); \ ASSERT(page_get_owner(_p) =3D=3D (_d)) =20 -extern paddr_t mem_hotplug; - /*************************************************************************= ***** * With shadow pagetables, the different kinds of address start * to get get confusing. diff --git a/xen/arch/x86/include/asm/numa.h b/xen/arch/x86/include/asm/num= a.h index 6c87942d43..2ca3475271 100644 --- a/xen/arch/x86/include/asm/numa.h +++ b/xen/arch/x86/include/asm/numa.h @@ -10,6 +10,7 @@ typedef u8 nodeid_t; extern int srat_rev; =20 extern nodeid_t pxm_to_node(unsigned int pxm); +extern unsigned int numa_node_to_arch_nid(nodeid_t n); =20 #define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT)) =20 @@ -22,8 +23,6 @@ extern void init_cpu_to_node(void); =20 #define arch_want_default_dmazone() (num_online_nodes() > 1) =20 -extern int valid_numa_range(paddr_t start, paddr_t end, nodeid_t node); - void srat_parse_regions(paddr_t addr); extern u8 __node_distance(nodeid_t a, nodeid_t b); unsigned int arch_get_dma_bitsize(void); diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index db1817b691..68f9989e1f 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -157,8 +157,6 @@ l1_pgentry_t __section(".bss.page_aligned") __aligned(P= AGE_SIZE) l1_pgentry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE) l1_fixmap_x[L1_PAGETABLE_ENTRIES]; =20 -paddr_t __read_mostly mem_hotplug; - /* Frame table size in pages. */ unsigned long max_page; unsigned long total_pages; diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c index fa8caaa084..e565c3a34d 100644 --- a/xen/arch/x86/numa.c +++ b/xen/arch/x86/numa.c @@ -41,9 +41,12 @@ int __init arch_numa_setup(const char *opt) return -EINVAL; } =20 -bool arch_numa_disabled(void) +bool arch_numa_disabled(bool init_as_disable) { - return acpi_numa < 0; + if ( !init_as_disable ) + return acpi_numa < 0; + + return acpi_numa <=3D 0; } =20 /* diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c index bd9694db24..7964e199c5 100644 --- a/xen/arch/x86/srat.c +++ b/xen/arch/x86/srat.c @@ -24,10 +24,6 @@ =20 static struct acpi_table_slit *__read_mostly acpi_slit; =20 -static nodemask_t memory_nodes_parsed __initdata; -static nodemask_t processor_nodes_parsed __initdata; -static struct node nodes[MAX_NUMNODES] __initdata; - struct pxm2node { unsigned pxm; nodeid_t node; @@ -35,19 +31,6 @@ struct pxm2node { static struct pxm2node __read_mostly pxm2node[MAX_NUMNODES] =3D { [0 ... MAX_NUMNODES - 1] =3D {.node =3D NUMA_NO_NODE} }; =20 -static unsigned node_to_pxm(nodeid_t n); - -static int num_node_memblks; -static struct node node_memblk_range[NR_NODE_MEMBLKS]; -static nodeid_t memblk_nodeid[NR_NODE_MEMBLKS]; -static __initdata DECLARE_BITMAP(memblk_hotplug, NR_NODE_MEMBLKS); - -enum conflicts { - NO_CONFLICT, - OVERLAP, - INTERLEAVE, -}; - static inline bool node_found(unsigned idx, unsigned pxm) { return ((pxm2node[idx].pxm =3D=3D pxm) && @@ -110,78 +93,7 @@ nodeid_t setup_node(unsigned pxm) return node; } =20 -int valid_numa_range(paddr_t start, paddr_t end, nodeid_t node) -{ - int i; - - for (i =3D 0; i < num_node_memblks; i++) { - struct node *nd =3D &node_memblk_range[i]; - - if (nd->start <=3D start && nd->end >=3D end && - memblk_nodeid[i] =3D=3D node) - return 1; - } - - return 0; -} - -static -enum conflicts __init conflicting_memblks(nodeid_t nid, paddr_t start, - paddr_t end, paddr_t nd_start, - paddr_t nd_end, unsigned int *mblkid) -{ - unsigned int i; - - /* - * Scan all recorded nodes' memory blocks to check conflicts: - * Overlap or interleave. - */ - for (i =3D 0; i < num_node_memblks; i++) { - struct node *nd =3D &node_memblk_range[i]; - - *mblkid =3D i; - - /* Skip 0 bytes node memory block. */ - if (nd->start =3D=3D nd->end) - continue; - /* - * Use memblk range to check memblk overlaps, include the - * self-overlap case. As nd's range is non-empty, the special - * case "nd->end =3D=3D end && nd->start =3D=3D start" also can be cover= ed. - */ - if (nd->end > start && nd->start < end) - return OVERLAP; - - /* - * Use node memory range to check whether new range contains - * memory from other nodes - interleave check. We just need - * to check full contains situation. Because overlaps have - * been checked above. - */ - if (nid !=3D memblk_nodeid[i] && - nd->start >=3D nd_start && nd->end <=3D nd_end) - return INTERLEAVE; - } - - return NO_CONFLICT; -} - -static __init void cutoff_node(int i, paddr_t start, paddr_t end) -{ - struct node *nd =3D &nodes[i]; - if (nd->start < start) { - nd->start =3D start; - if (nd->end < nd->start) - nd->start =3D nd->end; - } - if (nd->end > end) { - nd->end =3D end; - if (nd->start > nd->end) - nd->start =3D nd->end; - } -} - -static __init void bad_srat(void) +void __init numa_fw_bad(void) { int i; printk(KERN_ERR "SRAT: SRAT not used.\n"); @@ -241,7 +153,7 @@ acpi_numa_x2apic_affinity_init(const struct acpi_srat_x= 2apic_cpu_affinity *pa) if (numa_disabled()) return; if (pa->header.length < sizeof(struct acpi_srat_x2apic_cpu_affinity)) { - bad_srat(); + numa_fw_bad(); return; } if (!(pa->flags & ACPI_SRAT_CPU_ENABLED)) @@ -254,12 +166,12 @@ acpi_numa_x2apic_affinity_init(const struct acpi_srat= _x2apic_cpu_affinity *pa) pxm =3D pa->proximity_domain; node =3D setup_node(pxm); if (node =3D=3D NUMA_NO_NODE) { - bad_srat(); + numa_fw_bad(); return; } =20 apicid_to_node[pa->apic_id] =3D node; - node_set(node, processor_nodes_parsed); + numa_set_processor_nodes_parsed(node); acpi_numa =3D 1; =20 if (opt_acpi_verbose) @@ -277,7 +189,7 @@ acpi_numa_processor_affinity_init(const struct acpi_sra= t_cpu_affinity *pa) if (numa_disabled()) return; if (pa->header.length !=3D sizeof(struct acpi_srat_cpu_affinity)) { - bad_srat(); + numa_fw_bad(); return; } if (!(pa->flags & ACPI_SRAT_CPU_ENABLED)) @@ -290,11 +202,11 @@ acpi_numa_processor_affinity_init(const struct acpi_s= rat_cpu_affinity *pa) } node =3D setup_node(pxm); if (node =3D=3D NUMA_NO_NODE) { - bad_srat(); + numa_fw_bad(); return; } apicid_to_node[pa->apic_id] =3D node; - node_set(node, processor_nodes_parsed); + numa_set_processor_nodes_parsed(node); acpi_numa =3D 1; =20 if (opt_acpi_verbose) @@ -306,32 +218,27 @@ acpi_numa_processor_affinity_init(const struct acpi_s= rat_cpu_affinity *pa) void __init acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma) { - struct node *nd; - paddr_t nd_start, nd_end; - paddr_t start, end; unsigned pxm; nodeid_t node; - unsigned int i; =20 if (numa_disabled()) return; if (ma->header.length !=3D sizeof(struct acpi_srat_mem_affinity)) { - bad_srat(); + numa_fw_bad(); return; } if (!(ma->flags & ACPI_SRAT_MEM_ENABLED)) return; =20 - start =3D ma->base_address; - end =3D start + ma->length; /* Supplement the heuristics in l1tf_calculations(). */ - l1tf_safe_maddr =3D max(l1tf_safe_maddr, ROUNDUP(end, PAGE_SIZE)); + l1tf_safe_maddr =3D max(l1tf_safe_maddr, + ROUNDUP(ma->base_address + ma->length, + PAGE_SIZE)); =20 - if (num_node_memblks >=3D NR_NODE_MEMBLKS) - { + if (!numa_memblks_available()) { dprintk(XENLOG_WARNING, - "Too many numa entry, try bigger NR_NODE_MEMBLKS \n"); - bad_srat(); + "Too many numa entries, try bigger NR_NODE_MEMBLKS!\n"); + numa_fw_bad(); return; } =20 @@ -340,136 +247,14 @@ acpi_numa_memory_affinity_init(const struct acpi_sra= t_mem_affinity *ma) pxm &=3D 0xff; node =3D setup_node(pxm); if (node =3D=3D NUMA_NO_NODE) { - bad_srat(); + numa_fw_bad(); return; } =20 - /* - * For the node that already has some memory blocks, we will - * expand the node memory range temporarily to check memory - * interleaves with other nodes. We will not use this node - * temp memory range to check overlaps, because it will mask - * the overlaps in same node. - * - * Node with 0 bytes memory doesn't need this expandsion. - */ - nd_start =3D start; - nd_end =3D end; - nd =3D &nodes[node]; - if (nd->start !=3D nd->end) { - if (nd_start > nd->start) - nd_start =3D nd->start; - - if (nd_end < nd->end) - nd_end =3D nd->end; - } - - /* It is fine to add this area to the nodes data it will be used later*/ - switch (conflicting_memblks(node, start, end, nd_start, nd_end, &i)) { - case OVERLAP: - if (memblk_nodeid[i] =3D=3D node) { - bool mismatch =3D !(ma->flags & - ACPI_SRAT_MEM_HOT_PLUGGABLE) !=3D - !test_bit(i, memblk_hotplug); - - printk("%sSRAT: PXM %u [%"PRIpaddr", %"PRIpaddr"] overlaps with itself = [%"PRIpaddr", %"PRIpaddr"]\n", - mismatch ? KERN_ERR : KERN_WARNING, pxm, start, - end - 1, node_memblk_range[i].start, - node_memblk_range[i].end - 1); - if (mismatch) { - bad_srat(); - return; - } - break; - } - - printk(KERN_ERR - "SRAT: PXM %u [%"PRIpaddr", %"PRIpaddr"] overlaps with PXM %u [%"= PRIpaddr", %"PRIpaddr"]\n", - pxm, start, end - 1, node_to_pxm(memblk_nodeid[i]), - node_memblk_range[i].start, - node_memblk_range[i].end - 1); - bad_srat(); - return; - - case INTERLEAVE: - printk(KERN_ERR - "SRAT=EF=BC=9A PXM %u: [%"PRIpaddr", %"PRIpaddr"] interleaves wit= h PXM %u memblk [%"PRIpaddr", %"PRIpaddr"]\n", - pxm, nd_start, nd_end - 1, node_to_pxm(memblk_nodeid[i]), - node_memblk_range[i].start, node_memblk_range[i].end - 1); - bad_srat(); - return; - - case NO_CONFLICT: - break; - } - - if (!(ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE)) { - node_set(node, memory_nodes_parsed); - nd->start =3D nd_start; - nd->end =3D nd_end; - } - - printk(KERN_INFO "SRAT: Node %u PXM %u [%"PRIpaddr", %"PRIpaddr"]%s\n", - node, pxm, start, end - 1, - ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE ? " (hotplug)" : ""); - - node_memblk_range[num_node_memblks].start =3D start; - node_memblk_range[num_node_memblks].end =3D end; - memblk_nodeid[num_node_memblks] =3D node; - if (ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) { - __set_bit(num_node_memblks, memblk_hotplug); - if (end > mem_hotplug) - mem_hotplug =3D end; - } - num_node_memblks++; -} - -/* Sanity check to catch more bad SRATs (they are amazingly common). - Make sure the PXMs cover all memory. */ -static int __init nodes_cover_memory(void) -{ - unsigned int i; - - for (i =3D 0; ; i++) { - int err; - unsigned int j; - bool found; - paddr_t start, end; - - /* Try to loop memory map from index 0 to end to get RAM ranges. */ - err =3D arch_get_ram_range(i, &start, &end); - - /* Reach the end of arch's memory map */ - if (err =3D=3D -ENOENT) - break; - - /* Index relate entry is not RAM, skip it. */ - if (err) - continue; - - do { - found =3D false; - for_each_node_mask(j, memory_nodes_parsed) - if (start < nodes[j].end - && end > nodes[j].start) { - if (start >=3D nodes[j].start) { - start =3D nodes[j].end; - found =3D true; - } - if (end <=3D nodes[j].end) { - end =3D nodes[j].start; - found =3D true; - } - } - } while (found && start < end); - - if (start < end) { - printk(KERN_ERR "NUMA: No NODE for RAM range: " - "[%"PRIpaddr", %"PRIpaddr"]\n", start, end - 1); - return 0; - } - } - return 1; + if (!numa_update_node_memblks(node, pxm, ma->base_address, + ma->length, "PXM", + ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE)) + numa_fw_bad(); } =20 void __init acpi_numa_arch_fixup(void) {} @@ -525,59 +310,9 @@ void __init srat_parse_regions(paddr_t addr) pfn_pdx_hole_setup(mask >> PAGE_SHIFT); } =20 -/* Use the information discovered above to actually set up the nodes. */ -int __init numa_scan_nodes(paddr_t start, paddr_t end) -{ - int i; - nodemask_t all_nodes_parsed; - - /* First clean up the node list */ - for (i =3D 0; i < MAX_NUMNODES; i++) - cutoff_node(i, start, end); - - if (acpi_numa <=3D 0) - return -1; - - if (!nodes_cover_memory()) { - bad_srat(); - return -1; - } - - memnode_shift =3D compute_hash_shift(node_memblk_range, num_node_memblks, - memblk_nodeid); - - if (memnode_shift < 0) { - printk(KERN_ERR - "SRAT: No NUMA node hash function found. Contact maintainer\n"); - bad_srat(); - return -1; - } - - nodes_or(all_nodes_parsed, memory_nodes_parsed, processor_nodes_parsed); - - /* Finally register nodes */ - for_each_node_mask(i, all_nodes_parsed) - { - uint64_t size =3D nodes[i].end - nodes[i].start; - - if ( size =3D=3D 0 ) - printk(KERN_INFO "SRAT: node %u has no memory\n", i); - - setup_node_bootmem(i, nodes[i].start, nodes[i].end); - } - for (i =3D 0; i < nr_cpu_ids; i++) { - if (cpu_to_node[i] =3D=3D NUMA_NO_NODE) - continue; - if (!nodemask_test(cpu_to_node[i], &processor_nodes_parsed)) - numa_set_node(i, NUMA_NO_NODE); - } - numa_init_array(); - return 0; -} - -static unsigned node_to_pxm(nodeid_t n) +unsigned int numa_node_to_arch_nid(nodeid_t n) { - unsigned i; + unsigned int i; =20 if ((n < ARRAY_SIZE(pxm2node)) && (pxm2node[n].node =3D=3D n)) return pxm2node[n].pxm; @@ -594,8 +329,8 @@ u8 __node_distance(nodeid_t a, nodeid_t b) =20 if (!acpi_slit) return a =3D=3D b ? 10 : 20; - index =3D acpi_slit->locality_count * node_to_pxm(a); - slit_val =3D acpi_slit->entry[index + node_to_pxm(b)]; + index =3D acpi_slit->locality_count * numa_node_to_arch_nid(a); + slit_val =3D acpi_slit->entry[index + numa_node_to_arch_nid(b)]; =20 /* ACPI defines 0xff as an unreachable node and 0-9 are undefined */ if ((slit_val =3D=3D 0xff) || (slit_val <=3D 9)) diff --git a/xen/common/numa.c b/xen/common/numa.c index 03e7318d72..da0ff7ae34 100644 --- a/xen/common/numa.c +++ b/xen/common/numa.c @@ -13,6 +13,21 @@ #include #include =20 +static nodemask_t __initdata processor_nodes_parsed; +static nodemask_t __initdata memory_nodes_parsed; +static struct node __initdata nodes[MAX_NUMNODES]; + +static unsigned int __ro_after_init num_node_memblks; +static struct node __ro_after_init node_memblk_range[NR_NODE_MEMBLKS]; +static nodeid_t __ro_after_init memblk_nodeid[NR_NODE_MEMBLKS]; +static __initdata DECLARE_BITMAP(memblk_hotplug, NR_NODE_MEMBLKS); + +enum conflicts { + NO_CONFLICT, + OVERLAP, + INTERLEAVE, +}; + struct node_data __ro_after_init node_data[MAX_NUMNODES]; =20 /* Mapping from pdx to node id */ @@ -33,7 +48,309 @@ bool __read_mostly numa_off; =20 bool numa_disabled(void) { - return numa_off || arch_numa_disabled(); + return numa_off || arch_numa_disabled(false); +} + +void __init numa_set_processor_nodes_parsed(nodeid_t node) +{ + node_set(node, processor_nodes_parsed); +} + +bool valid_numa_range(paddr_t start, paddr_t end, nodeid_t node) +{ + unsigned int i; + + for ( i =3D 0; i < num_node_memblks; i++ ) + { + struct node *nd =3D &node_memblk_range[i]; + + if ( nd->start <=3D start && nd->end >=3D end && + memblk_nodeid[i] =3D=3D node ) + return true; + } + + return false; +} + +static enum conflicts __init conflicting_memblks( + nodeid_t nid, paddr_t start, paddr_t end, paddr_t nd_start, + paddr_t nd_end, unsigned int *mblkid) +{ + unsigned int i; + + /* + * Scan all recorded nodes' memory blocks to check conflicts: + * Overlap or interleave. + */ + for ( i =3D 0; i < num_node_memblks; i++ ) + { + const struct node *nd =3D &node_memblk_range[i]; + + *mblkid =3D i; + + /* Skip 0 bytes node memory block. */ + if ( nd->start =3D=3D nd->end ) + continue; + /* + * Use memblk range to check memblk overlaps, include the + * self-overlap case. As nd's range is non-empty, the special + * case "nd->end =3D=3D end && nd->start =3D=3D start" also can be= covered. + */ + if ( nd->end > start && nd->start < end ) + return OVERLAP; + + /* + * Use node memory range to check whether new range contains + * memory from other nodes - interleave check. We just need + * to check full contains situation. Because overlaps have + * been checked above. + */ + if ( nid !=3D memblk_nodeid[i] && + nd->start >=3D nd_start && nd->end <=3D nd_end ) + return INTERLEAVE; + } + + return NO_CONFLICT; +} + +static void __init cutoff_node(nodeid_t i, paddr_t start, paddr_t end) +{ + struct node *nd =3D &nodes[i]; + + if ( nd->start < start ) + { + nd->start =3D start; + if ( nd->end < nd->start ) + nd->start =3D nd->end; + } + + if ( nd->end > end ) + { + nd->end =3D end; + if ( nd->start > nd->end ) + nd->start =3D nd->end; + } +} + +bool __init numa_memblks_available(void) +{ + return num_node_memblks < NR_NODE_MEMBLKS; +} + +/* + * This function will be called by NUMA memory affinity initialization to + * update NUMA node's memory range. In this function, we assume all memory + * regions belonging to a single node are in one chunk. Holes (or MMIO + * ranges) between them will be included in the node. + * + * So in numa_update_node_memblks, if there are multiple banks for each + * node, start and end are stretched to cover the holes between them, and + * it works as long as memory banks of different NUMA nodes don't interlea= ve. + */ +bool __init numa_update_node_memblks(nodeid_t node, unsigned int arch_nid, + paddr_t start, paddr_t size, + const char *prefix, + bool hotplug) +{ + unsigned int i; + paddr_t end =3D start + size; + paddr_t nd_start =3D start; + paddr_t nd_end =3D end; + struct node *nd =3D &nodes[node]; + + /* + * For the node that already has some memory blocks, we will + * expand the node memory range temporarily to check memory + * interleaves with other nodes. We will not use this node + * temp memory range to check overlaps, because it will mask + * the overlaps in same node. + * + * Node with 0 bytes memory doesn't need this expandsion. + */ + if ( nd->start !=3D nd->end ) + { + if ( nd_start > nd->start ) + nd_start =3D nd->start; + + if ( nd_end < nd->end ) + nd_end =3D nd->end; + } + + /* It is fine to add this area to the nodes data it will be used later= */ + switch ( conflicting_memblks(node, start, end, nd_start, nd_end, &i) ) + { + case OVERLAP: + if ( memblk_nodeid[i] =3D=3D node ) + { + bool mismatch =3D !(hotplug) !=3D !test_bit(i, memblk_hotplug); + + printk("%sNUMA: %s %u [%"PRIpaddr", %"PRIpaddr"] overlaps with= itself [%"PRIpaddr", %"PRIpaddr"]\n", + mismatch ? KERN_ERR : KERN_WARNING, prefix, + arch_nid, start, end - 1, + node_memblk_range[i].start, node_memblk_range[i].end - = 1); + if ( mismatch ) + return false; + break; + } + + printk(KERN_ERR + "NUMA: %s %u [%"PRIpaddr", %"PRIpaddr"] overlaps with %s %u= [%"PRIpaddr", %"PRIpaddr"]\n", + prefix, arch_nid, start, end - 1, prefix, + numa_node_to_arch_nid(memblk_nodeid[i]), + node_memblk_range[i].start, node_memblk_range[i].end - 1); + return false; + + + case INTERLEAVE: + printk(KERN_ERR + "NUMA=EF=BC=9A %s %u: [%"PRIpaddr", %"PRIpaddr"] interleave= s with %s %u memblk [%"PRIpaddr", %"PRIpaddr"]\n", + prefix, arch_nid, nd_start, nd_end - 1, + prefix, numa_node_to_arch_nid(memblk_nodeid[i]), + node_memblk_range[i].start, node_memblk_range[i].end - 1); + return false; + + case NO_CONFLICT: + break; + } + + if ( !hotplug ) + { + node_set(node, memory_nodes_parsed); + nd->start =3D nd_start; + nd->end =3D nd_end; + } + + +#ifdef CONFIG_HAS_NUMA_NODE_FWID + printk(KERN_INFO "NUMA: Node %u %s %u [%"PRIpaddr", %"PRIpaddr"]%s\n", + node, prefix, arch_nid, start, end - 1, + hotplug ? " (hotplug)" : ""); +#else + printk(KERN_INFO "NUMA: Node %u [%"PRIpaddr", %"PRIpaddr"]%s\n", + node, start, end - 1, hotplug ? " (hotplug)" : ""); +#endif + + node_memblk_range[num_node_memblks].start =3D start; + node_memblk_range[num_node_memblks].end =3D end; + memblk_nodeid[num_node_memblks] =3D node; + if ( hotplug ) + { + __set_bit(num_node_memblks, memblk_hotplug); + if ( end > mem_hotplug ) + mem_hotplug =3D end; + } + num_node_memblks++; + + return true; +} + +/* + * Sanity check to catch more bad SRATs (they are amazingly common). + * Make sure the PXMs cover all memory. + */ +static int __init nodes_cover_memory(void) +{ + unsigned int i; + + for ( i =3D 0; ; i++ ) + { + int err; + bool found; + unsigned int j; + paddr_t start, end; + + /* Try to loop memory map from index 0 to end to get RAM ranges. */ + err =3D arch_get_ram_range(i, &start, &end); + + /* Reach the end of arch's memory map */ + if ( err =3D=3D -ENOENT ) + break; + + /* Index relate entry is not RAM, skip it. */ + if ( err ) + continue; + + do { + found =3D false; + for_each_node_mask( j, memory_nodes_parsed ) + if ( start < nodes[j].end + && end > nodes[j].start ) + { + if ( start >=3D nodes[j].start ) + { + start =3D nodes[j].end; + found =3D true; + } + + if ( end <=3D nodes[j].end ) + { + end =3D nodes[j].start; + found =3D true; + } + } + } while ( found && start < end ); + + if ( start < end ) + { + printk(KERN_ERR "NUMA: No node for RAM range: " + "[%"PRIpaddr", %"PRIpaddr"]\n", start, end - 1); + return 0; + } + } + return 1; +} + +/* Use the information discovered above to actually set up the nodes. */ +static bool __init numa_scan_nodes(paddr_t start, paddr_t end) +{ + unsigned int i; + nodemask_t all_nodes_parsed; + + /* First clean up the node list */ + for ( i =3D 0; i < MAX_NUMNODES; i++ ) + cutoff_node(i, start, end); + + /* When numa is on with good firmware, we can do numa scan nodes. */ + if ( arch_numa_disabled(true) ) + return false; + + if ( !nodes_cover_memory() ) + { + numa_fw_bad(); + return false; + } + + memnode_shift =3D compute_hash_shift(node_memblk_range, num_node_membl= ks, + memblk_nodeid); + + if ( memnode_shift < 0 ) + { + printk(KERN_ERR + "NUMA: No NUMA node hash function found. Contact maintainer= \n"); + numa_fw_bad(); + return false; + } + + nodes_or(all_nodes_parsed, memory_nodes_parsed, processor_nodes_parsed= ); + + /* Finally register nodes */ + for_each_node_mask( i, all_nodes_parsed ) + { + if ( nodes[i].end - nodes[i].start =3D=3D 0 ) + printk(KERN_INFO "NUMA: node %u has no memory\n", i); + + setup_node_bootmem(i, nodes[i].start, nodes[i].end); + } + + for ( i =3D 0; i < nr_cpu_ids; i++ ) + { + if ( cpu_to_node[i] =3D=3D NUMA_NO_NODE ) + continue; + if ( !nodemask_test(cpu_to_node[i], &processor_nodes_parsed) ) + numa_set_node(i, NUMA_NO_NODE); + } + numa_init_array(); + return true; } =20 /* @@ -242,7 +559,7 @@ void __init numa_initmem_init(unsigned long start_pfn, = unsigned long end_pfn) #endif =20 #ifdef CONFIG_NUMA - if ( !numa_off && !numa_scan_nodes(start, end) ) + if ( !numa_off && numa_scan_nodes(start, end) ) return; #endif =20 diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index bfd4150be7..39b9653286 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -159,6 +159,8 @@ #define PGT_TYPE_INFO_INITIALIZER 0 #endif =20 +paddr_t __read_mostly mem_hotplug; + /* * Comma-separated list of hexadecimal page numbers containing bad bytes. * e.g. 'badpage=3D0x3f45,0x8a321'. diff --git a/xen/drivers/acpi/Kconfig b/xen/drivers/acpi/Kconfig index e3f3d8f4b1..6f33d1ad57 100644 --- a/xen/drivers/acpi/Kconfig +++ b/xen/drivers/acpi/Kconfig @@ -7,4 +7,5 @@ config ACPI_LEGACY_TABLES_LOOKUP =20 config ACPI_NUMA bool + select HAS_NUMA_NODE_FWID select NUMA diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 35b065146f..2bced13c0c 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -148,6 +148,8 @@ int assign_page( /* Dump info to serial console */ void arch_dump_shared_mem_info(void); =20 +extern paddr_t mem_hotplug; + /* * Extra fault info types which are used to further describe * the source of an access violation. diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h index 38be7db960..e593115ba2 100644 --- a/xen/include/xen/numa.h +++ b/xen/include/xen/numa.h @@ -11,6 +11,7 @@ #define NUMA_NO_DISTANCE 0xFF =20 #define MAX_NUMNODES (1 << NODES_SHIFT) +#define NR_NODE_MEMBLKS (MAX_NUMNODES * 2) =20 #define vcpu_to_node(v) (cpu_to_node((v)->processor)) =20 @@ -42,10 +43,10 @@ extern void numa_add_cpu(unsigned int cpu); extern void numa_init_array(void); extern void numa_set_node(unsigned int cpu, nodeid_t node); extern void numa_initmem_init(unsigned long start_pfn, unsigned long end_p= fn); -extern int numa_scan_nodes(paddr_t start, paddr_t end); +extern void numa_fw_bad(void); =20 extern int arch_numa_setup(const char *opt); -extern bool arch_numa_disabled(void); +extern bool arch_numa_disabled(bool init_as_disable); extern void setup_node_bootmem(nodeid_t nodeid, paddr_t start, paddr_t end= ); =20 static inline void clear_node_cpumask(unsigned int cpu) @@ -93,6 +94,13 @@ static inline nodeid_t __attribute_pure__ phys_to_nid(pa= ddr_t addr) */ extern int arch_get_ram_range(unsigned int idx, paddr_t *start, paddr_t *end); +extern bool valid_numa_range(paddr_t start, paddr_t end, nodeid_t node); +extern bool numa_memblks_available(void); +extern bool numa_update_node_memblks(nodeid_t node, unsigned int arch_nid, + paddr_t start, paddr_t size, + const char *prefix, + bool hotplug); +extern void numa_set_processor_nodes_parsed(nodeid_t node); =20 #endif =20 --=20 2.25.1 From nobody Fri May 17 01:43:39 2024 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=2 dmarc=pass fromdomain=arm.com); dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=3; a=rsa-sha256; t=1662089966; cv=pass; d=zohomail.com; s=zohoarc; b=NKEttFnPRmp4Xb7WudAOPM/B+vclQphyeKfJo3/txTtx8U909gSom6Iz2pwlDKm+GOffphnTdWFzwkiHsnWOwMHW+z/jyXp7Ej/+oQOJqHHVwR45PgNCsK4WbTjlS3Bmnlxl2jETTV1Rl3SYbLPYGVh9HTGtCo60dsKu9zt1slk= ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662089966; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c24JNM9CmKKyBmuocLYrIdMPXWfKN3aqMIKpf5afvV4=; b=XbsZH//gJbgAiOj+XnzaT7Kt1WCdbgrDQr+ct45/X24EXTALPoLPUqAq7+PHqAVofJBsGGI1kn2hlia7hXnHwdPzChf/LnD7eXvZzSibFtLobAFLvFYUEneY/ifkGm9QYgmmbZG9XfleMY1NJiItUUKnq93S8aTYMrR3ndzAa38= ARC-Authentication-Results: i=3; 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=2 dmarc=pass fromdomain=arm.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1662089966984985.2223503913493; Thu, 1 Sep 2022 20:39:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.397285.637809 (Exim 4.92) (envelope-from ) id 1oTxWH-0008OX-Ux; Fri, 02 Sep 2022 03:39:01 +0000 Received: by outflank-mailman (output) from mailman id 397285.637809; Fri, 02 Sep 2022 03:39:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oTxWH-0008OL-Q1; Fri, 02 Sep 2022 03:39:01 +0000 Received: by outflank-mailman (input) for mailman id 397285; Fri, 02 Sep 2022 03:39:00 +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 1oTxQ2-0004PQ-Ld for xen-devel@lists.xenproject.org; Fri, 02 Sep 2022 03:32:34 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60072.outbound.protection.outlook.com [40.107.6.72]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e19ca15d-2a6f-11ed-82f2-63bd783d45fa; Fri, 02 Sep 2022 05:32:33 +0200 (CEST) Received: from DU2PR04CA0090.eurprd04.prod.outlook.com (2603:10a6:10:232::35) by VI1PR08MB5469.eurprd08.prod.outlook.com (2603:10a6:803:132::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Fri, 2 Sep 2022 03:32:18 +0000 Received: from DBAEUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:232:cafe::56) by DU2PR04CA0090.outlook.office365.com (2603:10a6:10:232::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.14 via Frontend Transport; Fri, 2 Sep 2022 03:32:18 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT057.mail.protection.outlook.com (100.127.142.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:32:17 +0000 Received: ("Tessian outbound cc6a8ab50b6b:v123"); Fri, 02 Sep 2022 03:32:17 +0000 Received: from f51a0cb4c96b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 89DAB0A1-28E9-41C0-813E-F00EDBFF854E.1; Fri, 02 Sep 2022 03:32:12 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f51a0cb4c96b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 02 Sep 2022 03:32:12 +0000 Received: from FR0P281CA0112.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a8::11) by DB8PR08MB5387.eurprd08.prod.outlook.com (2603:10a6:10:115::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.11; Fri, 2 Sep 2022 03:32:07 +0000 Received: from VE1EUR03FT028.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:a8:cafe::a1) by FR0P281CA0112.outlook.office365.com (2603:10a6:d10:a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.5 via Frontend Transport; Fri, 2 Sep 2022 03:32:07 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT028.mail.protection.outlook.com (10.152.18.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Fri, 2 Sep 2022 03:32:07 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2507.9; Fri, 2 Sep 2022 03:32:03 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.9; Fri, 2 Sep 2022 03:32:02 +0000 Received: from ais-wip-ds.shanghai.arm.com (10.169.190.86) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.9 via Frontend Transport; Fri, 2 Sep 2022 03:31:59 +0000 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: e19ca15d-2a6f-11ed-82f2-63bd783d45fa ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=TH4O/OSl/GXDZtPZeNzan7mPCNxgqKtSG4HrD1ekN+qX4jDIiKsVrf/i12L3PmdwRx+ZRgWeI8lkICacIdktvxJcQxoU5c64aM6m5Uam5MxOEmGKx8bTIXDcVbxJ6nnGHD8pW6GbU271NnKzZuipaqBqcuoW+yI6RU/a0Sol/nTSbiGNh4qGjuPcpJ7eVJD3mMfyqaQspFZBjjILZM4tRjRYz2c/ibP4yV6AAIwoPj3GDqXY+HydkJpMFTe6Vd1smRmqSaC9No6lDPzBJ0cw+eA/7o0HdCkTJ7tZ4F8VAg9VH14ukE6KzxWSk3TmUd0IAvSfI1kW8+c+LEaidou/aA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=c24JNM9CmKKyBmuocLYrIdMPXWfKN3aqMIKpf5afvV4=; b=gpPmPgdeccSTZIw3/DbbOgh6DxsDjxoViRjikyq1I3NqzPl7VuBCSRGKd0ld0+V0aOe+YsgWVbS+dDmUCUQpTD7FjYsaSUEm7/SlL4EgjAU4z4CxXeGs+1SDyLH+GpKiLJTclLEfItzcfiDdgqpvMAMOzYAnLa+/fikos0/ZR+JpgMq0c9rXOPS+Mm652VJD8IH2rt262BIsEYtUrKehtIvwGn1Mj3UdMrwO4S5IadaDcukLe10IJMgHfzCRQsxSY1SgB0bqRkUvDr+GUzTQVLYD6EkDrfYTHj7JAD13JT19xQ2LGOnwuVBi+pe3Z4RRmyD0GdzC6oWMeXG6WnK7+Q== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c24JNM9CmKKyBmuocLYrIdMPXWfKN3aqMIKpf5afvV4=; b=lbtlvdMlwCTPwrFVphMgQrn8X89rrEyvugz2kckcYvTISZMOZrw6BT38gAvCXJ4N9mux67BoGqi5QQAlDZLjVmiM25f9ny/RPJzx4v4R+TQP4Pb/WXicIysPoZCWGeUxSJ/HD/YXhZznFexmCGzyZb3Rrb4DZOPnz8gPRXjby9k= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.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 arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C X-CheckRecipientChecked: true X-CR-MTA-CID: e9a734e8d165181b X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LiToRe2dz/7nR9uUzYEoDSc1syPLMSUmWrQLbM7hkt6PBxfFaJTz0QbTY2gl2XWWZ3ey6yLyA/m5L5v7+jKecOdV4lZebvvXfL/PJt/G0XMNd5ORlWJzfnVlo5/+j24kD0Qb8nnjiGzatq/0Lss5JHIe0SqiTs6dxuXeXemDcN6GhSu0zZhnqwHdkSFcS2yl53cEKyPsHCt0S8rCO1RMm7JEmxt9gRzoEix1ilpuf5mf24sd21z22lg0Cj/BGvd/XKbsVrRPi94r2HbIILmYNGGODg6wQHiJ6+werwA6I0raKnbTvFYasQAG/KeiNyjnDmlOyw3UVwSe/Ud+YQHRiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=c24JNM9CmKKyBmuocLYrIdMPXWfKN3aqMIKpf5afvV4=; b=O3Q8KxxGQ09UOX5wqaf9wU9ZDPSUPRU45xPadheJgEeLGt+L2CAj0Unn/Qno+GhwXjm5//8soPq55/cESQ3Cgkc3qP0zbu53P8/P3A96/kP92dic7dbtVM7l3Fqq8qMHImo5Ofj3Kudyr4jmMvtd8vw0sZokhN7LV46+f31fKdCv1DKJw48A3DTFuT3kQZjEtoF+/xpgTZ7uRnPEJ4PfJPBWcvMTCbeOjny8+WhID+KLxoWTH/92NUlq4QtkIo3QXWqVVfwznTxLO1Jr9UgJm7sVakBcx3Ff/t6G33wLkY2RpJTFh9B1jp/0hAQmTVw6Jq5+ivlNX+bUYeHECGjRoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c24JNM9CmKKyBmuocLYrIdMPXWfKN3aqMIKpf5afvV4=; b=lbtlvdMlwCTPwrFVphMgQrn8X89rrEyvugz2kckcYvTISZMOZrw6BT38gAvCXJ4N9mux67BoGqi5QQAlDZLjVmiM25f9ny/RPJzx4v4R+TQP4Pb/WXicIysPoZCWGeUxSJ/HD/YXhZznFexmCGzyZb3Rrb4DZOPnz8gPRXjby9k= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C From: Wei Chen To: CC: , Wei Chen , Andrew Cooper , George Dunlap , "Jan Beulich" , Julien Grall , "Stefano Stabellini" , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v4 6/6] xen: introduce a Kconfig option to configure NUMA nodes number Date: Fri, 2 Sep 2022 11:31:21 +0800 Message-ID: <20220902033121.540328-7-wei.chen@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902033121.540328-1-wei.chen@arm.com> References: <20220902033121.540328-1-wei.chen@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: cf474a3e-91b0-4ad4-a9b1-08da8c93bc7c X-MS-TrafficTypeDiagnostic: DB8PR08MB5387:EE_|DBAEUR03FT057:EE_|VI1PR08MB5469:EE_ x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: JGRRDgUUgwq1I29DjGybxxrrOdX+/IkmLKt+W1B+NCp8RgzpPpmV7NVBnkU55qISCs1y9FegLsYHyhDsSF0VYGS8qZPPERgiw9bDpEoAAVrVkebS1UdBozzMaRcIgfyYkOHpKdM1Zs++mxVVFWxsjJVjJECtu1lauw0LVIdZMF9kj8LqFFFj0udJCRCEKE+hHgma7WmqMzm+dnJX0V6pweYYD4ce5YSrjzf5nFjFzAgkYMOGW4JTO52zi/fdMu6Tm0UtsqfCr8ZxP94wtvgm5Hin9kaMN2T+7TPRthzwQ3dcmm9ygojDhJAPp11jDjAoq++nUKd040qFI0HJ4GigWu0KaIu2oq52CrQTq3ZXsSY9KI6rrT0cipMDfUmojMxqo8Xxm+HJMR6tlJY3xyinEqda7eAJFerVJtMF6ZRtLsifHrDL7scTSwFaikwULuEpqididqoX3Z2CiWO157lkKUoY3P2VFda8/crBs58yw+QK4mP5zRP3HBvQrZlSnrscetf27lGxLu6CxAZ81BkdoFe5RVWbHOUzPFxMs0z6H77pxR3jy+Z24cv/ld3h6k4d36q0Sdpul2ME1hTnrQeF0xn4/ewraNP0Sm6CZaUM3SHtQ3uemhUesEhEXLs8Mas/0e3wFjUbFDMT3jVz8a3XRTcQMMTN37LOkKjG8awSGDn7Sl0BKZF31vPlrQQxOZRW4xzY49v0NdDSp/c+u+0xPrIK//kJwgs4PnUWB4JccTwcxBolJT46qSh1slCo8wBleXvhUjJl26bFdGRI3NrxxvIAIC8ugXkMJJBVAunCdE4= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(39860400002)(346002)(136003)(376002)(396003)(46966006)(40470700004)(36840700001)(426003)(47076005)(7696005)(26005)(336012)(2616005)(186003)(1076003)(40480700001)(44832011)(8936002)(5660300002)(36756003)(41300700001)(6666004)(86362001)(478600001)(36860700001)(83380400001)(356005)(81166007)(54906003)(6916009)(82310400005)(2906002)(316002)(40460700003)(82740400003)(4326008)(8676002)(70206006)(70586007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5387 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4e9e035f-a40d-49b6-b8c9-08da8c93b651 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fZtLOlQCO853KMU0YKSVrSaS5D94uJW/oE4rv8HJkbMRUMkQpJmNQebYwjUomlBgQM8aPepN2y2DeUQ1JvBLBhoiYl8G5MxphLyoT/KKbDESZDfZJqqeazRxR0FjmlfwMHgJ6Atyy8FYb7FGSM1i0WxbfycwJrvCBWNI4khrh4tplnNh0Ozs92XVB0FcfnySSdlTCI0JXB8iHzluDbsAPGt1fc2scH5qHTLYAwfZ056D+DSRWdTqkPLtrVv1AJJHDrDGYIl6y00pCliHzXLVDM1ScJ9ZgFE2uVhYFjYR8SeAH+nachM/j/aiV7ifwNS54vUjED22BFJmUzD2v/nYqWuMqOk8CEQD2E0nhzz+bxiWZVP+CxV9cYUfcnHR77YB4HfIfT7KvnwYRk7otvOFLi1xqEWa8kV0XiIn4J+/4TB8jS1rvKISWxzmnsTlT8iug9B/4fK5GOGkYDENktxqxdmxgEPl/+WQtFcXL4Ulm8KOOu8DFMhJwdvYjL+EoBEbx2HubPGESh66igjF9tjELi4smAhB9FPRvXLMGE9duQp8ZAzwVCGMlDYAlY++3tAcD0s/Y9KhxuQbLq9IeufTFLYR4I7i8vNyicH7fSOXDw9wD3uRXVyFE6+yrFhSq6xkSGImSpUiQqTbGGSGEMVbFeOdc4nNfXC2LHNkHJke9mlzSA4rbfWBT1pZGLZ71Yid7d4/UJq9gRbVAhOyp+F2BMf/l9y8RSBMd64nv2OTTrBGEA0APX5UB0a7QDloXTwkDl8MzgOTiNNk3cgMO+RHcA== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230016)(4636009)(346002)(376002)(136003)(396003)(39860400002)(46966006)(36840700001)(40470700004)(82310400005)(40480700001)(36860700001)(86362001)(81166007)(70586007)(8676002)(4326008)(41300700001)(5660300002)(478600001)(54906003)(40460700003)(8936002)(70206006)(426003)(6916009)(1076003)(316002)(47076005)(186003)(82740400003)(2616005)(44832011)(336012)(26005)(36756003)(7696005)(6666004)(2906002)(83380400001)(107886003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2022 03:32:17.6714 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf474a3e-91b0-4ad4-a9b1-08da8c93bc7c X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5469 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1662089969582100001 Content-Type: text/plain; charset="utf-8" Currently the maximum number of NUMA nodes is a hardcoded value. This provides little flexibility unless changing the code. Introduce a new Kconfig option to change the maximum number of NUMA nodes conveniently. Also considering that not all architectures support NUMA, this Kconfig option is only visible on NUMA enabled architectures. Architectures not supporting NUMA still use 1 for MAX_NUMNODES. As NODES_SHIFT is currently unused, we're taking this opportunity to remove it. Signed-off-by: Wei Chen Acked-by: Jan Beulich --- v3 -> v4: 1. Update the commit log to follow Jan's suggestion. 2. Add Ack-by. v2 -> v3: 1. Fix indent. 2. Use 2-64 for node range. v1 -> v2: 1. Add NODES_SHIFT remove message in commit log 2. Change NR_NUMA_NODES upper bound from 4095 to 255. --- xen/arch/Kconfig | 11 +++++++++++ xen/arch/x86/include/asm/numa.h | 2 -- xen/include/xen/numa.h | 11 ++++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/xen/arch/Kconfig b/xen/arch/Kconfig index f16eb0df43..7028f7b74f 100644 --- a/xen/arch/Kconfig +++ b/xen/arch/Kconfig @@ -17,3 +17,14 @@ config NR_CPUS For CPU cores which support Simultaneous Multi-Threading or similar technologies, this the number of logical threads which Xen will support. + +config NR_NUMA_NODES + int "Maximum number of NUMA nodes supported" + range 2 64 + default "64" + depends on NUMA + help + Controls the build-time size of various arrays and bitmaps + associated with multiple-nodes management. It is the upper bound of + the number of NUMA nodes that the scheduler, memory allocation and + other NUMA-aware components can handle. diff --git a/xen/arch/x86/include/asm/numa.h b/xen/arch/x86/include/asm/num= a.h index 2ca3475271..7866afa408 100644 --- a/xen/arch/x86/include/asm/numa.h +++ b/xen/arch/x86/include/asm/numa.h @@ -3,8 +3,6 @@ =20 #include =20 -#define NODES_SHIFT 6 - typedef u8 nodeid_t; =20 extern int srat_rev; diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h index e593115ba2..e16a7c3764 100644 --- a/xen/include/xen/numa.h +++ b/xen/include/xen/numa.h @@ -3,14 +3,15 @@ =20 #include =20 -#ifndef NODES_SHIFT -#define NODES_SHIFT 0 -#endif - #define NUMA_NO_NODE 0xFF #define NUMA_NO_DISTANCE 0xFF =20 -#define MAX_NUMNODES (1 << NODES_SHIFT) +#ifdef CONFIG_NR_NUMA_NODES +#define MAX_NUMNODES CONFIG_NR_NUMA_NODES +#else +#define MAX_NUMNODES 1 +#endif + #define NR_NODE_MEMBLKS (MAX_NUMNODES * 2) =20 #define vcpu_to_node(v) (cpu_to_node((v)->processor)) --=20 2.25.1