lkml.org 
[lkml]   [2021]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH V2] x86/sgx: Fix free page accounting
Date
>>> The consequence of sgx_nr_free_pages not being protected is that
>>> its value may not accurately reflect the actual number of free
>>> pages on the system, impacting the availability of free pages in
>>> support of many flows. The problematic scenario isu when the
>>
> > In non-atomicity is not a problem, when it is not a problem :-)

This is most definitely a problem.

start with sgx_nr_free_pages == 100

Now have a cpu on node0 allocate a page at the same time as another
cpu on node1 allcoates a page. Each holds the relevent per-node lock,
but that doesn't stop both CPUs from accessing the global together:

CPU on node0 CPU on node1
sgx_nr_free_pages--; sgx_nr_free_pages--;

What is the value of sgx_nr_free_pages now? We want it to be 98,
but it could be 99.

Rinse, repeat thousands of times. Eventually the value of sgx_nr_free_pages
has not even a close connection to the number of free pages.

-Tony


\
 
 \ /
  Last update: 2021-11-10 20:17    [W:0.055 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site