On Tue, Oct 22, 2019 at 12:35:30PM -0700, Sean Christopherson wrote: > On Mon, Oct 21, 2019 at 02:19:08PM +0300, Jarkko Sakkinen wrote: > > On Fri, Oct 18, 2019 at 07:30:57AM -0700, Sean Christopherson wrote: > > > On Fri, Oct 18, 2019 at 03:49:42PM +0300, Jarkko Sakkinen wrote: > > > > On Wed, Oct 16, 2019 at 11:37:45AM -0700, Sean Christopherson wrote: > > > > > Track the free page count on a per EPC section basis so that the value > > > > > is properly protected by the section's spinlock. > > > > > > > > > > As was pointed out when the change was proposed[*], using a global > > > > > non-atomic counter to track the number of free EPC pages is not safe. > > > > > The order of non-atomic reads and writes are not guaranteed, i.e. > > > > > concurrent RMW operats can write stale data. This causes a variety > > > > > of bad behavior, e.g. livelocks because the free page count wraps and > > > > > causes the swap thread to stop reclaiming. > > > > > > > > > > Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> > > > > > > > > What is the reason not change it just to atomic? > > > > > > The purpose of separate sections is to avoid bouncing locks and whatnot > > > across packages. Adding a global atomic to the hotpath defeats that > > > purpose. > > > > I do get that but it does not actually cause incorrect behaviour, > > right? Not being atomic obivously does because READ part of the > > READ+STORE can get re-ordered. > > Haven't tested yet, but it should be functionally correct. I just don't > understand the motivation for the change to a global free count. I get > that we don't have any NUMA awareness whatsoever, but if that's the > argument, why bother with the complexity of per-section tracking in the > first place? You are right what you are saying. We can revert to the aggregation code. I'm just checking that I exactly get the point when it comes to concurrency issues. I can take care of reverting it as I broke it. /Jarkko