Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp7242550pxv; Fri, 30 Jul 2021 13:37:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKUyF3stlCCqngb6hvvgc+M3DIvOMLto82krgqYn5VDn2L8O7C2lU8ILtOY/iUQlkiWnor X-Received: by 2002:a5e:8d03:: with SMTP id m3mr187052ioj.200.1627677430094; Fri, 30 Jul 2021 13:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627677430; cv=none; d=google.com; s=arc-20160816; b=wdsT3G8DuqCS+5xgZDsmjm2SiPvspcAFm/fQjjThTURHa4smb5+alpgbfnFDQ+H1RK n5ICIz1ogT3+QW29sJ7Aj4v0Sc69zYJhXt9g7gk6JIrx0lqqjyagb6M99MDGzgJHcicq edp/BRuuDQ94AUpThVNPcQKZMPPIKdWkBLmOwNi+vjo5XKP2crrs6e1P+1xYQCd8OGAW IiZpeKs12MyZoz95rCxiuIr6aJEXBhmsIOP7ZVpDhkQC/qd15qjIi3n1xfUxiCquRyfY U8dc3FcsqEfNz1aMqyEIb+D75K1MCy9YlUiNl+7PRzD3VCH2/HXSXr/vpEqnHYDYEEZ6 tj/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:autocrypt:from :references:cc:to:subject; bh=sPXET9LBrQkbCSOpCTwW+pskdH8PRYMsEr7ylnd0cyU=; b=J43TbPI6/4cdc4Q0sqv4SYurskEOZYx6TB8DD8Od1Qoc1kXWZeLojqnDz1S4ljJklW WxbyZJ7myvPlDGh1wrTlDVbySkSJdNWU41VcEN+RdCrhS4XFyVhWaXuCHmlDJUSnAI13 JbJBX2zNfo5J2WP2fqaXqJCFpWI0T0BTUnczQt5IV0ngv2BMn6I6/rMsyf97DSdlE/i6 B5R2t3CQy53LnT5Zf0PNoJyYH8ZQiqfjUhfTnD0Cr/sJibfqlSILrCuyw2fZBD8cVwm2 cp8VKP0rDeL170vyg4btihPUsoCSoqgwVHLtYer7ixNzh7DV7QH91eCsuHHNgMS+eudA gAuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l17si3248683ilt.90.2021.07.30.13.36.55; Fri, 30 Jul 2021 13:37:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231508AbhG3Ufz (ORCPT + 99 others); Fri, 30 Jul 2021 16:35:55 -0400 Received: from mga17.intel.com ([192.55.52.151]:49561 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231463AbhG3Ufw (ORCPT ); Fri, 30 Jul 2021 16:35:52 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10061"; a="193444416" X-IronPort-AV: E=Sophos;i="5.84,282,1620716400"; d="scan'208";a="193444416" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2021 13:35:45 -0700 X-IronPort-AV: E=Sophos;i="5.84,282,1620716400"; d="scan'208";a="477165440" Received: from cwschule-mobl.amr.corp.intel.com (HELO [10.212.156.26]) ([10.212.156.26]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2021 13:35:45 -0700 Subject: Re: [PATCH v3 2/7] x86/sgx: Add infrastructure to identify SGX EPC pages To: "Luck, Tony" Cc: Sean Christopherson , Jarkko Sakkinen , x86@kernel.org, linux-kernel@vger.kernel.org, Matthew Wilcox References: <20210719182009.1409895-1-tony.luck@intel.com> <20210728204653.1509010-1-tony.luck@intel.com> <20210728204653.1509010-3-tony.luck@intel.com> <141602a3-ef61-01f0-4a3c-69f8e7012fcd@intel.com> <20210730003809.hp3nmqmgyysa45nz@kernel.org> <20210730184400.GA1521057@agluck-desk2.amr.corp.intel.com> From: Dave Hansen Autocrypt: addr=dave.hansen@intel.com; keydata= xsFNBE6HMP0BEADIMA3XYkQfF3dwHlj58Yjsc4E5y5G67cfbt8dvaUq2fx1lR0K9h1bOI6fC oAiUXvGAOxPDsB/P6UEOISPpLl5IuYsSwAeZGkdQ5g6m1xq7AlDJQZddhr/1DC/nMVa/2BoY 2UnKuZuSBu7lgOE193+7Uks3416N2hTkyKUSNkduyoZ9F5twiBhxPJwPtn/wnch6n5RsoXsb ygOEDxLEsSk/7eyFycjE+btUtAWZtx+HseyaGfqkZK0Z9bT1lsaHecmB203xShwCPT49Blxz VOab8668QpaEOdLGhtvrVYVK7x4skyT3nGWcgDCl5/Vp3TWA4K+IofwvXzX2ON/Mj7aQwf5W iC+3nWC7q0uxKwwsddJ0Nu+dpA/UORQWa1NiAftEoSpk5+nUUi0WE+5DRm0H+TXKBWMGNCFn c6+EKg5zQaa8KqymHcOrSXNPmzJuXvDQ8uj2J8XuzCZfK4uy1+YdIr0yyEMI7mdh4KX50LO1 pmowEqDh7dLShTOif/7UtQYrzYq9cPnjU2ZW4qd5Qz2joSGTG9eCXLz5PRe5SqHxv6ljk8mb ApNuY7bOXO/A7T2j5RwXIlcmssqIjBcxsRRoIbpCwWWGjkYjzYCjgsNFL6rt4OL11OUF37wL QcTl7fbCGv53KfKPdYD5hcbguLKi/aCccJK18ZwNjFhqr4MliQARAQAB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x4WHqUn3yFj8rwTAU1tluRUYyeLy0ayUlKBH ybj0N71vWO936MqP6haFERzuPAIpxj2ezwu0xb1GjTk4ynna6h5GjnKgdfOWoRtoWndMZxbA z5cecg== Message-ID: Date: Fri, 30 Jul 2021 13:35:42 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210730184400.GA1521057@agluck-desk2.amr.corp.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/30/21 11:44 AM, Luck, Tony wrote: > @@ -649,6 +650,9 @@ static bool __init sgx_setup_epc_section(u64 phys_addr, u64 size, > } > > section->phys_addr = phys_addr; > + section->end_phys_addr = phys_addr + size - 1; > + xa_store_range(&epc_page_ranges, section->phys_addr, > + section->end_phys_addr, section, GFP_KERNEL); That is compact, but how much memory does it eat? I'm a little worried about this hunk of xa_store_range(): > do { > xas_set_range(&xas, first, last); > xas_store(&xas, entry); > if (xas_error(&xas)) > goto unlock; > first += xas_size(&xas); > } while (first <= last); That makes it look like it's iterating over the whole range and making loads of individual array instead of doing something super clever like keeping an extent-style structure. Let's say we have 1TB of EPC. How big is the array to store these indexes? Would this be more compact if instead of doing a physical address range: xa_store_range(&epc_page_ranges, section->phys_addr, section->end_phys_addr, ...); ... you did it based on PFNs: xa_store_range(&epc_page_ranges, section->phys_addr >> PAGE_SHIFT, section->end_phys_addr >> PAGE_SHIFT, ...); SGX sections are at *least* page-aligned, so this should be fine.