From nobody Wed Nov 27 05:49:51 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=1731330767; cv=none; d=zohomail.com; s=zohoarc; b=PwofFdkix1vi3WN1d+V7YRwUDsf9aHchGRYiLnTBRmHzXp77/RTUfQgvyjGLAAXSofMeSvUwYHGt3UOPxzwmeMh4V7EBlpAaPOzB8Tuea9uHesjUEErWodU/Wg2p9BpLgqU33CTntD9ZRAgsCjvTjl+wbSoVh+89IUy4Crozm3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731330767; 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=W0GanGvpA+3jTX9LxsfCUWpnROXG+vaTFolekFzAvck=; b=TJsFzySN4YlkQXKb8txPaBjPtmOmVEhTAgyKlhKs8sXkwogJuZCj30zy6y/CBeSfv23oI7aqtOhr5dVH53RI43Ds+K1Ytsopz802IuluAg7cI4QY1NsqwYnY3I3hfK8Ey9PZaVu+M+EXWniRWodjrOSpocvp5stH0KxvxtZViOQ= 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 1731330767398259.5609302438186; Mon, 11 Nov 2024 05:12:47 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.833742.1249028 (Exim 4.92) (envelope-from ) id 1tAUDN-0002Cl-92; Mon, 11 Nov 2024 13:12:21 +0000 Received: by outflank-mailman (output) from mailman id 833742.1249028; Mon, 11 Nov 2024 13:12: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 1tAUDN-0002CX-3Q; Mon, 11 Nov 2024 13:12:21 +0000 Received: by outflank-mailman (input) for mailman id 833742; Mon, 11 Nov 2024 13:12:19 +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 1tAUDL-0007pD-HN for xen-devel@lists.xenproject.org; Mon, 11 Nov 2024 13:12:19 +0000 Received: from smtp-fw-33001.amazon.com (smtp-fw-33001.amazon.com [207.171.190.10]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9288da4e-a02e-11ef-99a3-01e77a169b0f; Mon, 11 Nov 2024 14:12:16 +0100 (CET) Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev) ([10.25.36.210]) by smtp-border-fw-33001.sea14.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2024 13:12:15 +0000 Received: from EX19MTAUEA002.ant.amazon.com [10.0.29.78:36658] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.2.104:2525] with esmtp (Farcaster) id 175b2100-e97e-462f-a456-f6bcc4ede293; Mon, 11 Nov 2024 13:12:14 +0000 (UTC) Received: from EX19D008UEA004.ant.amazon.com (10.252.134.191) by EX19MTAUEA002.ant.amazon.com (10.252.134.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Mon, 11 Nov 2024 13:12:09 +0000 Received: from EX19MTAUEC001.ant.amazon.com (10.252.135.222) by EX19D008UEA004.ant.amazon.com (10.252.134.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Mon, 11 Nov 2024 13:12:09 +0000 Received: from email-imr-corp-prod-pdx-all-2b-5ec155c2.us-west-2.amazon.com (10.124.125.6) by mail-relay.amazon.com (10.252.135.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34 via Frontend Transport; Mon, 11 Nov 2024 13:12:09 +0000 Received: from dev-dsk-eliasely-1a-fd74790f.eu-west-1.amazon.com (dev-dsk-eliasely-1a-fd74790f.eu-west-1.amazon.com [10.253.91.118]) by email-imr-corp-prod-pdx-all-2b-5ec155c2.us-west-2.amazon.com (Postfix) with ESMTPS id 0F33642135; Mon, 11 Nov 2024 13:12:07 +0000 (UTC) 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: 9288da4e-a02e-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjIwNy4xNzEuMTkwLjEwIiwiaGVsbyI6InNtdHAtZnctMzMwMDEuYW1hem9uLmNvbSJ9 X-Custom-Transaction: eyJpZCI6IjkyODhkYTRlLWEwMmUtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMxMzMwNzM2LjU4MzE5Mywic2VuZGVyIjoicHJ2cz0wMzhkMjZkMGM9ZWxpYXNlbHlAYW1hem9uLmNvLnVrIiwicmVjaXBpZW50IjoieGVuLWRldmVsQGxpc3RzLnhlbnByb2plY3Qub3JnIn0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1731330736; x=1762866736; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=W0GanGvpA+3jTX9LxsfCUWpnROXG+vaTFolekFzAvck=; b=rPFgZDyOcO4DgzkQmMQ2VmrrXobUC6r48N+kWpfpOLPKBxDKa9iE4Wju r6FilQTS3QPZTZHTezii9AhfXozx9tuqYobIw/6K7zkdWMl9O9dOh+3zY mz5+Tq8GiKvOvOn2vELQsq+QF6mIlDYFaRNgupGO4xxH22KNhzmDIW/mi g=; X-IronPort-AV: E=Sophos;i="6.12,145,1728950400"; d="scan'208";a="384186415" X-Farcaster-Flow-ID: 175b2100-e97e-462f-a456-f6bcc4ede293 From: Elias El Yandouzi To: CC: , , , Hongyan Xia , Julien Grall , Elias El Yandouzi Subject: [PATCH V4 10/15] xen/page_alloc: vmap heap nodes when they are outside the direct map Date: Mon, 11 Nov 2024 13:11:43 +0000 Message-ID: <20241111131148.52568-11-eliasely@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20241111131148.52568-1-eliasely@amazon.com> References: <20241111131148.52568-1-eliasely@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @amazon.com) X-ZM-MESSAGEID: 1731330768912116600 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 v4: * Change type of the parameters to paddr_t * Use clear_domain_page() instead of open-coding it 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 2cef521ad85a..62cdeb5013a3 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -137,6 +137,7 @@ #include #include #include +#include =20 #include #include @@ -606,22 +607,32 @@ 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))) ) { - _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); + else + _heap[node] =3D vmap_contig(_mfn(mfn + nr - needed), 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 + nr - needed, needed) ) + _heap[node] =3D mfn_to_virt(mfn + nr - needed); + else + _heap[node] =3D vmap_contig(_mfn(mfn + nr - needed), 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