From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751937AbdKZTBP (ORCPT ); Sun, 26 Nov 2017 14:01:15 -0500 Received: from mga01.intel.com ([192.55.52.88]:64531 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751816AbdKZTBN (ORCPT ); Sun, 26 Nov 2017 14:01:13 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,460,1505804400"; d="scan'208";a="177979420" Date: Sun, 26 Nov 2017 21:01:09 +0200 From: Jarkko Sakkinen To: platform-driver-x86@vger.kernel.org, x86@kernel.org Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Darren Hart , Andy Shevchenko Subject: Re: [PATCH v6 06/11] intel_sgx: driver for Intel Software Guard Extensions Message-ID: <20171126190109.qfvjoq2sbz5x3ve7@linux.intel.com> References: <20171125193132.24321-1-jarkko.sakkinen@linux.intel.com> <20171125193132.24321-7-jarkko.sakkinen@linux.intel.com> <20171126173356.ik7dhvvcojgermof@linux.intel.com> <20171126184627.hegr3qzgous5ivpe@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171126184627.hegr3qzgous5ivpe@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 26, 2017 at 08:46:27PM +0200, Jarkko Sakkinen wrote: > On Sun, Nov 26, 2017 at 07:33:56PM +0200, Jarkko Sakkinen wrote: > > > +struct sgx_encl_page { > > > + unsigned long addr; > > > + unsigned int flags; > > > + void *epc_page; > > > + struct sgx_va_page *va_page; > > > + unsigned int va_offset; > > > + struct list_head list; > > > +}; > > > > This can be without major streches hoops packed way more. There are 12 > > bits free for use in the addr field. I can use low three bits for flags > > and upper nine bits for va_offset. > > > > I think I can also quite easily union epc_page and va_page fields. > > > > With these changes the struct would shrink to: > > > > struct sgx_encl_page { > > unsigned long addr; > > union { > > void *epc_page; > > struct sgx_va_page *va_page; > > }; > > struct list_head list; > > }; > > Once I started to thinking more about this I realized that this can be > shrunk even further. I can drop the list field and use a tag for loaded > pages in the radix tree where these are stored. The end result would be > > struct sgx_encl_page { > unsigned long addr; > union { > void *epc_page; > struct sgx_va_page *va_page; > }; > }; With this last size optimization there is an issue that it would be nice to select the pages to be swapped out in FIFO order. That kind of means that tag would not work quite well. I could try an approach where I have a pointer array to present a queue inside struct sgx_encl for loaded pages and in that way get rid of the 'list' field. /Jarkko