From nobody Thu May 9 04:06:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=amazon.com ARC-Seal: i=1; a=rsa-sha256; t=1705431976; cv=none; d=zohomail.com; s=zohoarc; b=Xr00oeYWlUESKMypXKV47Fwvb/TdzJ6e3N59e90GpmeTNJvlWhMIY2B4Q8QPUloNVbMfaJRoOfKycmOc7QfCtEUbTZrP484yDAbhF+6SfmPV9lcgcp5oA7FW2lY8kXTYfv2C9tpEwVod92gT7flTBoLWfRRtkvEInDIXh2miB7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705431976; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BQwz5u8QWnu4kJOr/giiJYPgo6aRgBqNBhniW2zo2FE=; b=nkHFe1ZbIbz1uclMiq/MWsO6zo/Hpj2updXuNb8OSQsZ+ZjRXfCcwTUrnzWD5goA9/91cVAt19PBarVSvc7hBpK7bYOTrmAXrSOmtPq6AExuH4MHr9g/TyNW0HZP3iiWOSn91qpwJt080UBkKqcaYpNN2DyyiKahc62YJwAFeZA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1705431976739510.9719452154227; Tue, 16 Jan 2024 11:06:16 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.668019.1039857 (Exim 4.92) (envelope-from ) id 1rPol6-0006fF-WB; Tue, 16 Jan 2024 19:06:01 +0000 Received: by outflank-mailman (output) from mailman id 668019.1039857; Tue, 16 Jan 2024 19:06:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rPol6-0006eO-RI; Tue, 16 Jan 2024 19:06:00 +0000 Received: by outflank-mailman (input) for mailman id 668019; Tue, 16 Jan 2024 19:05:59 +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 1rPoXx-0002UD-Ug for xen-devel@lists.xenproject.org; Tue, 16 Jan 2024 18:52:25 +0000 Received: from smtp-fw-80008.amazon.com (smtp-fw-80008.amazon.com [99.78.197.219]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 627ddc1f-b4a0-11ee-98f1-6d05b1d4d9a1; Tue, 16 Jan 2024 19:52:25 +0100 (CET) Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1a-m6i4x-bbc6e425.us-east-1.amazon.com) ([10.25.36.214]) by smtp-border-fw-80008.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 18:52:22 +0000 Received: from smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev (iad7-ws-svc-p70-lb3-vlan3.iad.amazon.com [10.32.235.38]) by email-inbound-relay-iad-1a-m6i4x-bbc6e425.us-east-1.amazon.com (Postfix) with ESMTPS id 3DD0D807A3; Tue, 16 Jan 2024 18:52:20 +0000 (UTC) Received: from EX19MTAUEC001.ant.amazon.com [10.0.44.209:4913] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.15.248:2525] with esmtp (Farcaster) id de871c36-9ec9-4ec7-b295-f240a8062615; Tue, 16 Jan 2024 18:52:19 +0000 (UTC) Received: from EX19D008UEA004.ant.amazon.com (10.252.134.191) by EX19MTAUEC001.ant.amazon.com (10.252.135.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 16 Jan 2024 18:52:14 +0000 Received: from EX19MTAUWB001.ant.amazon.com (10.250.64.248) by EX19D008UEA004.ant.amazon.com (10.252.134.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 16 Jan 2024 18:52:14 +0000 Received: from dev-dsk-eliasely-1a-fd74790f.eu-west-1.amazon.com (10.253.91.118) by mail-relay.amazon.com (10.250.64.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40 via Frontend Transport; Tue, 16 Jan 2024 18:52:12 +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 Sender: "Xen-devel" X-Inumbo-ID: 627ddc1f-b4a0-11ee-98f1-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1705431145; x=1736967145; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BQwz5u8QWnu4kJOr/giiJYPgo6aRgBqNBhniW2zo2FE=; b=YnGdkP68oU7GJgEKFaNf9M2PKn2jARFRFUtMEsE/EnoNrrF2c7ynHdYu O2ZU1Qasr/RXagzDM2zgNciApWsOPRrOkyoUzXPP623TL2zQ1bUq7W/T8 XFPAstHRAIREJmT5wN+el6VeY0jpgMw5RtOwqVQFUDAuB78wF7V/Ycxgb Q=; X-IronPort-AV: E=Sophos;i="6.05,200,1701129600"; d="scan'208";a="58742934" X-Farcaster-Flow-ID: de871c36-9ec9-4ec7-b295-f240a8062615 From: Elias El Yandouzi To: CC: , , , Hongyan Xia , Andrew Cooper , "George Dunlap" , Jan Beulich , "Stefano Stabellini" , Wei Liu , Julien Grall , Elias El Yandouzi Subject: [PATCH v2] x86/setup: vmap heap nodes when they are outside the direct map Date: Tue, 16 Jan 2024 18:50:49 +0000 Message-ID: <20240116185056.15000-21-eliasely@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240116185056.15000-1-eliasely@amazon.com> References: <20240116185056.15000-1-eliasely@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: Bulk X-ZohoMail-DKIM: pass (identity @amazon.com) X-ZM-MESSAGEID: 1705431977068100001 Content-Type: text/plain; charset="utf-8" From: Hongyan Xia When we do not have a direct map, archs_mfn_in_direct_map() will always return false, thus init_node_heap() will allocate xenheap pages from an existing node for the metadata of a new node. This means that the metadata of a new node is in a different node, slowing down heap allocation. Since we now have early vmap, vmap the metadata locally in the new node. Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi ---- Changes in v2: * vmap_contig_pages() was renamed to vmap_contig() * Fix indentation and coding style Changes from Hongyan's version: * arch_mfn_in_direct_map() was renamed to arch_mfns_in_direct_map() * Use vmap_contig_pages() rather than __vmap(...). * Add missing include (xen/vmap.h) so it compiles on Arm diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 52934ec5c1..42b9aaae1c 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -136,6 +136,7 @@ #include #include #include +#include =20 #include #include @@ -604,22 +605,44 @@ static unsigned long init_node_heap(int node, unsigne= d long mfn, needed =3D 0; } else if ( *use_tail && nr >=3D needed && - arch_mfns_in_directmap(mfn + nr - needed, needed) && (!xenheap_bits || - !((mfn + nr - 1) >> (xenheap_bits - PAGE_SHIFT))) ) + !((mfn + nr - 1) >> (xenheap_bits - PAGE_SHIFT))) ) { - _heap[node] =3D mfn_to_virt(mfn + nr - needed); - avail[node] =3D mfn_to_virt(mfn + nr - 1) + - PAGE_SIZE - sizeof(**avail) * NR_ZONES; + if ( arch_mfns_in_directmap(mfn + nr - needed, needed) ) + { + _heap[node] =3D mfn_to_virt(mfn + nr - needed); + avail[node] =3D mfn_to_virt(mfn + nr - 1) + + PAGE_SIZE - sizeof(**avail) * NR_ZONES; + } + else + { + mfn_t needed_start =3D _mfn(mfn + nr - needed); + + _heap[node] =3D vmap_contig(needed_start, needed); + BUG_ON(!_heap[node]); + avail[node] =3D (void *)(_heap[node]) + (needed << PAGE_SHIFT)= - + sizeof(**avail) * NR_ZONES; + } } else if ( nr >=3D needed && - arch_mfns_in_directmap(mfn, needed) && (!xenheap_bits || - !((mfn + needed - 1) >> (xenheap_bits - PAGE_SHIFT))) ) + !((mfn + needed - 1) >> (xenheap_bits - PAGE_SHIFT))) ) { - _heap[node] =3D mfn_to_virt(mfn); - avail[node] =3D mfn_to_virt(mfn + needed - 1) + - PAGE_SIZE - sizeof(**avail) * NR_ZONES; + if ( arch_mfns_in_directmap(mfn, needed) ) + { + _heap[node] =3D mfn_to_virt(mfn); + avail[node] =3D mfn_to_virt(mfn + needed - 1) + + PAGE_SIZE - sizeof(**avail) * NR_ZONES; + } + else + { + mfn_t needed_start =3D _mfn(mfn); + + _heap[node] =3D vmap_contig(needed_start, needed); + BUG_ON(!_heap[node]); + avail[node] =3D (void *)(_heap[node]) + (needed << PAGE_SHIFT)= - + sizeof(**avail) * NR_ZONES; + } *use_tail =3D false; } else if ( get_order_from_bytes(sizeof(**_heap)) =3D=3D --=20 2.40.1