lkml.org 
[lkml]   [2020]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages
On Thu, May 28, 2020 at 08:37:16PM -0700, Sean Christopherson wrote:
> On Fri, May 29, 2020 at 06:28:16AM +0300, Jarkko Sakkinen wrote:
> > On Thu, May 28, 2020 at 12:59:17PM -0700, Sean Christopherson wrote:
> > > On Thu, May 28, 2020 at 10:07:18PM +0300, Jarkko Sakkinen wrote:
> > > > * sgx_grab_page() - Grab a free EPC page
> > > > * @owner: the owner of the EPC page
> > > > * @reclaim: reclaim pages if necessary
> > > > *
> > > > * Iterate through EPC sections and borrow a free EPC page to the caller. When a
> > > > * page is no longer needed it must be released with sgx_free_page(). If
> > > > * @reclaim is set to true, directly reclaim pages when we are out of pages. No
> > > > * mm's can be locked when @reclaim is set to true.
> > > > *
> > > > * Finally, wake up ksgxswapd when the number of pages goes below the watermark
> > > > * before returning back to the caller.
> > > > *
> > > > * Return:
> > > > * an EPC page,
> > > > * -errno on error
> > > > */
> > > >
> > > > I also rewrote the kdoc.
> > > >
> > > > I do agree that sgx_try_grab_page() should be renamed as __sgx_grab_page().
> > >
> > > FWIW, I really, really dislike "grab". The nomenclature for normal memory
> > > and pages uses "alloc" when taking a page off a free list, and "grab" when
> > > elevating the refcount. I don't understand the motivation for diverging
> > > from that. SGX is weird enough as is, using names that don't align with
> > > exist norms will only serve to further obfuscate the code.
> >
> > OK, what would be a better name then? The semantics are not standard
> > memory allocation semantics in the first place. And kdoc in v30 speaks
> > about grabbing.
>
> In what way are they not standard allocation semantics? sgx_alloc_page()
> is an API to allocate (EPC) memory on-demand, sgx_free_page() is its partner
> to free that memory when it is no longer needed. There are many different
> ways to manage and allocate memory, but the basic premise is the same for
> all and no different than what we're doing.

I'll go with sgx_alloc_epc_page(). It is more precise name.

It's not as precise as sgx_alloc_epc_page_from_section but is a great
compromise between scree estate and clarity of expression :-)

/Jarkko

\
 
 \ /
  Last update: 2020-05-29 07:08    [W:0.081 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site